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

perf: speed up v8::String::to_rust_*_lossy() #1645

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

lucacasonato
Copy link
Member

This commit speeds up this common conversion
method between by 2x for many common cases. Short
one byte ASCII strings are now 20% faster. Longer
one byte ASCII strings are 2.5x faster. Short UTF8
strings are marginally slower (5%) but longer UTF8
strings are upwards of 2x faster.

A follow up will make the short UTF8 strings about
2x faster than the current implementation as well.

@lucacasonato
Copy link
Member Author

Main

ascii alloc: 28.693481ms
asciilong alloc: 12.713113ms
utf8 alloc: 77.509234ms
utf8long alloc: 415.201443ms
ascii stack: 19.645841ms
asciilong stack: 11.865463ms
utf8 stack: 66.01316ms
utf8long stack: 421.637861ms

ascii alloc: 28.82945ms
asciilong alloc: 12.715254ms
utf8 alloc: 77.888193ms
utf8long alloc: 424.717064ms
ascii stack: 19.456001ms
asciilong stack: 11.794382ms
utf8 stack: 64.327569ms
utf8long stack: 420.072509ms

ascii alloc: 27.680299ms
asciilong alloc: 12.362603ms
utf8 alloc: 77.129383ms
utf8long alloc: 424.482294ms
ascii stack: 20.359151ms
asciilong stack: 12.390033ms
utf8 stack: 66.729982ms
utf8long stack: 422.581681ms

This PR

ascii alloc: 24.014995ms
asciilong alloc: 5.197276ms
utf8 alloc: 80.071666ms
utf8long alloc: 267.608056ms
ascii stack: 16.353647ms
asciilong stack: 5.159856ms
utf8 stack: 71.056516ms
utf8long stack: 273.113161ms

ascii alloc: 23.978715ms
asciilong alloc: 5.238166ms
utf8 alloc: 79.217804ms
utf8long alloc: 265.617734ms
ascii stack: 15.503417ms
asciilong stack: 5.143925ms
utf8 stack: 70.102775ms
utf8long stack: 264.238623ms

ascii alloc: 24.224156ms
asciilong alloc: 5.121675ms
utf8 alloc: 81.940328ms
utf8long alloc: 268.783537ms
ascii stack: 15.651557ms
asciilong stack: 5.150135ms
utf8 stack: 72.978149ms
utf8long stack: 266.422574ms

This commit speeds up this common conversion
method between by 2x for many common cases. Short
one byte ASCII strings are now 20% faster. Longer
one byte ASCII strings are 2.5x faster. Short UTF8
strings are marginally slower (5%) but longer UTF8
strings are upwards of 2x faster.

A follow up will make the short UTF8 strings about
2x faster than the current implementation as well.
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.

1 participant