Repository navigation
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (7)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. WalkthroughThe event loop now records start and idle times. Rust bindings expose these measurements to JavaScript, where ChangesEvent-loop utilization measurements
Suggested reviewers: Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The reported snapshot behavior matches Node, and no actionable issue remains after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The new API exposes aggregate timing for the caller’s event loop without accepting a target loop or granting additional privileges. No material security regression was identified. Confidence is limited by incomplete validation of concurrent access and failure paths. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
What does this PR do?
performance.eventLoopUtilization()always returned{ idle: 0, active: 0, utilization: 0 }. It now reports real numbers on macOS and Linux, following Node's semantics.us_loop_run_bun_tick, usockets adds up the time the loop spends blocked in epoll/kqueue (idle_time_ns) and records when the loop first ran (loop_start_ns). Only ticks where the loop actually sleeps are timed.node_util_binding.rsexpose these values in ms.perf_hooks.tsports Node's logic: zeros before the loop starts,elu()returns totals,elu(prev)the delta, andelu(a, b)the difference.Not in this PR: Windows (libuv, still zeros; the docs now say so),
worker.performance.eventLoopUtilization(), and theperformance.nodeTimingplaceholders.How did you verify your code works?
Repro script:
Before (Bun 1.4.2): both lines print
{ idle: 0, active: 0, utilization: 0 }.After (debug build, macOS):
Node prints similar numbers for the same script.
I added a test to
test/js/node/perf_hooks/perf_hooks.test.ts:bun bd test test/js/node/perf_hooks/perf_hooks.test.ts: 14 pass, 0 fail.USE_SYSTEM_BUN=1 bun test test/js/node/perf_hooks/perf_hooks.test.ts -t eventLoopUtilization(Bun 1.4.2): fails, becausebusy.activeis 0.I tested on macOS (kqueue). The Linux epoll path uses the same timing code around
bun_epoll_pwait2, so CI will cover it.