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 RoutingContext by removing summary generation and othe… #2295
Conversation
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.
Niiiice 👍
For reference, I tend to look hard at routing code when trying to squeeze out performance since it's a lot of useful functionality, but not needed in RPC-only frameworks like gRPC upstream. So to be able to compete in performance with RPC frameworks, we need to make sure it's as fast as possible - this means having the router cache and making sure construction of the routing context is as lightweight as possible. Hopefully we find more ways to reduce this extra processing even further :) |
Codecov Report
@@ Coverage Diff @@
## master #2295 +/- ##
============================================
- Coverage 73.82% 73.71% -0.11%
+ Complexity 9934 9919 -15
============================================
Files 871 871
Lines 38024 38041 +17
Branches 4663 4671 +8
============================================
- Hits 28070 28041 -29
- Misses 7572 7621 +49
+ Partials 2382 2379 -3
Continue to review full report at Codecov.
|
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.
👍
@trustin your other PR inspired me to use do/while here :D |
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.
Nice! 👍
01cc7f8
to
41d6b55
Compare
…e#2295) …r small tweaks. - Don't generate a summary array for use in hashing and do the computation directly to reduce allocations - Make accept headers extraction non-lazy, it was being eagerly evaluated during summary extraction in the old code anyways. It isn't really possible to use routing cache with lazy attributes anyways - Don't use `forEach` due to extra `Stream` allocation and lambda allocation during extraction (current `forEach` holds a reference to the builder) - Don't allocate list builder when `getAll` headers and the header isn't present After ``` Benchmark Mode Cnt Score Error Units RoutersBenchmark.exactMatch thrpt 5 12921841.803 ▒ 173790.211 ops/s RoutersBenchmark.exactMatch_wrapped thrpt 5 12047216.990 ▒ 351620.117 ops/s ``` Before (wrapped is slower due to double allocation of summary) ``` Benchmark Mode Cnt Score Error Units RoutersBenchmark.exactMatch thrpt 5 7817340.954 ▒ 926608.528 ops/s RoutersBenchmark.exactMatch_wrapped thrpt 5 6175815.558 ▒ 276154.231 ops/s ```
…r small tweaks.
forEach
due to extraStream
allocation and lambda allocation during extraction (currentforEach
holds a reference to the builder)getAll
headers and the header isn't presentAfter
Before (wrapped is slower due to double allocation of summary)