-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
http: implement slab allocation for HTTP header parsing #61375
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
base: main
Are you sure you want to change the base?
http: implement slab allocation for HTTP header parsing #61375
Conversation
|
Review requested:
|
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 pull request implements slab allocation for HTTP header parsing to optimize performance by reducing heap allocations. The implementation addresses a TODO comment about O(n) allocations being inefficient and achieves a reported 52% performance improvement in HTTP header parsing benchmarks.
Changes:
- Added a 128-byte fixed-size buffer (slab) to each
StringPtrinstance for caching small strings - Modified
Save()andUpdate()methods to use slab allocation before falling back to heap allocation - Added
using_slab_flag to track slab usage state alongside existingon_heap_flag
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #61375 +/- ##
=======================================
Coverage 88.51% 88.52%
=======================================
Files 704 704
Lines 208776 208790 +14
Branches 40301 40301
=======================================
+ Hits 184803 184832 +29
+ Misses 15966 15925 -41
- Partials 8007 8033 +26
🚀 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
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Reset(); | ||
| } | ||
|
|
||
| // Memory impact: ~8KB per parser (66 StringPtr × 128 bytes). |
Copilot
AI
Jan 13, 2026
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.
The memory calculation is slightly inaccurate. 66 × 128 = 8,448 bytes, which is approximately 8.25KB, not 8KB. Consider updating to '~8.4KB' or '~8.5KB' for better accuracy.
| // Memory impact: ~8KB per parser (66 StringPtr × 128 bytes). | |
| // Memory impact: ~8.4KB per parser (66 StringPtr × 128 bytes). |
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.
Thank you overly pedantic AI code review. The ~8KB is accurate enough here.
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.
Yes, I agree.
fix: // TODO(bnoordhuis) Use slab allocation, O(n) allocs is bad.
before:
after:
52% faster HTTP header parsing