Skip to content

src: skip the Environment lookup when it is already known - #67833

Open
nigrosimone wants to merge 1 commit into
nodejs:mainfrom
nigrosimone:async-resource-env
Open

nigrosimone wants to merge 1 commit into
nodejs:mainfrom
nigrosimone:async-resource-env

Conversation

@nigrosimone

@nigrosimone nigrosimone commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up of #66510, from the question in nodejs/performance#24 (comment) about places in Node that already have the Environment.

  • AsyncResource::MakeCallback() keeps env_, but went through InternalMakeCallback(isolate, ...), which looks up the Environment again from the creation context of the callback on every call. It now calls MakeCallbackInEnvironment(env_, ...), as Node-API does since node-api: find the Environment once #66509. This is the path of the addons that use node::AsyncResource.
  • Environment::CheckImmediate() called MakeCallback(env->isolate(), ...) with env in hand, now MakeCallback(env, ...).

The lookup removed is the same one #66510 saves for addons (133 -> 119 ns per call), so the AsyncResource row of benchmark/napi/make_callback should move the same way.

Disclosure: I used Opus 5.5 (Max) as coding assistant

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Nov 27, 2026
Signed-off-by: Nigro Simone <nigro.simone@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants