buffer: use fast API for writing one-byte strings#54311
buffer: use fast API for writing one-byte strings#54311nodejs-github-bot merged 1 commit intonodejs:mainfrom
Conversation
|
Probably because the benchmark has a flaw, and the input is not a one byte string. I recommend reading this amazing blog post: https://iliazeus.github.io/articles/js-string-optimizations-en/ |
|
@anonrig still only minimal difference: buffers/buffer-write-string.js n=1000000 len=1 9.21 % ±12.42% ±17.25% ±24.00%
buffers/buffer-write-string.js n=1000000 len=16 * 5.12 % ±4.58% ±6.53% ±9.52%
buffers/buffer-write-string.js n=1000000 len=32 2.87 % ±8.49% ±12.18% ±17.88%
buffers/buffer-write-string.js n=1000000 len=8 ** 8.27 % ±5.40% ±7.68% ±11.10% |
|
Can you add a printf to fast api function and make sure that it runs? I've had several occasions that I couldn't trigger fast path for super simple calls. |
|
@anonrig You are right. It's never called and I have no idea why. Do you know anyone that might know more? |
|
Ah, it's because buffer is this and not the first arg. Do you know if fast API works with this args? |
|
The first arg (receiver) is the this arg. |
|
Tried with no this and still no success... seems like a dead end for me |
de22cf8 to
63e7cda
Compare
|
This works for me and the fast api path is hit starting around 1e4 iterations in the benchmark: |
|
Got it to work! buffers/buffer-write-string.js n=1000000 str='a' *** 306.67 % ±7.42% ±10.17% ±13.87%
buffers/buffer-write-string.js n=1000000 str='aa' *** 289.45 % ±3.26% ±4.59% ±6.55%
buffers/buffer-write-string.js n=1000000 str='aaaa' *** 271.79 % ±12.09% ±16.96% ±24.00%looks promising |
f3259aa to
d1eb51b
Compare
9c98f8f to
2596951
Compare
2596951 to
6594e2e
Compare
|
Landed in ccf05ef |
|
Access violation occurred in FastWriteString function, causing the process to crash and exit. @ronag
|
This comment was marked as outdated.
This comment was marked as outdated.
|
@ShenHongFei Thanks for reporting! Fix is ready. |
|
I tried applying the patch https://github.com/nodejs/node/pull/54391/files and the problem was solved. Thank you. |
Refs: #54311 (comment) PR-URL: #54391 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
PR-URL: #54310 PR-URL: #54311 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Refs: #54311 (comment) PR-URL: #54391 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
Notable changes: buffer: * use fast API for writing one-byte strings (Robert Nagy) #54311 * optimize createFromString (Robert Nagy) #54324 * use native copy impl (Robert Nagy) #54087 inspector: * (SEMVER-MINOR) support `Network.loadingFailed` event (Kohei Ueno) #54246 lib: * (SEMVER-MINOR) rewrite AsyncLocalStorage without async_hooks (Stephen Belanger) #48528 module: * (SEMVER-MINOR) unflag detect-module (Geoffrey Booth) #53619 PR-URL: TODO
Notable changes: buffer: * use fast API for writing one-byte strings (Robert Nagy) #54311 * optimize createFromString (Robert Nagy) #54324 * use native copy impl (Robert Nagy) #54087 inspector: * (SEMVER-MINOR) support `Network.loadingFailed` event (Kohei Ueno) #54246 lib: * (SEMVER-MINOR) rewrite AsyncLocalStorage without async_hooks (Stephen Belanger) #48528 module: * (SEMVER-MINOR) unflag detect-module (Geoffrey Booth) #53619 PR-URL: #54452
Notable changes: buffer: * use fast API for writing one-byte strings (Robert Nagy) #54311 * optimize createFromString (Robert Nagy) #54324 * use native copy impl (Robert Nagy) #54087 inspector: * (SEMVER-MINOR) support `Network.loadingFailed` event (Kohei Ueno) #54246 lib: * (SEMVER-MINOR) rewrite AsyncLocalStorage without async_hooks (Stephen Belanger) #48528 module: * (SEMVER-MINOR) add --experimental-transform-types flag (Marco Ippolito) #54283 * (SEMVER-MINOR) unflag detect-module (Geoffrey Booth) #53619 PR-URL: #54452
PR-URL: #54310 PR-URL: #54311 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Refs: #54311 (comment) PR-URL: #54391 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
Notable changes: buffer: * use fast API for writing one-byte strings (Robert Nagy) #54311 * optimize createFromString (Robert Nagy) #54324 * use native copy impl (Robert Nagy) #54087 inspector: * (SEMVER-MINOR) support `Network.loadingFailed` event (Kohei Ueno) #54246 lib: * (SEMVER-MINOR) rewrite AsyncLocalStorage without async_hooks (Stephen Belanger) #48528 module: * (SEMVER-MINOR) add --experimental-transform-types flag (Marco Ippolito) #54283 * (SEMVER-MINOR) unflag detect-module (Geoffrey Booth) #53619 PR-URL: #54452
Notable changes: buffer: * use fast API for writing one-byte strings (Robert Nagy) #54311 * optimize createFromString (Robert Nagy) #54324 * use native copy impl (Robert Nagy) #54087 inspector: * (SEMVER-MINOR) support `Network.loadingFailed` event (Kohei Ueno) #54246 lib: * (SEMVER-MINOR) rewrite AsyncLocalStorage without async_hooks (Stephen Belanger) #48528 module: * (SEMVER-MINOR) add --experimental-transform-types flag (Marco Ippolito) #54283 * (SEMVER-MINOR) unflag detect-module (Geoffrey Booth) #53619 PR-URL: #54452

Uh oh!
There was an error while loading. Please reload this page.