Uh oh!
There was an error while loading. Please reload this page.
http: use v8::Array::New() with a prebuilt vector - #46447
Conversation
Avoid using v8::Array::Set() which results in JS execution and is thus slow. Prebuild the vector in C++ land and build the JS array directly with that vector whereever possible.
nodejs-github-bot
commented
Jan 31, 2023
Review requested:
|
This comment was marked as outdated.
This comment was marked as outdated.
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.
nodejs-github-bot
commented
Feb 3, 2023
| ASSIGN_OR_RETURN_UNWRAP(&list, args.Holder()); | ||
| uint32_t i = 0; | ||
| std::vector<Local<Value>> result; |
There was a problem hiding this comment.
What about using MaybeStackBuffer to avoid allocations if number of elements is not too high?
There was a problem hiding this comment.
I think v8::Array -> std::vector would make sense (to avoid C++ -> JS invocation costs) but std::vector -> MaybeStackBuffer probably would not make much difference...(and personally I prefer STL unless the home-grown alternatives makes a significant difference)
nodejs-github-bot
commented
Feb 4, 2023
nodejs-github-bot
commented
Feb 6, 2023
nodejs-github-bot
commented
Feb 8, 2023
Landed in a5ede9c |
Avoid using v8::Array::Set() which results in JS execution and is thus slow. Prebuild the vector in C++ land and build the JS array directly with that vector whereever possible. PR-URL: #46447 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: James M Snell <jasnell@gmail.com>
Avoid using v8::Array::Set() which results in JS execution and is thus slow. Prebuild the vector in C++ land and build the JS array directly with that vector whereever possible. PR-URL: #46447 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: James M Snell <jasnell@gmail.com>
Avoid using v8::Array::Set() which results in JS execution and is thus slow. Prebuild the vector in C++ land and build the JS array directly with that vector whereever possible.