Skip to content
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

Skip media type parsing for known string values #16358

Merged

Conversation

andrross
Copy link
Member

Less intrusive optimization solving the same problem as #16073

Related Issues

Resolves #15979

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@github-actions github-actions bot added enhancement Enhancement or improvement to existing feature or request Libraries Lucene Upgrades and Libraries, Any 3rd party library that Core depends on, ex: nebula; team is respo Performance This is for any performance related enhancements or bugs labels Oct 16, 2024
Copy link
Contributor

❌ Gradle check result for cae2f71: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to forward optimize and add the result of parseMediaType to this map?

@reta
Copy link
Collaborator

reta commented Oct 17, 2024

Love it @andrross ! Thank you!

Any reason not to forward optimize and add the result of parseMediaType to this map?

@dblock I think it would complicate things a lot:
a) map is immutable now but it won't be anymore (with all the consequences)
b) map has to be capped since parseMediaType could accept myriad of variations

I believe the parseMediaType will be done only once for a whole request, may be it is an acceptable tradeoff?

Copy link
Collaborator

@reta reta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM to me!

@andrross
Copy link
Member Author

Any reason not to forward optimize and add the result of parseMediaType to this map?

@dblock I think it would complicate things a lot:
a) map is immutable now but it won't be anymore (with all the consequences)
b) map has to be capped since parseMediaType could accept myriad of variations

@dblock I agree with @reta about the complexities. Also, in my simple testing I can't even find the Content-Type header parsing anywhere in the profile so I think it is negligible. This optimization is targeted at the transport protocol where we've already got a MediaType instance and we just want to serialize it across the wire in the binary protocol.

Copy link
Contributor

✅ Gradle check result for cae2f71: SUCCESS

Copy link

codecov bot commented Oct 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.03%. Comparing base (ec7b652) to head (cae2f71).
Report is 5 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #16358      +/-   ##
============================================
+ Coverage     72.00%   72.03%   +0.02%     
- Complexity    64817    64838      +21     
============================================
  Files          5307     5307              
  Lines        302660   302670      +10     
  Branches      43724    43725       +1     
============================================
+ Hits         217931   218022      +91     
+ Misses        66906    66746     -160     
- Partials      17823    17902      +79     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@andrross andrross added the backport 2.x Backport to 2.x branch label Oct 17, 2024
@andrross andrross merged commit e360ceb into opensearch-project:main Oct 17, 2024
66 of 68 checks passed
@andrross andrross deleted the short-circuit-media-type-parsing branch October 17, 2024 16:46
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 17, 2024
Signed-off-by: Andrew Ross <[email protected]>
(cherry picked from commit e360ceb)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@reta reta added v3.0.0 Issues and PRs related to version 3.0.0 v2.18.0 Issues and PRs related to version 2.18.0 labels Oct 17, 2024
dk2k pushed a commit to dk2k/OpenSearch that referenced this pull request Oct 17, 2024
dbwiddis pushed a commit that referenced this pull request Oct 17, 2024
(cherry picked from commit e360ceb)

Signed-off-by: Andrew Ross <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch enhancement Enhancement or improvement to existing feature or request Libraries Lucene Upgrades and Libraries, Any 3rd party library that Core depends on, ex: nebula; team is respo Performance This is for any performance related enhancements or bugs skip-changelog v2.18.0 Issues and PRs related to version 2.18.0 v3.0.0 Issues and PRs related to version 3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CPU intensive string parsing of MediaType field in binary serialization
3 participants