feat(node): implement performance.nodeTiming and uvMetricsInfo#32861
Draft
bartlomieju wants to merge 1 commit intomainfrom
Draft
feat(node): implement performance.nodeTiming and uvMetricsInfo#32861bartlomieju wants to merge 1 commit intomainfrom
bartlomieju wants to merge 1 commit intomainfrom
Conversation
Implement `performance.nodeTiming` from `node:perf_hooks` with a
proper `PerformanceNodeTiming` class instead of an empty object stub.
Implements:
- `name`, `entryType`, `startTime`, `duration` (PerformanceEntry props)
- `nodeStart`, `v8Start`, `environment`, `bootstrapComplete` (timing
milestones, approximated since Deno doesn't track these separately)
- `loopStart`, `loopExit`, `idleTime` (event loop timing, partially
stubbed)
- `uvMetricsInfo` getter returning `{ loopCount, events, eventsWaiting }`
backed by actual event loop counters in deno_core's UvLoopInner
- `toJSON()` for serialization
The event loop metrics are tracked in deno_core:
- `loop_count`: incremented each event loop iteration
- `events`: incremented per I/O event (TCP/TTY) processed
- `events_waiting`: reserved for future use
- Exposed via `uv_loop_metrics_info()` and `op_node_uv_metrics_info`
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #31085
Implements
performance.nodeTimingfromnode:perf_hookswith a properPerformanceNodeTimingclass instead of the empty object stub ({}).Before
After
Changes
deno_core (
libs/core/uv_compat.rs,libs/core/runtime/jsruntime.rs):loop_count,events,events_waitingcounters toUvLoopInnerloop_countincrements each event loop iterationeventsincrements per TCP/TTY I/O event processeduv_loop_metrics_info()public functionext/node (
ops/perf_hooks.rs,lib.rs):op_node_uv_metrics_infoop that reads counters fromUvLoopinOpStateext/node (
polyfills/perf_hooks.js):performance.nodeTiming = {}withPerformanceNodeTimingclassname,entryType,startTime,duration, timing milestones,loopStart,loopExit,idleTime,uvMetricsInfo,toJSON()uvMetricsInfogetter returns real{ loopCount, events, eventsWaiting }Still stubbed/approximated
nodeStart,v8Start,environment,bootstrapComplete) are approximatedidleTimereturns 0 (needs idle time tracking inUvLoopInner)loopExitreturns -1 (needs process exit hook)events_waitingcounter is not yet incrementedTest plan
performance.nodeTiming.uvMetricsInforeturns object with correct shapeloopCountincrements after event loop iterationscargo checkpasses🤖 Generated with Claude Code