Conversation
libuv reports the event loop metrics exposed through `performance.nodeTiming.uvMetricsInfo` as `uint64_t` counters, but they were copied into an `Int32Array` (and, before that, converted using `v8::Integer::New()`), so they wrapped around after 2^31 on long-running processes. Store the metrics in a `Float64Array` instead. Values are now exact up to `Number.MAX_SAFE_INTEGER`. Assisted-by: OpenCode Signed-off-by: James M Snell <jasnell@gmail.com>
`performanceNodeTiming.uvMetricsInfo` is a property, not a method, so document its value using `Type:` rather than `Returns:`. Assisted-by: OpenCode Signed-off-by: James M Snell <jasnell@gmail.com>
Collaborator
|
Review requested:
|
`performance.nodeTiming.uvMetricsInfo` returns the libuv event loop metrics as numbers, which are only exact up to `Number.MAX_SAFE_INTEGER`. Add `uvMetricsInfoBigInt`, which returns the same metrics as bigints backed by `uint64_t` storage, carrying the full 64-bit range reported by libuv. A single native call fills both a `Float64Array` and a `BigUint64Array`, so `uvMetricsInfo` does not pay for bigint allocation and conversion. The new property is omitted from `toJSON()`, as `JSON.stringify()` cannot serialize bigints. Assisted-by: OpenCode Signed-off-by: James M Snell <jasnell@gmail.com>
jasnell
force-pushed
the
jasnell/perf-hooks-uvmetricsinfo-bigint
branch
from
September 17, 2026 22:41
f013265 to
fbab3f2
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #66094 +/- ##
==========================================
- Coverage 92.80% 90.28% -2.52%
==========================================
Files 420 790 +370
Lines 190225 271630 +81405
Branches 29133 51833 +22700
==========================================
+ Hits 176540 245249 +68709
- Misses 13359 16886 +3527
- Partials 326 9495 +9169
🚀 New features to boost your workflow:
|
RafaelGSS
approved these changes
Sep 18, 2026
Collaborator
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.
libuv reports the event loop metrics exposed through
performance.nodeTiming.uvMetricsInfoasuint64_tcounters, butthey were copied into an
Int32Array(and, before that, convertedusing
v8::Integer::New()), so they wrapped around after 2^31 onlong-running processes. While such large numbers aren't typical,
they are possible, making the current implementation flawed.
This PR stores the metrics in a
Float64Arrayinstead. Values arenow exact up to
Number.MAX_SAFE_INTEGER.We also introduce a parallel
uvMetricsInfoBigIntwhose values arerepresented as
bigintto represent the fully correct value.Note that the corrected handling using
Float64Arrayvs.Int32Arrayadds roughly 1-6ns per call overhead to the fact that v8 must create
a
HeapNumberfrom theFloat64Arrayelement while theInt32Arrayallows it to use SMI. Given the typical usage pattern here, however,
6ns is unlikely to be noticed but it will show up in the unrealistic
microbenchmark.