-
Notifications
You must be signed in to change notification settings - Fork 25.4k
Remove HTTP content copies #117303
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
Remove HTTP content copies #117303
Conversation
1a1a83c
to
845c1ab
Compare
Hi @mhl-b, I've created a changelog YAML for you. |
Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination) |
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
return channel -> client.execute( | ||
TransportPutStoredScriptAction.TYPE, | ||
putRequest, | ||
ActionListener.withRef(new RestToXContentListener<>(channel), content) |
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.
This is ok but it looks like we only use org.elasticsearch.action.admin.cluster.storedscripts.PutStoredScriptRequest#content
in order to validate its length, we should replace it with a number.
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.
Actually it's still used in toString()
, but not particularly usefully IMO, so I opened #117556 to remove that (and clean things up in this area too). Once that's backported to 8.18 we can safely replace this with a number in 9.0.
return channel -> client.execute( | ||
PutPipelineTransportAction.TYPE, | ||
request, | ||
ActionListener.withRef(new RestToXContentListener<>(channel), content) |
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.
I thought this wasn't correct, it looked like we end up putting the source in the cluster state, so it seemed that we need to take a copy. But now that I look closer I see that org.elasticsearch.ingest.PipelineConfiguration#PipelineConfiguration(java.lang.String, org.elasticsearch.common.bytes.BytesReference, org.elasticsearch.xcontent.XContentType)
parses the source to a map and stores that. So this seems ok to me.
Remove HTTP content copies entirely from REST handlers. All handlers from now should use RefCounted pooled byte buffers. Handlers that parse x-content in
prepareRequest
by default will use pooled buffers. Other handlers that move pooled buffer to another thread should use new methodActionListener.withRef(listener, content)
for proper reference counting.In current implementation of
ActionListener.withRef
buffers are retained till we have a response. It is not optimal since buffers can be released once request is dispatched in transport. But in reality the performance implication might be negligible. Ideally we should bind buffer lifetime to the transport request, not to results listener. But it's a larger code change. For example BytesTransportRequest implements explicit ref counting for the content.For example:
Follow-up for #116115
Closes ES-10140