Skip to content

diagnostics_channel: add threadpool work event - #65982

Open
IlyasShabi wants to merge 3 commits into
nodejs:mainfrom
IlyasShabi:ishabi/threadpool-dc
Open

IlyasShabi wants to merge 3 commits into
nodejs:mainfrom
IlyasShabi:ishabi/threadpool-dc

Conversation

@IlyasShabi

@IlyasShabi IlyasShabi commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

This PR aims to add support for experimental threadpool.work.<type> diagnostics channel.
type: kind of threadpool work

The event exposes:

  • enqueued: submission timestamp
  • started: execution start timestamp
  • ended: execution end timestamp

These timestamps allow diagnostics tools to distinguish queue time from native execution time. Cancelled work reports started and ended as null.

The channel and subscriber state are cached per Environment so the unsubscribed path remains minimal.

Benchmark

Unsubscribed configurations showed no significant regressions. Most subscribed configurations were also within noise; zlib at n=10000 measured a 3.48% regression on local machine (will share the onces from CI)

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/performance

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. labels Sep 11, 2026

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

while this is a good generic API, I'm not convinced. Shouldn't we add one for each usage?

cc @bengl @Qard ?

@IlyasShabi

Copy link
Copy Markdown
Member Author

@mcollina You mean separate channels named threadpool.work.<type>? This is also a valid approach and would let consumers subscribe only to relevant work and remove type from the payload.

@codecov

codecov Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.60759% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.40%. Comparing base (fcfb7ec) to head (a1c60b9).

Files with missing lines Patch % Lines
src/threadpoolwork-inl.h 82.85% 0 Missing and 6 partials ⚠️
src/env.cc 84.21% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #65982   +/-   ##
=======================================
  Coverage   90.40%   90.40%           
=======================================
  Files         791      791           
  Lines      276226   276293   +67     
  Branches    53045    53053    +8     
=======================================
+ Hits       249732   249796   +64     
+ Misses      16899    16896    -3     
- Partials     9595     9601    +6     
Files with missing lines Coverage Δ
src/crypto/crypto_util.h 66.66% <100.00%> (ø)
src/env.h 97.53% <100.00%> (+0.12%) ⬆️
src/glob/node_glob.cc 75.45% <100.00%> (ø)
src/histogram.cc 86.32% <100.00%> (-0.44%) ⬇️
src/node_api.cc 77.07% <100.00%> (ø)
src/node_diagnostics_channel.cc 85.71% <100.00%> (+1.09%) ⬆️
src/node_diagnostics_channel.h 87.50% <100.00%> (+16.07%) ⬆️
src/node_file.cc 75.57% <100.00%> (ø)
src/node_internals.h 82.25% <100.00%> (+1.90%) ⬆️
src/node_sqlite.cc 81.89% <100.00%> (-0.03%) ⬇️
... and 3 more

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

@mcollina

Copy link
Copy Markdown
Member

yes

@mcollina

Copy link
Copy Markdown
Member

I think you are missing the documentation

@IlyasShabi

Copy link
Copy Markdown
Member Author

@IlyasShabi
IlyasShabi requested a review from mcollina September 14, 2026 13:05
@IlyasShabi

Copy link
Copy Markdown
Member Author

@mcollina could you please have a look?

@IlyasShabi
IlyasShabi requested review from Qard and bengl September 16, 2026 15:21
@IlyasShabi
IlyasShabi force-pushed the ishabi/threadpool-dc branch from ff193a0 to a1c60b9 Compare October 6, 2026 09:26

##### Event: `'threadpool.work.<type>'`

Each kind of thread pool work has a separate channel named by appending its

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.

Make it clear that this is the libuv thread pool. I'd even suggest putting it the event name to make it clearer. While it may be self-evident from reading the supported values, being as specific as possible is helpful in both docs and channel names.

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

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants