dart-lang / shelf

Web server middleware for Dart
https://pub.dev/packages/shelf
BSD 3-Clause "New" or "Revised" License
921 stars 124 forks source link

`Headers.fromEntries`: using `CaseInsensitiveMap.fromEntries` #437

Closed gmpassos closed 3 months ago

gmpassos commented 3 months ago

gmpassos commented 3 months ago

FYI: @kevmoo

gmpassos commented 3 months ago

I made some tweaks.

nice

kevmoo commented 3 months ago

@gmpassos – and some more tweaks 😄

kevmoo commented 3 months ago

@gmpassos – do you have benchmarks showing this makes things notably faster?

kevmoo commented 3 months ago

@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!

gmpassos commented 3 months ago

@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!

Thanks for the quick response and attention. I will wait for the publication...

kevmoo commented 3 months ago

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

gmpassos commented 3 months ago

@gmpassos – do you have benchmarks showing this makes things notably faster?

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.

kevmoo commented 3 months ago

shelf published w/ this! @gmpassos !