crate/elasticsearch — pull request #23 by mfussenegger (2014-10-17 12:51:46+00:00)
Title: reduce memory usage during fetch source sub phase

XContentFactory.xcontentBuilder() allocates a new BytesStreamOutput using the
default page size which is 16kb.

Can be optimized to use the length of the sourceRef because that is the
maximum size possible size that the streamOutput will use.

For example: This safes about 300 MB memory allocation on a request that is
fetching 200.000 small documents (~ 150 bytes each)