Uh oh!
There was an error while loading. Please reload this page.
src: remove pushValueToArray and setupProcessObject - #24264
Conversation
Some local benchmark results: The Intuitively the new API is doing what has to be done either in JS or C++ - it constructs an Array out of a FixedArray with all the elements readily packed inside, so it shouldn't be slower than the old way (which calls into JS), the impact seems to come from how the new approach affect what gets optimized in a hot loop which rarely happen in real word, so I am inclined to just ignore the results in For reference, something like #24125 shows significant improvement when the length of the array is long enough and the call cannot be optimized (e.g. unconditionally done in C++ land without |
bmeurer
left a comment
There was a problem hiding this comment.
Not sure about the benchmark results TBH.
There was a problem hiding this comment.
Since you already know the capacity needed for this, how about pre-allocating it here?
There was a problem hiding this comment.
Good idea! Thanks for catching that
There was a problem hiding this comment.
Same here, how about preallocating the appropriate capacity?
There was a problem hiding this comment.
Now come to think of it, this one can actually be an array since its capacity cannot be bigger than 32*2, maybe that'll speed it up a bit more..
There was a problem hiding this comment.
I'd trust Are the benchmark around this? 😮std::vector. No need to over-optimize.
Instead of calling into JS from C++ to push values into an array, use the new Array::New API that takes a pointer and a length directly.
Instead of calling into JS from C++ to push values into an array, use the new Array::New API that takes a pointer and a length directly.
Instead of calling into JS from C++ to push values into an array, use the new Array::New API that takes a pointer and a length directly.
Instead of calling into JS from C++ to push values into an array, use the new Array::New API that takes a pointer and a length directly.
Instead of calling into JS from C++ to push values into an array, use the new Array::New API that takes a pointer and a length directly.
Instead of calling into JS from C++ to push values into an array, use the new Array::New API that takes a pointer and a length directly.
3cb8bf9 to
cc511fbCompareInstead of calling into JS from C++ to push values into an array, use the new Array::New API that takes a pointer and a length directly.
The usage of NODE_PUSH_VAL_TO_ARRAY_MAX and push_values_to_array_function has all been removed in favor of the new Array::New API that takes a C++ array. Remove the unused code.
cc511fb to
db5e5faComparejoyeecheung
commented
Nov 11, 2018
Apparently using a fixed-size array in the http parser does the trick, though the impact shown from when n=100 (somehow accuracy is a little bit better): Other benchmark results: |
joyeecheung
commented
Nov 11, 2018
refack
left a comment
There was a problem hiding this comment.
🎉
(just have some style nits)
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Good catch! (though I realize it's originally that way :/)
There was a problem hiding this comment.
I think the compiler should be able optimize this away anyway?
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
/s/nov/origin_v.size()/ for correctness and readability
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
addaleax
left a comment
There was a problem hiding this comment.
Nice work!
And, to be explicit, I’m 👍 on using indexed for-loops here as well (for the reasons @joyeecheung is mentioning).
There was a problem hiding this comment.
I think the compiler should be able optimize this away anyway?
| if (j > 0) | ||
| fn->Call(context, holder, j, argv).ToLocalChecked(); | ||
| for (size_t i = 0; i < nov; ++i) { | ||
| auto entry = origin->ov[i]; |
There was a problem hiding this comment.
I know this is copy-pasted, but I think getting rid of this auto might make things more readable :)
Interesting results: I tried using push_back: emplace_back: I suspect RVO is somehow not in effect with the way Fixed a few nits with const references and a few comments. CI: https://ci.nodejs.org/job/node-test-pull-request/18576/ |
Instead of calling into JS from C++ to push values into an array, use the new Array::New API that takes a pointer and a length directly. PR-URL: #24264 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
The usage of NODE_PUSH_VAL_TO_ARRAY_MAX and push_values_to_array_function has all been removed in favor of the new Array::New API that takes a C++ array. Remove the unused code. PR-URL: #24264 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Instead of calling into JS from C++ to push values into an array, use the new Array::New API that takes a pointer and a length directly. PR-URL: #24264 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Instead of calling into JS from C++ to push values into an array, use the new Array::New API that takes a pointer and a length directly. PR-URL: #24264 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Instead of calling into JS from C++ to push values into an array, use the new Array::New API that takes a pointer and a length directly. PR-URL: #24264 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Instead of calling into JS from C++ to push values into an array, use the new Array::New API that takes a pointer and a length directly. PR-URL: #24264 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Instead of calling into JS from C++ to push values into an array, use the new Array::New API that takes a pointer and a length directly. PR-URL: #24264 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Instead of calling into JS from C++ to push values into an array, use the new Array::New API that takes a pointer and a length directly. PR-URL: #24264 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Instead of calling into JS from C++ to push values into an array, use the new Array::New API that takes a pointer and a length directly. PR-URL: #24264 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
The usage of NODE_PUSH_VAL_TO_ARRAY_MAX and push_values_to_array_function has all been removed in favor of the new Array::New API that takes a C++ array. Remove the unused code. PR-URL: #24264 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Instead of calling into JS from C++ to push values into an array, use the new Array::New API that takes a pointer and a length directly. PR-URL: nodejs#24264 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Instead of calling into JS from C++ to push values into an array, use the new Array::New API that takes a pointer and a length directly. PR-URL: nodejs#24264 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Instead of calling into JS from C++ to push values into an array, use the new Array::New API that takes a pointer and a length directly. PR-URL: nodejs#24264 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Instead of calling into JS from C++ to push values into an array, use the new Array::New API that takes a pointer and a length directly. PR-URL: nodejs#24264 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Instead of calling into JS from C++ to push values into an array, use the new Array::New API that takes a pointer and a length directly. PR-URL: nodejs#24264 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Instead of calling into JS from C++ to push values into an array, use the new Array::New API that takes a pointer and a length directly. PR-URL: nodejs#24264 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Instead of calling into JS from C++ to push values into an array, use the new Array::New API that takes a pointer and a length directly. PR-URL: nodejs#24264 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
The usage of NODE_PUSH_VAL_TO_ARRAY_MAX and push_values_to_array_function has all been removed in favor of the new Array::New API that takes a C++ array. Remove the unused code. PR-URL: nodejs#24264 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
codebytere
commented
Jan 12, 2019
@joyeecheung can/should this be backported to |
This PR removes
pushValueToArrayNODE_PUSH_VAL_TO_ARRAY_MAXenv->env->push_values_to_array_function()In favor of the new V8 C++ API that constructs an Array from a C++ array directly.
Also removes
setupProcessObjectsince by now it is only doing thepush_values_to_array_functionsetup.Also added a test for
os.cpus()values.Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes