Streaming result of queries

@jmorris

For the sake of clarity I want to elaborate on the current behavior:

.NET 4.x:

  • The HTTP response body is collected in a byte buffer and not returned until the entire body has been received. I’m currently unclear from a quick code review if this buffer may be spooled to disk or always lives on the heap
  • The deserialized objects when enumerating the IQueryResult are streamed (unless using an incompatible custom deserializer), but the first result is not available until after the entire body is received

.NET >=6:

  • The HTTP response body is returned as a stream after headers are read
  • The deserialized objects when enumerating the IQueryResult are streamed, the first result is available as soon as it is received over the wire (unless using an incompatible custom deserializer)

The majority of the OOM concerns are around the deserialized POCOs rather than the response body, IMO. What we are discussing changing is only related to the response body in .NET 4 and would improve things as relates to memory if enabled (so long as it isn’t misused and Dispose is called).

The “danger” of this plan is A) people enabling the setting thinking “streaming is good” and then being confused when their app has esoteric and hard-to-diagnose problems with connection pools because they didn’t dispose correctly and B) whatever other strange behaviors exist in .NET 4 that we don’t yet know about that may cause other problems.

1 Like