-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Switch XContentBuilder from BytesStreamOutput to ByteArrayOutputStream #28945
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This switches the underlying byte output representation used by default in `XContentBuilder` from `BytesStreamOutput` to a `ByteArrayOutputStream` (an `OutputStream` can still be specified manually) This is groundwork to allow us to decouple `XContent*` from the rest of the ES core code so that it may be factored into a separate jar. Since `BytesStreamOutput` was not using the recycling instance of `BigArrays`, this should not affect the circuit breaking capabilities elsewhere in the system. Relates to elastic#28504
/cc @elastic/es-core-infra |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me. It is certainly worth looking at the benchmarks after this. I expect if we lose performance we can switch the hot parts to the ctor which takes an OutputStream
and project BytesStreamOutput
if (bos instanceof ByteArrayOutputStream) { | ||
return new BytesArray(((ByteArrayOutputStream) bos).toByteArray()); | ||
} else { | ||
return ((BytesStream) bos).bytes(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh boy!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A problem for another PR, I assume.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, unfortunately
#28945) This switches the underlying byte output representation used by default in `XContentBuilder` from `BytesStreamOutput` to a `ByteArrayOutputStream` (an `OutputStream` can still be specified manually) This is groundwork to allow us to decouple `XContent*` from the rest of the ES core code so that it may be factored into a separate jar. Since `BytesStreamOutput` was not using the recycling instance of `BigArrays`, this should not affect the circuit breaking capabilities elsewhere in the system. Relates to #28504
elastic#28945) This switches the underlying byte output representation used by default in `XContentBuilder` from `BytesStreamOutput` to a `ByteArrayOutputStream` (an `OutputStream` can still be specified manually) This is groundwork to allow us to decouple `XContent*` from the rest of the ES core code so that it may be factored into a separate jar. Since `BytesStreamOutput` was not using the recycling instance of `BigArrays`, this should not affect the circuit breaking capabilities elsewhere in the system. Relates to elastic#28504
* master: (28 commits) Maybe die before failing engine (elastic#28973) Remove special handling for _all in nodes info Remove Booleans use from XContent and ToXContent (elastic#28768) Update Gradle Testing Docs (elastic#28970) Make primary-replica resync failures less lenient (elastic#28534) Remove temporary file 10_basic.yml~ Use different pipeline id in test. (pipelines do not get removed between tests extending from ESIntegTestCase) Use fixture to test the repository-gcs plugin (elastic#28788) Use String.join() to describe a list of tasks (elastic#28941) Fixed incorrect test try-catch statement Plugins: Consolidate plugin and module loading code (elastic#28815) percolator: Take `matchAllDocs` and `verified` of the sub result into account when analyzing a function_score query. Build: Remove rest tests on archive distribution projects (elastic#28952) Remove FastStringReader in favor of vanilla StringReader (elastic#28944) Remove FastCharArrayReader and FastCharArrayWriter (elastic#28951) Continue registering pipelines after one pipeline parse failure. (elastic#28752) Build: Fix ability to ignore when no tests are run (elastic#28930) [rest-api-spec] update doc link for /_rank_eval Switch XContentBuilder from BytesStreamOutput to ByteArrayOutputStream (elastic#28945) Factor UnknownNamedObjectException into its own class (elastic#28931) ...
This switches the underlying byte output representation used by default in
XContentBuilder
fromBytesStreamOutput
to aByteArrayOutputStream
(anOutputStream
can still be specified manually)This is groundwork to allow us to decouple
XContent*
from the rest of the EScore code so that it may be factored into a separate jar.
Since
BytesStreamOutput
was not using the recycling instance ofBigArrays
,this should not affect the circuit breaking capabilities elsewhere in the
system.
Relates to #28504