Repository navigation
src: add MakeCallback() taking an Environment - #66510
Merged
Merged
Conversation
Collaborator
|
Review requested:
|
nigrosimone
force-pushed
the
makecallback-env
branch
from
October 21, 2026 00:58
310f545 to
77584c5
Compare
Member
|
Why still draft? |
Contributor
Author
|
Now is ready
|
nigrosimone
force-pushed
the
makecallback-env
branch
from
November 9, 2026 15:27
77584c5 to
7383b33
Compare
nigrosimone
force-pushed
the
makecallback-env
branch
3 times, most recently
from
November 9, 2026 17:22
0bf95f3 to
c07db16
Compare
node::MakeCallback() looks up the Environment from the creation context of the callback on every call. An addon that calls into the same Environment many times, a server calling one handler per request for example, can now take it once with GetCurrentEnvironment() and pass it. The callback must belong to that Environment. Add a benchmark, napi/make_callback_env, comparing the two overloads. Refs: nodejs/performance#24 Signed-off-by: Nigro Simone <nigro.simone@gmail.com>
nigrosimone
force-pushed
the
makecallback-env
branch
from
November 26, 2026 05:39
c07db16 to
3278f89
Compare
nigrosimone
marked this pull request as ready for review
November 26, 2026 05:43
Collaborator
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #66510 +/- ##
==========================================
- Coverage 92.59% 90.50% -2.10%
==========================================
Files 433 805 +372
Lines 200382 285810 +85428
Branches 30786 55184 +24398
==========================================
+ Hits 185553 258681 +73128
- Misses 14486 17214 +2728
- Partials 343 9915 +9572
🚀 New features to boost your workflow:
|
jasnell
approved these changes
Nov 26, 2026
Collaborator
|
Landed in 3872251 |
nigrosimone
added a commit
to nigrosimone/fulmine.js
that referenced
this pull request
Nov 27, 2026
Signed-off-by: Nigro Simone <nigro.simone@gmail.com>
This was referenced Nov 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
node::MakeCallback()looks up the Environment from the creation context of the callback on every call. This adds an overload that takes it: an addon calling into the same Environment many times (uWS calls one handler per request) takes it once withGetCurrentEnvironment()and passes it. The callback must belong to that Environment.It uses the internal helper added in #66509. The new benchmark
napi/make_callback_envruns both overloads in the same process: 133.0 to 118.9 ns at n=1e7 (+11.8%) and 130.6 to 124.5 ns at n=1e6 (+4.9%), with #66395 and #66500 underneath, Linux x64, one core.This is new public API, the shape was discussed in nodejs/performance#24.
Disclosure: I used Opus 5.5 (Max) as coding assistant