-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
⚡️ Performance optimizations #3477
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
Conversation
NEW Benchmark_HTTPHandler-12 1762837 640.6 ns/op 696 B/op 10 allocs/op Benchmark_HTTPHandler-12 1924524 616.5 ns/op 696 B/op 10 allocs/op Benchmark_HTTPHandler-12 1838780 650.4 ns/op 696 B/op 10 allocs/op Benchmark_HTTPHandler-12 1876947 644.0 ns/op 696 B/op 10 allocs/op OLD Benchmark_HTTPHandler-12 1864819 667.2 ns/op 720 B/op 11 allocs/op Benchmark_HTTPHandler-12 1892569 677.0 ns/op 720 B/op 11 allocs/op Benchmark_HTTPHandler-12 1811704 639.5 ns/op 720 B/op 11 allocs/op Benchmark_HTTPHandler-12 1879849 644.0 ns/op 720 B/op 11 allocs/op Utils / IsNoCache NEW Benchmark_Utils_IsNoCache-12 44307204 27.08 ns/op 0 B/op 0 allocs/op Benchmark_Utils_IsNoCache-12 40782919 26.88 ns/op 0 B/op 0 allocs/op Benchmark_Utils_IsNoCache-12 44228217 26.69 ns/op 0 B/op 0 allocs/op Benchmark_Utils_IsNoCache-12 45605700 26.75 ns/op 0 B/op 0 allocs/op OLD Benchmark_Utils_IsNoCache-12 30043908 37.80 ns/op 0 B/op 0 allocs/op Benchmark_Utils_IsNoCache-12 32137476 37.51 ns/op 0 B/op 0 allocs/op Benchmark_Utils_IsNoCache-12 31474653 37.92 ns/op 0 B/op 0 allocs/op Benchmark_Utils_IsNoCache-12 31838683 37.71 ns/op 0 B/op 0 allocs/op
WalkthroughThe pull request updates internal logic for detecting "no-cache" in a helper function, optimizes the initialization of an HTTP handler adaptor by moving it outside the closure, and introduces a benchmark test for the adaptor. No exported function signatures are changed. Changes
Sequence Diagram(s)sequenceDiagram
participant Test as Benchmark_HTTPHandler
participant Fiber as Fiber App
participant Adaptor as HTTPHandler Adaptor
participant Handler as http.HandlerFunc
Test->>Adaptor: Call HTTPHandler(Handler)
Adaptor->>Handler: Initialize handler (once)
loop b.N times
Test->>Adaptor: Call adaptor with Fiber context
Adaptor->>Handler: Serve HTTP request
Handler-->>Adaptor: Respond with status and body
Adaptor-->>Test: Return nil
end
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
⏰ Context from checks skipped due to timeout of 90000ms (6)
🔇 Additional comments (3)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3477 +/- ##
==========================================
+ Coverage 83.87% 84.35% +0.48%
==========================================
Files 119 120 +1
Lines 11892 12161 +269
==========================================
+ Hits 9974 10258 +284
+ Misses 1488 1475 -13
+ Partials 430 428 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull Request Overview
This PR introduces performance optimizations by updating the HTTP handler adapter and streamlining the caching check in utility functions.
- Updated HTTPHandler wrapper for better benchmark performance
- Added benchmark for HTTPHandler
- Refactored isNoCache utility for efficiency
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| middleware/adaptor/adaptor_test.go | New benchmark added for HTTPHandler performance |
| middleware/adaptor/adaptor.go | Simplified HTTPHandler wrapper implementation using fasthttpadaptor |
| helpers.go | Rewritten isNoCache function to improve performance |
Comments suppressed due to low confidence (1)
helpers.go:586
- Returning false immediately when there aren't enough characters remaining may prematurely exit the loop. Consider replacing 'return false' with 'break' to ensure the rest of the string is scanned for a potential match.
if i+ncLen > n {
adpater / HTTPHandler
NEW
OLD
Utils / IsNoCache
NEW
OLD