-
Notifications
You must be signed in to change notification settings - Fork 0
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
Implement an incremental HTTP parser using the llhttp APIs #90
Comments
I'm not 100% on the requirements here, since most special/fringe cases are either handled by llhttp itself, or would need to be tested separately as part of #137 (and related issues). I suppose as long as "chunks" can be parsed and (llhttp-ffi) events are triggered on success/error, that's as good a starting point as any. The main thing I've taken care of already is to allow forwarding events to Lua from C without incurring the 50x slowdown. Right now, the parser can replay events and generate (buffered) Lua requests/responses at about 40%+ native performance, which could clearly be better but also a lot worse. If more is needed, 60% to 95% should be possible by moving the Streaming mode is TBD, but should be possible via libuv APIs already (need to overwrite the parser's default event handlers). |
The above design is still too slow. The last version amounted to about 16-20% of llhttp's performance. Considering there are many features that were missing, I might just go a different route and assemble the messages fully in C. This means:
I guess the Lua version that's based on string buffers could be used for the streaming mode. If there's so much I/O then the parsing overhead should be negligible, i.e. the slowdown doesn't matter as much. There may still be issues with the excessive memory consumption in those cases, though. Perhaps the best solution is no solution and to just use nginx if this feature is needed? |
The current version should fulfill all requirements and allow future extension, for example streaming large files via libuv FS requests. I'm sure a lot could be done to improve the implementation, but I guess it's good enough to move on to the HTTP RFCs for now. |
Goals:
The text was updated successfully, but these errors were encountered: