-
Notifications
You must be signed in to change notification settings - Fork 282
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
[Performance Bug] Repeated deserialization of headers for a direct channel request #2724
Comments
[Triage] Hi @parasjain1, thank you for filing this issue. If you would be interested in opening a PR this may be the fastest way to correct the behavior you documented. Please reach out to @cwperks with any additional context. |
This might not be a straightforward if-else fix as Serializing: Background: Transport service uses When the request flow reaches Deserializing: Since |
Update: One possible solution to solve the serializing approach is to compare the ephemeralIds of localNode and connection Node. This is derived for DiscoveryNode.java's equals() method to compare two nodes. I will raise a PR for this. |
HeaderHelper.isDirectRequest() has the logic to determine if the current request is a direct (local node) request. It relies on a header |
|
Checked this, and this indeed is the flow. The method name HeaderHelper.isDirectRequest() lead me to believe that this would work anywhere in the security plugin flow. Thanks for pointing out @mgodwan. |
@parasjain1 @mgodwan I have raised a PR for this fix. Please review: #2765 |
Post fix observations: Profiling Security Transport InterceptorsPrerequisites:
Pre #2765Setup:
Steps:
Results:
Post the fix: #2765Setup:
Steps:
Results:
Conclusion:We can infer that for smaller number of bulk requests (100k) we see a decrease of .15% of CPU usage. Although not highly visible this number would rise when number of requests increase significantly. Appendix:bulk-index.py
|
What is the issue?
During a direct channel request i.e. a request which originated and is handled by the same node, the security plugin kicks in and deserializes
userHeader
andoriginalRemoteAddress
objects again hence consuming more time to process the request.How can one reproduce the bug?
A simple bulk request on a multi node cluster should reproduce the issue.
What is the expected behavior?
Do not deserialize the objects again for direct channel requests, and re-use the previously deserialized values.
What is your host/environment?
Do you have any additional context?
SecurityIntercepter.sendMessageDecorate
stashes the current thread context due to which the transient headers are cleared.SecurityRequestHandler.messageReceivedDecorate
deserializes the userHeader and originalRemoteAddress objects just to put them in thread context's transient headers.For a direct channel request (channelType == "direct"),
SecurityIntercepter.sendMessageDecorate
may retain these values in transient headers andSecurityRequestHandler.messageReceivedDecorate
will no longer need to deserialize these again.The text was updated successfully, but these errors were encountered: