-
Notifications
You must be signed in to change notification settings - Fork 10
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
parser: two-phase parsing #120
base: develop
Are you sure you want to change the base?
Conversation
An automated preview of the documentation is available at https://120.http-proto.prtest.cppalliance.org/index.html |
1 similar comment
An automated preview of the documentation is available at https://120.http-proto.prtest.cppalliance.org/index.html |
With the new changes, the parser returns immediately after the header is parsed and does not begin parsing the body until the next call to `parse()`. In the case of bodiless messages and head responses, it directly transitions to the `complete_in_place` state after the header is parsed, making a call to `parse()` unnecessary (but still valid). This two-phase parsing brings a few benefits with almost no complications on the usage side of the API: - It introduces an optimization opportunity for users who want to attach a body. If they do so immediately after the header is parsed (which seems to be the case most of the time), there's no need for `cb1_` for elastic bodies and a small `cb1_` for sink bodies (as it will be used temporarily). This means all the extra space can be utilized for `cb0_`. - Because parsing the body might complete with an error, returning after the header is parsed allows users to access the header and on the next call to parse encounter the error. - Setting the body limit in the middle of parsing the body or after it doesn't make much sense, so returning right after the header is parsed provides a window for setting such limits. - If users want to attach a body, they will almost always do so immediately after the header is parsed. By not continuing the parsing of the body, we avoid the need for an extra buffer copy operation (in case the user wants to attach a buffer).
GCOVR code coverage report https://120.http-proto.prtest.cppalliance.org/gcovr/index.html |
An automated preview of the documentation is available at https://120.http-proto.prtest.cppalliance.org/index.html |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #120 +/- ##
===========================================
- Coverage 91.11% 90.96% -0.15%
===========================================
Files 81 81
Lines 4806 4826 +20
===========================================
+ Hits 4379 4390 +11
- Misses 427 436 +9
Continue to review full report in Codecov by Sentry.
|
GCOVR code coverage report https://120.http-proto.prtest.cppalliance.org/gcovr/index.html |
With the new changes, the parser returns immediately after the header is parsed and does not begin parsing the body until the next call to
parse()
. In the case of bodiless messages and head responses, it directly transitions to thecomplete_in_place
state after the header is parsed, making a call toparse()
unnecessary (but still valid).This two-phase parsing brings a few benefits with almost no complications on the usage side of the API:
cb1_
for elastic bodies and a smallcb1_
for sink bodies (as it will be used temporarily). This means all the extra space can be utilized forcb0_
.