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>
@codecov

codecov Bot commented Nov 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.52%. Comparing base (7ed1ca0) to head (8c5027b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67833      +/-   ##
==========================================
+ Coverage   90.51%   90.52%   +0.01%     
==========================================
  Files         805      805              
  Lines      285878   285879       +1     
  Branches    55200    55199       -1     
==========================================
+ Hits       258756   258786      +30     
+ Misses      17214    17200      -14     
+ Partials     9908     9893      -15     
Files with missing lines Coverage Δ
src/api/async_resource.cc 83.01% <100.00%> (ø)
src/env.cc 84.20% <100.00%> (-0.06%) ⬇️

... and 29 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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