-
Notifications
You must be signed in to change notification settings - Fork 127
Headers.fromEntries
: using CaseInsensitiveMap.fromEntries
#437
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
Headers.fromEntries
: using CaseInsensitiveMap.fromEntries
#437
Conversation
* Optimize constructor `_`: use `CaseInsensitiveMap.fromEntries`.
* Added the constructor `Headers.fromEntries`. * Added the internal constructor `_fromEntries`, which uses `CaseInsensitiveMap.fromEntries` for optimization. * Renamed the internal constructor `_` to `_from`, redirecting it to `this._fromEntries`.
FYI: @kevmoo |
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.
I made some tweaks.
nice |
@gmpassos – and some more tweaks 😄 |
@gmpassos – do you have benchmarks showing this makes things notably faster? |
@gmpassos – we need to roll this through our internal "stuff" before we publish. To make sure nothing breaks. I'll let you know when publish happens! |
Revisions updated by `dart tools/rev_sdk_deps.dart`. async (https://github.com/dart-lang/async/compare/a004370..d7c0cd5): d7c0cd5 2024-06-17 Kevin Moore Drop use of pkg:collection whereNotNull() (dart-archive/async#278) dartdoc (https://github.com/dart-lang/dartdoc/compare/14d33d3..818d1f5): 818d1f52 2024-06-17 Sam Rawlins Minor improvement to the 'documentedWhere' comment (dart-lang/dartdoc#3789) 39591df5 2024-06-17 Sam Rawlins Pipe the '--stats' flag through for the 'doc sdk' task (dart-lang/dartdoc#3791) 6b2ee570 2024-06-17 Sam Rawlins Use 'named' extension in tests (dart-lang/dartdoc#3790) fabc394b 2024-06-17 Sam Rawlins Add more information to various asserts. (dart-lang/dartdoc#3787) 64982f89 2024-06-17 Parker Lougheed Update to package:lints v4 (dart-lang/dartdoc#3785) http_parser (https://github.com/dart-lang/http_parser/compare/71b4c2c..9bf7bd9): 9bf7bd9 2024-06-17 Kevin Moore Prepare release v4.1.0 (dart-archive/http_parser#100) shelf (https://github.com/dart-lang/shelf/compare/4c54af6..2536c15): 2536c15 2024-06-17 Graciliano Monteiro Passos `Headers.fromEntries`: using `CaseInsensitiveMap.fromEntries` (dart-lang/shelf#437) Change-Id: Iff49c7356534f950147b2c0c087e59414a6fc393 Tested: pkg/vm changes are updating test expectations Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372101 Commit-Queue: Devon Carew <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]> Auto-Submit: Devon Carew <[email protected]>
Thanks for the quick response and attention. I will wait for the publication... |
Looks like @devoncarew landed in the Dart SDK 50 minutes ago. We'll have to wait a few hours to make sure that rolls into our internal...things...before we publish |
In my benchmark, I get a 1-2% improvement, but note that you need to have real-world headers (real browsers send many more headers than simple HTTP clients). Additionally, you need a heavy load, as this also affects the GC. This is more significant for slower/smaller servers. On a medium-sized server with low traffic, this won't have much impact. I'm also looking for a way to avoid computation of all canonicalized keys just to build the headers. This will significantly improve performance, or we could use a specialized cache of canonicalized keys, but this will be a future optimization. |
shelf published w/ this! @gmpassos ! |
Headers
:Headers.fromEntries
._fromEntries
, which usesCaseInsensitiveMap.fromEntries
for optimization._
to_from
, redirecting it tothis._fromEntries
.