GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: cut small costs in node::MakeCallback by nigrosimone · Pull Request #66395 · nodejs/node

Conversation

@nigrosimone

@nigrosimone nigrosimone commented Sep 29, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

After #66316, node::MakeCallback still does some work that the common case does not need:

  • it enters the Environment's context also when it is already the entered and current one
  • it sets the async context frame also when it does not change (usually undefined before and after): now async_context_frame::exchange() skips the set, for every caller
  • push_async_context() takes the resource variant by value
  • the native resource stack uses resize() where push_back() and pop_back() are enough

Each one is 1-5 ns, together about 14-16 ns per call. type=Call does not use this code. benchmark/compare.js, 30 runs, Linux x64:

                                                    confidence improvement accuracy (*)   (**)  (***)
napi/make_callback n=1000000 type='AsyncResource'           ***      9.10 %  ±4.88% ±6.51% ±8.49%
napi/make_callback n=1000000 type='Call'                            -0.76 %  ±5.76% ±7.66% ±9.97%
napi/make_callback n=1000000 type='MakeCallback'            ***     13.24 %  ±6.31% ±8.40% ±10.93%
napi/make_callback n=10000000 type='AsyncResource'           **      8.68 %  ±5.17% ±6.89% ±8.98%
napi/make_callback n=10000000 type='Call'                           -1.65 %  ±6.17% ±8.21% ±10.69%
napi/make_callback n=10000000 type='MakeCallback'           ***     11.56 %  ±2.91% ±3.87% ±5.04%

Refs: nodejs/performance#24

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@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 Sep 29, 2026
@nigrosimone
nigrosimone marked this pull request as ready for review September 29, 2026 14:08
@nigrosimone nigrosimone mentioned this pull request Sep 29, 2026
MakeCallback is very slow nodejs/performance#24
Open
@codecov

codecov Bot commented Sep 29, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.35294% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.38%. Comparing base (1f26576) to head (8acef08).
⚠️ Report is 376 commits behind head on main.

Files with missing lines Patch % Lines
src/api/callback.cc 57.14% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66395      +/-   ##
==========================================
+ Coverage   90.35%   90.38%   +0.03%     
==========================================
  Files         792      792              
  Lines      275500   275592      +92     
  Branches    52791    52848      +57     
==========================================
+ Hits       248932   249105     +173     
+ Misses      16992    16893      -99     
- Partials     9576     9594      +18     
Files with missing lines Coverage Δ
src/async_context_frame.cc 100.00% <100.00%> (ø)
src/env.cc 82.22% <100.00%> (-0.01%) ⬇️
src/env.h 97.40% <ø> (+0.06%) ⬆️
src/api/callback.cc 81.94% <57.14%> (-1.47%) ⬇️

... and 39 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.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

meixg
meixg approved these changes Sep 30, 2026
View reviewed changes
@addaleax addaleax added the needs-benchmark-ci PRs that need a benchmark CI run. label Sep 30, 2026
addaleax
addaleax reviewed Sep 30, 2026
View reviewed changes
Comment thread src/api/callback.cc Resolved

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Sep 30, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Benchmark GHA (napi / make_callback): https://github.com/nodejs/node/actions/runs/36693603945

Results

[!WARNING]
Do not take GHA benchmark results as face value, always confirm them
using a dedicated machine, e.g. Jenkins CI.

Benchmark results:

[!WARNING]
Do not take GHA benchmark results as face value, always confirm them
using a dedicated machine, e.g. Jenkins CI.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nigrosimone
src: cut small costs in node::MakeCallback
8acef08
Enter the Environment's context only when it is not already the
entered and current one, set the async context frame only when it
changes, pass the resource variant to push_async_context() by const
reference, and grow and shrink the native resource stack with
push_back() and pop_back() instead of resize().

Refs: nodejs/performance#24
Signed-off-by: Nigro Simone <[email protected]>
@nigrosimone
nigrosimone force-pushed the callback-context-scope branch from 4667f95 to 8acef08 Compare September 30, 2026 11:47
@nigrosimone

nigrosimone commented Sep 30, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Benchmark GHA (napi / make_callback): https://github.com/nodejs/node/actions/runs/36693603945

@addaleax The GHA benchmark could not load the binding ("Binding failed to load" in every job): the workflow runs make build-ci but never make bench-addons-build, so no napi/* benchmark can run there. The table in the description is benchmark/compare.js on my machine.


fixed in:

  • benchmark,tools: fix napi benchmarks on GHA #66423
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

nigrosimone added a commit to nigrosimone/node that referenced this pull request Sep 30, 2026
@nigrosimone
benchmark,tools: fix napi benchmarks on GHA
d1e747a
The GHA benchmark never built the addons of benchmark/napi, and its
--debug-node build made benchmark/common.js look for them in
build/Debug. Build them when the napi category runs, and pick the
build type as test/common does.

Refs: nodejs#66395
Signed-off-by: Nigro Simone <[email protected]>
This was referenced Sep 30, 2026
benchmark,tools: fix napi benchmarks on GHA #66423
Merged
Provide common utilities such as readJson uNetworking/uWebSockets.js#1346
Open
nigrosimone added a commit to nigrosimone/node that referenced this pull request Oct 3, 2026
@nigrosimone
benchmark,tools: fix napi benchmarks on GHA
e0dad8b
The GHA benchmark never built the addons of benchmark/napi, and its
--debug-node build made benchmark/common.js look for them in
build/Debug. Build them when the napi category runs, and pick the
build type as test/common does.

Refs: nodejs#66395
Signed-off-by: Nigro Simone <[email protected]>
This was referenced Oct 4, 2026
node-api: find the Environment once #66509
Merged
src: add MakeCallback() taking an Environment #66510
Merged
src: skip the async id stack when nobody sees it #66511
Merged
anonrig
anonrig approved these changes Oct 4, 2026
View reviewed changes
@anonrig anonrig added author ready PRs with CI started, the required approvals, and no outstanding review comments. request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Oct 4, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 4, 2026
@nodejs-github-bot

nodejs-github-bot commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/78165/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

aduh95 pushed a commit that referenced this pull request Oct 11, 2026
@nigrosimone
benchmark,tools: fix napi benchmarks on GHA
6f71b9b
The GHA benchmark never built the addons of benchmark/napi, and its
--debug-node build made benchmark/common.js look for them in
build/Debug. Build them when the napi category runs, and pick the
build type as test/common does.

Refs: #66395
Signed-off-by: Nigro Simone <[email protected]>
PR-URL: #66423
Reviewed-By: Antoine du Hamel <[email protected]>
@github-actions

github-actions Bot commented Oct 11, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Benchmark GHA (napi / make_callback): https://github.com/nodejs/node/actions/runs/38123439742

Results

[!WARNING]
Do not take GHA benchmark results as face value, always confirm them
using a dedicated machine, e.g. Jenkins CI.

Benchmark results:

                              confidence improvement accuracy (*)    (**)   (***)
napi/make_callback n=1000000                 10.33 %      ±17.33% ±22.92% ±29.54%
napi/make_callback n=10000000                 7.75 %      ±16.89% ±22.33% ±28.78%

Be aware that when doing many comparisons the risk of a false-positive
result increases. In this case, there are 2 comparisons, you can thus
expect the following amount of false-positive results:
  0.10 false positives, when considering a   5% risk acceptance (*, **, ***),
  0.02 false positives, when considering a   1% risk acceptance (**, ***),
  0.00 false positives, when considering a 0.1% risk acceptance (***)

[!WARNING]
Do not take GHA benchmark results as face value, always confirm them
using a dedicated machine, e.g. Jenkins CI.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

MikeMcC399 pushed a commit to MikeMcC399/node that referenced this pull request Oct 11, 2026
@nigrosimone @MikeMcC399
benchmark,tools: fix napi benchmarks on GHA
de2f9ae
The GHA benchmark never built the addons of benchmark/napi, and its
--debug-node build made benchmark/common.js look for them in
build/Debug. Build them when the napi category runs, and pick the
build type as test/common does.

Refs: nodejs#66395
Signed-off-by: Nigro Simone <[email protected]>
PR-URL: nodejs#66423
Reviewed-By: Antoine du Hamel <[email protected]>
@panva

panva commented Oct 11, 2026

Copy link
Copy Markdown
Member

FYI the benchmark shows no confidence in the results.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nigrosimone

nigrosimone commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

Yes, on GHA the accuracy is ±17% for a change of 8-13%, so it cannot say. On my machine, 30 runs, it is *** with ±3-6% (table in the description). Could someone run it on the Jenkins benchmark machine?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

richardlau pushed a commit that referenced this pull request Oct 12, 2026
@nigrosimone @richardlau
benchmark,tools: fix napi benchmarks on GHA
a0e638f
The GHA benchmark never built the addons of benchmark/napi, and its
--debug-node build made benchmark/common.js look for them in
build/Debug. Build them when the napi category runs, and pick the
build type as test/common does.

Refs: #66395
Signed-off-by: Nigro Simone <[email protected]>
PR-URL: #66423
Reviewed-By: Antoine du Hamel <[email protected]>
richardlau pushed a commit that referenced this pull request Oct 12, 2026
@nigrosimone @richardlau
benchmark,tools: fix napi benchmarks on GHA
7911e7a
The GHA benchmark never built the addons of benchmark/napi, and its
--debug-node build made benchmark/common.js look for them in
build/Debug. Build them when the napi category runs, and pick the
build type as test/common does.

Refs: #66395
Signed-off-by: Nigro Simone <[email protected]>
PR-URL: #66423
Reviewed-By: Antoine du Hamel <[email protected]>
richardlau pushed a commit that referenced this pull request Oct 12, 2026
@nigrosimone @richardlau
benchmark,tools: fix napi benchmarks on GHA
493bd6c
The GHA benchmark never built the addons of benchmark/napi, and its
--debug-node build made benchmark/common.js look for them in
build/Debug. Build them when the napi category runs, and pick the
build type as test/common does.

Refs: #66395
Signed-off-by: Nigro Simone <[email protected]>
PR-URL: #66423
Reviewed-By: Antoine du Hamel <[email protected]>
@nigrosimone

nigrosimone commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

@addaleax you added needs-benchmark-ci: could someone run the Jenkins benchmark job, category napi, filter make_callback?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@legendecas legendecas added the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 20, 2026
legendecas
legendecas approved these changes Oct 20, 2026
View reviewed changes
@nodejs-github-bot
nodejs-github-bot merged commit 5a566ac into nodejs:main Oct 20, 2026
72 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

Landed in 5a566ac

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 20, 2026
@nigrosimone nigrosimone mentioned this pull request Oct 20, 2026
src: do not shrink async resources on every pop #66344
Merged
@aduh95 aduh95 mentioned this pull request Oct 27, 2026
2026-10-28, Version 27.0.0-alpha.0.0.0 (Alpha) #67062
Merged
aduh95 pushed a commit that referenced this pull request Nov 12, 2026
@nigrosimone @aduh95
src: cut small costs in node::MakeCallback
14cb1f5
Enter the Environment's context only when it is not already the
entered and current one, set the async context frame only when it
changes, pass the resource variant to push_async_context() by const
reference, and grow and shrink the native resource stack with
push_back() and pop_back() instead of resize().

Refs: nodejs/performance#24
Signed-off-by: Nigro Simone <[email protected]>
PR-URL: #66395
Reviewed-By: Xuguang Mei <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
nigrosimone added a commit to nigrosimone/fulmine.js that referenced this pull request Nov 18, 2026
@nigrosimone
docs(how-its-built): add nodejs/node#66395 and #66344
92ca992
Signed-off-by: Nigro Simone <[email protected]>
@github-actions github-actions Bot mentioned this pull request Nov 20, 2026
2026-11-30, Version 26.14.0 'Lithium' (LTS) #67664
Open
gabylb pushed a commit to gabylb/node that referenced this pull request Nov 27, 2026
@nigrosimone @gabylb
src: cut small costs in node::MakeCallback
3cbedbc
Enter the Environment's context only when it is not already the
entered and current one, set the async context frame only when it
changes, pass the resource variant to push_async_context() by const
reference, and grow and shrink the native resource stack with
push_back() and pop_back() instead of resize().

Refs: nodejs/performance#24
Signed-off-by: Nigro Simone <[email protected]>
PR-URL: nodejs#66395
Reviewed-By: Xuguang Mei <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@addaleax addaleax addaleax left review comments
@anonrig anonrig anonrig approved these changes
@legendecas legendecas legendecas approved these changes
@meixg meixg meixg approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. c++ Issues and PRs that require attention from people who are familiar with C++. needs-benchmark-ci PRs that need a benchmark CI run. needs-ci PRs that need a full CI run.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@nigrosimone @nodejs-github-bot @panva @addaleax @anonrig @legendecas @meixg
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.