Httparsed - fast native dlang HTTP 1.x message header parser

Adam D. Ruppe destructionator at gmail.com
Tue Dec 15 01:18:44 UTC 2020


On Tuesday, 15 December 2020 at 00:32:42 UTC, H. S. Teoh wrote:
> It may not be the fastest web module in the D world

It actually does quite well, see: 
https://github.com/tchaloupka/httpbench (from the same OP here :) 
)

The header parser is nothing special, but since header parsing is 
a small part of the overall problem, it is good enough.

Though I have been tempted to optimize it a bit more since in a 
hello world benchmark even a small thing like header parsing can 
be noticeable. The fact that it does some totally unnecessary GC 
allocations can perhaps add up too.

(If I was doing all this again from scratch I'd actually be 
tempted to do a zero-copy, all lazy version. Read from the socket 
directly into the request-local buffer, then slice into it while 
parsing, then do decoding on-demand in that same buffer - url 
encoding always takes more space than the decoded version - and 
the result should be basically the fastest thing you can get. And 
if something comes in above typical size, then it can go back to 
the normal reallocated buffer and still win big on the average 
request. The problem with doing that now would be maintaining 
compatibility with my existing API.)

> (But of course, if Adam improves cgi.d to be competitive with 
> vibe.d

My biggest deficit compared to vibe is prolly documentation. 
Especially of my advanced features which are practically hidden.


More information about the Digitalmars-d-announce mailing list