Skip to content
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 improvements #680

Merged
merged 32 commits into from
Apr 6, 2021
Merged

parser improvements #680

merged 32 commits into from
Apr 6, 2021

Conversation

ronag
Copy link
Member

@ronag ronag commented Apr 5, 2021

Refactors and simplifies parser.

@ronag ronag requested a review from dnlup April 5, 2021 21:22
@codecov-io
Copy link

codecov-io commented Apr 5, 2021

Codecov Report

Merging #680 (0d1a0f7) into main (c266bc9) will increase coverage by 0.24%.
The diff coverage is 93.90%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #680      +/-   ##
==========================================
+ Coverage   97.25%   97.50%   +0.24%     
==========================================
  Files          26       26              
  Lines        2004     2122     +118     
==========================================
+ Hits         1949     2069     +120     
+ Misses         55       53       -2     
Impacted Files Coverage Δ
lib/client.js 98.69% <92.30%> (+0.17%) ⬆️
lib/llhttp/parser.js 92.45% <94.64%> (+0.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c266bc9...0d1a0f7. Read the comment docs.

@ronag ronag requested a review from mcollina April 5, 2021 21:38
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the changes looks good but CI is failing

if (ret !== 0) {
return ret
}
currentParser[kStatusMessage] = cstr(at, length)
return 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this function is empty, is it still needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, otherwise the WASM fails

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dnlup we might want to make this optional there, it will save a few cycle.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, all the functions exported in https://github.com/nodejs/undici/blob/main/deps/llhttp/src/api.c#L29 must be provided in the initialization.

if (ret !== 0) {
return ret
}
currentParser[kStatusMessage] = cstr(at, length)
return 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, all the functions exported in https://github.com/nodejs/undici/blob/main/deps/llhttp/src/api.c#L29 must be provided in the initialization.

lib/llhttp/parser.js Show resolved Hide resolved
lib/llhttp/parser.js Show resolved Hide resolved
@ronag ronag requested a review from dnlup April 6, 2021 07:25
lib/client.js Outdated
@@ -816,7 +798,11 @@ function onSocketError (err) {
}

function onSocketData (data) {
this[kParser].execute(data)
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a small drop in the benchmarks, I'll run them again to be sure the use of the try/catch is having an impact.

https://github.com/nodejs/undici/runs/2275815074?check_suite_focus=true

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the try catch should be easy. I’ll fix it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a second run, benchmarks look good. I would not change it yet.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Does it impact our benchmarks?

@dnlup
Copy link
Contributor

dnlup commented Apr 6, 2021

lgtm

Does it impact our benchmarks?

Benchmarks look good

@ronag ronag merged commit e7a4bcf into main Apr 6, 2021
@Uzlopak Uzlopak deleted the parser2 branch February 21, 2024 12:39
crysmags pushed a commit to crysmags/undici that referenced this pull request Feb 27, 2024
* refactor: parser upgrade

* refactor: parser onBody

* refactor: parser onmessagecomplete

* perf: parser pre-allocate array

* refactor: parser onHeaders

* refactor: parser simplify

* fix: remove unused var

* fix: add assertion

* refactor: inline makeError

* refactor: parse this[kBufferSize]

* refactor: parser don't are about statusMessage

* fixup! fix: add assertion

* fix

* fix: parser kHeaders

* fixup

* fixup

* fixuP

* fixuP

* fixuP

* fixuP

* fixuP

* fixuP

* fixuP

* fixuP

* fixuP

* fixup: assertion

* fixup

* fixup

* fixup

* fixup

* fixup: avoid try/catch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants