6 ms·
On a related note, we go through great lengths in the Kestrel HTTP server [0] (which also uses libuv) to have fast HTTP parsing. As an example, we attempt to re
by cesarbs 10y ago
On a related note, we go through great lengths in the Kestrel HTTP server [0] (which also uses libuv) to have fast HTTP parsing. As an example, we attempt to read the method and the HTTP version as longs and compare them to pre-computed longs in order to have fast comparisons and reuse strings containing standard methods and versions (reducing memory allocation is the main driver of our optimizations) [1], so we don't have to allocate those strings on every request. We do a similar thing for headers [2]. We also manage a lot of our own memory, despite using a garbage collected language [3].
[0] https://github.com/aspnet/KestrelHttpServer https://github.com/aspnet/KestrelHttpServer
[1] https://github.com/aspnet/KestrelHttpServer/blob/3a424f6abac6a019da4d00c32e98880c0f99e8d7/src/Microsoft.AspNetCore.Server.Kestrel/Infrastructure/MemoryPoolIteratorExtensions.cs#L295 https://github.com/aspnet/KestrelHttpServer/blob/3a424f6abac...
[2] https://github.com/aspnet/KestrelHttpServer/blob/dev/src/Microsoft.AspNetCore.Server.Kestrel/Http/FrameHeaders.Generated.cs https://github.com/aspnet/KestrelHttpServer/blob/dev/src/Mic...
[3] https://github.com/aspnet/KestrelHttpServer/blob/dev/src/Microsoft.AspNetCore.Server.Kestrel/Infrastructure/MemoryPool.cs https://github.com/aspnet/KestrelHttpServer/blob/dev/src/Mic...
- 1st1 10y agoHave you benchmarked it?