-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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/new route regexp allocations #732
Optimize/new route regexp allocations #732
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #732 +/- ##
==========================================
- Coverage 79.58% 78.18% -1.40%
==========================================
Files 5 5
Lines 911 903 -8
==========================================
- Hits 725 706 -19
- Misses 131 141 +10
- Partials 55 56 +1 ☔ View full report in Codecov by Sentry. |
f80a252
to
bd66659
Compare
Rebased off #731 |
bd66659
to
ed62916
Compare
@AlexVulaj thanks for #731 merge; rebased this one for review. Benchmark still the same as in description. |
@coreydaley is there anything i can/should do to get this reviewed? |
Hi @titpetric, thanks for working on this! |
@apoorvajagtap took your suggestion, added test to cover the expectation of the error return contents, PTAL |
The lint & security scan errors are not related to the current changes, so I'll go ahead with squash & merge. |
Will there be a new release soon that includes this change? My team and I came across this because we specifically need this type of optimization. |
What type of PR is this? (check all applicable)
Description
This optimizes NewRouter creation. The change introduces strings.Builder for more efficient strings concatenation, and replaces SplitN with Index, avoiding the allocations for the slice.
Related Tickets & Documents
BenchmarkNewRouterRegexpFunc:
Time Improvement: Significant improvement in execution time from 4,713 ns/op to 2,792 ns/op.
Memory Usage: Memory usage per operation dropped from 2,385 bytes to 1,640 bytes.
Allocations: Allocations per operation decreased substantially from 75 to 46.
Added/updated tests?
Run verifications and test
make verify
is passingmake test
is passing