Conversation
Do less variable allocations and reassignments inside spliceOne
since it's relied on by some performance sensitive code.
confidence improvement
util/splice.js size=10 n=10000000 ** 2.95 %
util/splice.js size=100 n=10000000 *** 10.68 %
util/splice.js size=500 n=10000000 *** 11.26 %
BridgeAR
left a comment
There was a problem hiding this comment.
LGTM with the comment addressed.
lib/internal/util.js
Outdated
|
|
||
| // About 1.5x faster than the two-arg version of Array#splice(). | ||
| // Depending on the size of the array, this is anywhere between 1.5-10x | ||
| // faster than the two-arg version of Array#splice() |
There was a problem hiding this comment.
Please add the V8 version this is tested with. And there is a new faster version that is currently deactivated. See https://bugs.chromium.org/p/v8/issues/detail?id=7221
| }, { flags: ['--expose-internals'] }); | ||
|
|
||
| function main({ n, size, type }) { | ||
| const { spliceOne } = require('internal/util'); |
There was a problem hiding this comment.
I'm curious, why put this here?
There was a problem hiding this comment.
The benchmark runs with --expose-internals so the main function has access to them but the outside doesn't.
|
It might be a good idea to also add other special cases for the benchmark, such as splicing the first element and the last element. |
|
Made all the requested changes. |
|
What do the benchmark results look like for the newly added cases? |
|
@mscdex Didn't have time for 100 runs but here's 30: |
|
Landed in b04d092 |
Do less variable allocations and reassignments inside spliceOne since it's relied on by some performance sensitive code. PR-URL: #20453 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Do less variable allocations and reassignments inside spliceOne since it's relied on by some performance sensitive code. PR-URL: #20453 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Do less variable allocations and reassignments inside spliceOne since it's relied on by some performance sensitive code. PR-URL: #20453 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Do less variable allocations and reassignments inside
spliceOnesince it's relied on by some performance sensitive code. This also adds a benchmark forspliceOne.Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes