Visitar URL original
async_hooks: faster AsyncResource#bind() by bengl · Pull Request #43065 · nodejs/node · GitHub
The Wayback Machine - https://web.archive.org/web/20220512031532/https://github.com/nodejs/node/pull/43065
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

async_hooks: faster AsyncResource#bind() #43065

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bengl
Copy link
Member

@bengl bengl commented May 12, 2022 •

FunctionPrototypeBind preserves length, and the asyncResource property can just be set normally, avoiding the costly call to ObjectDefineProperties. In the thisArg === undefined case, reducing it to a single ObjectDefineProperty still has tangible performance gain.

I added a benchmark and here is the output on my machine (the ./node-master result is without this commit, and the ./node result is with it):

$ ./node benchmark/async_hooks/async-resource-bind.js
async_hooks/async-resource-bind.js option="withThisArg" n=1e+100: 4.6615746235960295e+100
async_hooks/async-resource-bind.js option="withoutThisArg" n=1e+100: 5.939287298590602e+100
$ ./node-master benchmark/async_hooks/async-resource-bind.js
async_hooks/async-resource-bind.js option="withThisArg" n=1e+100: 1.6248803889798304e+99
async_hooks/async-resource-bind.js option="withoutThisArg" n=1e+100: 1.6487041313302313e+99

cc @nodejs/async_hooks

@nodejs-github-bot nodejs-github-bot added async_hooks needs-ci labels May 12, 2022
@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented May 12, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
async_hooks needs-ci
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants