Skip to content

src: fast path empty native immediate drain - #62969

Merged
nodejs-github-bot merged 2 commits into
nodejs:mainfrom
gurgunday:perf/env-skip-native-immediate
Jun 14, 2026
Merged

src: fast path empty native immediate drain#62969
nodejs-github-bot merged 2 commits into
nodejs:mainfrom
gurgunday:perf/env-skip-native-immediate

Conversation

@gurgunday

@gurgundaygurgunday commented Apr 26, 2026

Copy link
Copy Markdown
Member

RunAndClearNativeImmediates is called from CheckImmediate on every event loop tick, but most calls have no native immediates queued

  • Add a fast path that checks the three queues that are drained here. If all three are empty, return before creating any V8 handles or scopes
  • Use the same check in CheckImmediate, along with a JS immediate existance check, to exit even earlier

Before:

./node benchmark/run.js --filter immediate.js --set type=depth --set n=5000000 timers
timers/immediate.js
timers/immediate.js type="depth" n=5000000: 77,957.7280919732
./node benchmark/run.js --filter immediate.js --set type=depth1 --set n=5000000 timers
timers/immediate.js
timers/immediate.js type="depth1" n=5000000: 78,239.25105583081
./node benchmark/run.js --filter set-immediate-depth-args.js --set n=5000000 timers
timers/set-immediate-depth-args.js
timers/set-immediate-depth-args.js n=5000000: 77,728.55421361701

After:

./node benchmark/run.js --filter immediate.js --set type=depth --set n=5000000 timers
timers/immediate.js
timers/immediate.js type="depth" n=5000000: 81,438.54733112443
./node benchmark/run.js --filter immediate.js --set type=depth1 --set n=5000000 timers
timers/immediate.js
timers/immediate.js type="depth1" n=5000000: 81,920.65230335212
./node benchmark/run.js --filter set-immediate-depth-args.js --set n=5000000 timers
timers/set-immediate-depth-args.js
timers/set-immediate-depth-args.js n=5000000: 80,653.84783982178

@nodejs-github-botnodejs-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 Apr 26, 2026
@gurgunday
gurgundayforce-pushed the perf/env-skip-native-immediate branch from dc6cba4 to 0bed081CompareApril 26, 2026 11:55
@gurgundaygurgunday changed the title env: skip empty native immediate callback scopesrc: fast path empty native immediate drainApr 26, 2026
@gurgundaygurgunday added the performance Issues and PRs related to the performance of Node.js. label Apr 26, 2026
@codecov

codecovBot commented Apr 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.65%. Comparing base (c202696) to head (1584afc).
⚠️ Report is 479 commits behind head on main.

Additional details and impacted files
@@ Coverage Diff @@## main #62969 +/- ##
==========================================
- Coverage 89.66% 89.65% -0.02% 
==========================================
Files 706 706 Lines 219416 219424 +8 Branches 42073 42077 +4 ==========================================
- Hits 196738 196718 -20 - Misses 14576 14591 +15 - Partials 8102 8115 +13 
Files with missing linesCoverage Δ
src/env.cc85.31% <100.00%> (-0.22%)⬇️
src/env.h98.14% <ø> (ø)

... and 21 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.

Signed-off-by: Gürgün Dayıoğlu <hey@gurgun.day>
@gurgunday
gurgundayforce-pushed the perf/env-skip-native-immediate branch from 0bed081 to 1584afcCompareApril 26, 2026 13:38
@addaleaxaddaleax added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 27, 2026
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 27, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@gurgundaygurgunday added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 27, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@addaleaxaddaleax added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 2, 2026
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 2, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@gurgundaygurgunday added commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. commit-queue Add this label to land a pull request using GitHub Actions. labels Jun 13, 2026
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 14, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 4fb667e into nodejs:mainJun 14, 2026
85 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 4fb667e

aduh95 pushed a commit that referenced this pull request Jun 18, 2026
Signed-off-by: Gürgün Dayıoğlu <hey@gurgun.day>
PR-URL: #62969
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
@gurgunday
gurgunday deleted the perf/env-skip-native-immediate branch June 22, 2026 17:38
maksimyaromin added a commit to maksimyaromin/isolated-vm that referenced this pull request Jul 22, 2026
TransferablePromiseHolder::ResolveTask settles the receiving side's promise without running a microtask checkpoint, so under the nodejs isolate's explicit microtasks policy the awaiting continuations stay queued until unrelated JS activity runs one. Node used to mask this with an accidental per-iteration checkpoint; nodejs/node#62969 (26.4.0) removed it.
laverdet pushed a commit to laverdet/isolated-vm that referenced this pull request Aug 1, 2026
TransferablePromiseHolder::ResolveTask settles the receiving side's promise without running a microtask checkpoint, so under the nodejs isolate's explicit microtasks policy the awaiting continuations stay queued until unrelated JS activity runs one. Node used to mask this with an accidental per-iteration checkpoint; nodejs/node#62969 (26.4.0) removed it.
skvelymake pushed a commit to integromat/isolated-vm that referenced this pull request Aug 5, 2026
TransferablePromiseHolder::ResolveTask settles the receiving side's promise without running a microtask checkpoint, so under the nodejs isolate's explicit microtasks policy the awaiting continuations stay queued until unrelated JS activity runs one. Node used to mask this with an accidental per-iteration checkpoint; nodejs/node#62969 (26.4.0) removed it.
@aduh95aduh95 added the backport-requested-v24.x PRs awaiting manual backport to the v24.x-staging branch. label Aug 6, 2026
@aduh95

Copy link
Copy Markdown
Contributor

This doesn't land cleanly on v24.x-staging, it would require a manual backport PR if we want it on Node.js 24

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.backport-requested-v24.xPRs awaiting manual backport to the v24.x-staging branch.c++Issues and PRs that require attention from people who are familiar with C++.commit-queue-squashAdd this label to instruct the Commit Queue to squash all the PR commits into the first one.needs-ciPRs that need a full CI run.performanceIssues and PRs related to the performance of Node.js.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@gurgunday@nodejs-github-bot@aduh95@addaleax@anonrig