-
Notifications
You must be signed in to change notification settings - Fork 32
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
Optimize UserAgents #868
Optimize UserAgents #868
Conversation
Use a hand-rolled implementation to validate user agent name to avoid allocation and regex overhead.
Generate changelog in
|
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.
Optimized code remains very readable. I'm always surprised at how expensive regexes are in java!
Tweaked the implementation a bit more exactly follow regex and improved a bit more:
|
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.
Looks great, thanks!
Released 2.27.0 |
Before this PR
Similar to #864 , JFRs showing significant allocations and CPU consumed due to
com.palantir.conjure.java.api.config.service.UserAgents#isValidName
andcom.palantir.conjure.java.api.config.service.UserAgents#format
during Dialogue request processingAfter this PR
Some initial benchmark results on 16 core
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
whereregex
is the previous implementation andparser
is our hand rolled non-allocating version.==COMMIT_MSG==
Optimize UserAgents
Optimize UserAgents.isValidName to use a hand-rolled implementation to validate user agent name to avoid
allocation and regex overhead.
Increase default UserAgents.format string builder buffer size and ensure capacity as we append user agents.
==COMMIT_MSG==
Possible downsides?
Complexity of maintaining is higher than simple regex