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
deps: add simdutf dependency #45803
base: main
Are you sure you want to change the base?
deps: add simdutf dependency #45803
Conversation
|
Review requested: |
2c20c9a
to
6daa546
Compare
|
This would help speedup both ws and undici's WebSocket implementation (which is still WIP). When we receive a text frame or receive a close frame with a reason, we need to validate that the buffer contains valid utf-8. There are a few ways of doing so currently: a js implementation by default in both undici and ws, and optionally a package such as utf-8-validate. Note that simdutf is many times faster than the c++ version of utf-8-validate in the benchmark above, and the js fallback version is the slowest. Here is a PR from @lpinca that shows massive speedups when using simdutf: websockets/utf-8-validate#101. Considering how widespread usage of ws is, exposing a very fast ability to validate utf-8 would improve a ton of the ecosystem. |
5027cae
to
e94ba5f
Compare
bed88cc
to
4269faf
Compare
ced7ef2
to
5566c99
Compare
|
@mscdex I pushed a new commit adding |
|
@anonrig can you check the before/after binary size? |
|
|
It's |
@mscdex This is caused by our CIs. I believe we need to use a more recent compiler/assembler on CI. @nodejs/build wdyt? |
Well, node still supports building with (at least) gcc 8.3, so we need to make sure node can still compile on gcc 8. |
@mscdex It builds correctly on GCC-8. Benchmark CI machine has |
If it's using the Can we get confirmation on the build environment tool versions from @nodejs/build ? |
on the list of technical debt for the Build WG is upgrading the benchmark machine to something newer than Ubuntu 16.04. |
|
With the build tools being the same versions then, that must mean that the benchmark machine has opposite CPU feature availability (AVX512-wise) compared to the other x64 CI machines (e.g. benchmark CI has them and test CI does not or vice versa). Either way, I think this shows there is something not quite right with the compile-time CPU checks. |
|
FWIW the machine has the latest available binutils package for Ubuntu 16.04: and here's the last entry in |
16.04 is unsupported as of April 2021. The build team has already planned to upgrade the machine, and all supported CI machines have a passing build & tests. I believe this should not be a blocker. |
I'd like to be able to run the benchmarks in CI to verify the benchmark results, especially since there seems to be some configurations missing from the provided output. |
Co-authored-by: Daniel Lemire <daniel@lemire.me>
|
@mscdex With the help of @lemire, I've added the necessary configuration to disable AVX512 for old setups, such as our benchmark CI. The benchmark result can be seen from: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1272/console |
simdutf provides a faster way of providing utf8 operations with SIMD instructions. @nodejs/undici team was looking for a way to validate utf8 input, and this dependency can make it happen.
Edit: I'm proposing either exposing the following functionality through a new module (like
node:encoding) or throughutil.typesorbuffervalidate_ascii(string)validate_utf8(string)count_utf8(string)PS:
simdutfsupports more features, and depending on the need, it makes more sense to expose them through a new module, instead ofutil.typesorbuffer.