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

@gurgunday gurgunday 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-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 Apr 26, 2026
@gurgunday gurgunday force-pushed the perf/env-skip-native-immediate branch from dc6cba4 to 0bed081 Compare April 26, 2026 11:55
@gurgunday gurgunday changed the title env: skip empty native immediate callback scope src: fast path empty native immediate drain Apr 26, 2026
@gurgunday gurgunday added the performance Issues and PRs related to the performance of Node.js. label Apr 26, 2026
@codecov

codecov Bot 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 lines Coverage Δ
src/env.cc 85.31% <100.00%> (-0.22%) ⬇️
src/env.h 98.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 gurgunday force-pushed the perf/env-skip-native-immediate branch from 0bed081 to 1584afc Compare April 26, 2026 13:38
@addaleax addaleax added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 27, 2026
@github-actions github-actions Bot 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.

@gurgunday gurgunday 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.

@addaleax addaleax added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 2, 2026
@github-actions github-actions Bot 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

@gurgunday gurgunday 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-bot nodejs-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:main Jun 14, 2026
85 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 4fb667e

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

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run. performance Issues and PRs related to the performance of Node.js.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants