Skip to content

process: skip AsyncResource in queueMicrotask when only ALS is active - #67986

Open
IlyasShabi wants to merge 1 commit into
nodejs:mainfrom
IlyasShabi:ishabi/micro-task-als
Open

IlyasShabi wants to merge 1 commit into
nodejs:mainfrom
IlyasShabi:ishabi/micro-task-als

Conversation

@IlyasShabi

Copy link
Copy Markdown
Member

V8's MicrotaskQueue::EnqueueMicrotask already preserves CPED, so the AsyncResource wrapper in queueMicrotask() is only needed when async_hooks are enabled. This means any process using ALS currently pays an AsyncResource + bound function + closure allocation per microtask for nothing.

Local benchmark:

using node benchmark/compare.js --runs 30

                                                      confidence improvement
    process/queue-microtask-breadth.js als=0 n=400000                 1.74 %
    process/queue-microtask-breadth.js als=1 n=400000        ***    239.66 % 
    process/queue-microtask-depth.js  als=0 n=1200000         *       2.60 %
    process/queue-microtask-depth.js  als=1 n=1200000        ***    205.69 % 

Results: Perf improvement with ALS, no regression without it.

Signed-off-by: Ilyas Shabi <ilyas.shabi@datadoghq.com>
@IlyasShabi
IlyasShabi requested a review from gurgunday December 3, 2026 15:00
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/performance

@IlyasShabi
IlyasShabi requested a review from Qard December 3, 2026 15:00
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. process Issues and PRs related to the process subsystem. labels Dec 3, 2026
@IlyasShabi
IlyasShabi marked this pull request as ready for review December 3, 2026 15:16

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Dec 3, 2026

@gurgunday gurgunday left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@gurgunday gurgunday added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Dec 3, 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 Dec 3, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@codecov

codecov Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.59%. Comparing base (9873287) to head (0bcb9d8).
⚠️ Report is 13 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67986      +/-   ##
==========================================
+ Coverage   90.56%   90.59%   +0.02%     
==========================================
  Files         802      802              
  Lines      286935   286954      +19     
  Branches    55415    55405      -10     
==========================================
+ Hits       259871   259957      +86     
+ Misses      17161    17108      -53     
+ Partials     9903     9889      -14     
Files with missing lines Coverage Δ
lib/internal/process/task_queues.js 100.00% <100.00%> (ø)

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

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

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

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. needs-ci PRs that need a full CI run. process Issues and PRs related to the process subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants