Uh oh!
There was an error while loading. Please reload this page.
async_hooks: faster AsyncResource#bind() - #43065
Conversation
nodejs-github-bot
commented
May 12, 2022
Looks like I submitted too soon again here. While |
bengl
commented
May 12, 2022
Setting this as "ready for review" again. It's now always doing an |
This comment was marked as outdated.
This comment was marked as outdated.
mcollina
left a comment
There was a problem hiding this comment.
LGTM
How did you found this was a bottleneck? :D
bengl
commented
May 12, 2022
@mcollina |
bengl
commented
May 12, 2022
Here's a benchmark run: https://ci.nodejs.org/job/benchmark-node-micro-benchmarks/1136/ |
nodejs-github-bot
commented
May 12, 2022
nodejs-github-bot
commented
May 15, 2022
| value: this, | ||
| writable: true, | ||
| } | ||
| ObjectDefineProperty(bound, 'length', { |
There was a problem hiding this comment.
Why not just stop doing this completely? This is only one of the cases needed to preserve the original functionality as the function could also have other properties or symbols attached to it for example, and those wouldn't be copied. Maybe the best approach then would be to copy nothing and leave it to the user to decide what needs copying. Then the implementation will be as fast as it can be and will only become slower if the user decides that copying properties is needed.
nodejs-github-bot
commented
May 17, 2022
bengl
commented
Nov 12, 2023
Closing since #46432 precludes this. |
theFunctionPrototypeBindpreserveslength, andasyncResourceproperty can just be set normally, avoiding the costly call toObjectDefineProperties.In thereducing it to a singlethisArg === undefinedcase,ObjectDefinePropertystillhas tangible performance gain.I added a benchmark and here is the output on my machine (the
./node-masterresult is without this commit, and the./noderesult is with it):(Expand here for old/incorrect benchmark.)
cc @nodejs/async_hooks