deno
a6ab9dfe - fix(inspector): attribute idle event-loop wait to (idle) in CPU profiles (#35034)

Commit
54 days ago
fix(inspector): attribute idle event-loop wait to (idle) in CPU profiles (#35034) Profiling a Deno process over the inspector reported time spent parked in the event loop, waiting for timers or I/O, under the (program) node rather than (idle). The result was that a process doing nothing appeared to use ~100% CPU in Chrome DevTools, making CPU profiles of mostly-idle programs useless. The event loop now calls Isolate::SetIdle to tell V8's CPU profiler when it is about to park, so that wait is attributed to (idle). The call has to happen after the per-poll v8::ContextScope is torn down, because dropping the scope runs Isolate::Exit, which restores the VM state saved on entry and would otherwise immediately clobber the idle state before the loop parks. This matches how Node marks idle time. Note that the attribution only takes effect for `deno run --inspect`; once the debugger has actually paused (`--inspect-brk`) V8 keeps the isolate out of the idle state. Closes #21620
Author
Parents
Loading