Skip to content

src: add event loop based metrics into node - #62935

Merged
nodejs-github-bot merged 9 commits into
nodejs:mainfrom
pabloerhard:pabloerhard/add-event-loop-metrics
Jun 24, 2026
Merged

nodejs-github-bot merged 9 commits into
nodejs:mainfrom
pabloerhard:pabloerhard/add-event-loop-metrics

Conversation

@pabloerhard

@pabloerhard pabloerhard commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

Adds an opt in into monitorEventLoopDelay(), this option adds support for per iteration sampling using libuv hooks, while preserving the existing timer based approach.

When the new samplePerIteration option is set to true, monitorEventLoopDelay() samples directly from event loop iterations instead of using the interval timer. When samplePerIteration is omitted or false, the existing interval based implementation remains unchanged, including resolution handling and the older interval based trace counters.

Motivation
The interval based implementation has two limitations that the new option addresses:

  • Inaccurate measurements. Delay was approximated from a timer dispatch jitter (RecordDelta() between timer ticks) rather than measured from the loop itself. Samples had an implicit floor of resolution ms and could miss delays that didn't happen to coincide with a timer tick.
  • Wasteful wake ups. The timer forced the event loop to iterate every resolution ms just to record a sample, even when the application was otherwise idle and no one was reading the histogram.

This is an alternative implementation to the one in #62934

This PR directly addresses the following issue #56064

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

Labels

backport-open-v24.x Indicate that the PR has an open backport c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-squash PRs the Commit Queue should land as one squashed commit. needs-ci PRs that need a full CI run. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants