diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2020-06-22 12:35:23 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2020-06-25 21:52:53 +0300 |
commit | 40bc3095ab86d5311b211c2fd08048d9704b6ab2 (patch) | |
tree | 1d238c146866d1c0077f40baff79ca8e912be423 /lib/internal/bootstrap | |
parent | cb2c8106a7aced1a226eba468e27ac75b2ee8bfc (diff) |
lib,src: remove cpu profiler idle notifier
I added it in commit 57231d5286 ("src: notify V8 profiler when we're
idle") from October 2013 as a stop-gap measure to measure CPU time
rather than wall clock time, otherwise processes that spend a lot
of time sleeping in system calls give a false impression of being
very busy.
That fix is not without drawbacks because the idle flag is set before
libuv makes I/O callbacks and cleared again after. I/O callbacks can
result into calls into JS code and executing JS code is as non-idle
as you can get.
In commit 96ffcb9a21 ("src: reduce cpu profiler overhead") from January
2015, I made Node.js block off the SIGPROF signal that V8's CPU profiler
uses before Node.js goes to sleep. The goal of that commit is to reduce
the overhead from EINTR system call wakeups but it also has the pleasant
side effect of fixing what the idle notifier tried to fix.
This commit removes the idle notifier and turns the JS process object
methods into no-ops.
Fixes: https://github.com/nodejs/node/issues/19009
Refs: https://github.com/nodejs/node/pull/33138
PR-URL: https://github.com/nodejs/node/pull/34010
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'lib/internal/bootstrap')
-rw-r--r-- | lib/internal/bootstrap/switches/is_main_thread.js | 8 | ||||
-rw-r--r-- | lib/internal/bootstrap/switches/is_not_main_thread.js | 2 |
2 files changed, 6 insertions, 4 deletions
diff --git a/lib/internal/bootstrap/switches/is_main_thread.js b/lib/internal/bootstrap/switches/is_main_thread.js index be145e84dc2..08623898eda 100644 --- a/lib/internal/bootstrap/switches/is_main_thread.js +++ b/lib/internal/bootstrap/switches/is_main_thread.js @@ -6,8 +6,12 @@ const rawMethods = internalBinding('process_methods'); // TODO(joyeecheung): deprecate and remove these underscore methods process._debugProcess = rawMethods._debugProcess; process._debugEnd = rawMethods._debugEnd; -process._startProfilerIdleNotifier = rawMethods._startProfilerIdleNotifier; -process._stopProfilerIdleNotifier = rawMethods._stopProfilerIdleNotifier; + +// See the discussion in https://github.com/nodejs/node/issues/19009 and +// https://github.com/nodejs/node/pull/34010 for why these are no-ops. +// Five word summary: they were broken beyond repair. +process._startProfilerIdleNotifier = () => {}; +process._stopProfilerIdleNotifier = () => {}; function defineStream(name, getter) { ObjectDefineProperty(process, name, { diff --git a/lib/internal/bootstrap/switches/is_not_main_thread.js b/lib/internal/bootstrap/switches/is_not_main_thread.js index 852352eead0..379ad0a587a 100644 --- a/lib/internal/bootstrap/switches/is_not_main_thread.js +++ b/lib/internal/bootstrap/switches/is_not_main_thread.js @@ -4,8 +4,6 @@ const { ObjectDefineProperty } = primordials; delete process._debugProcess; delete process._debugEnd; -delete process._startProfilerIdleNotifier; -delete process._stopProfilerIdleNotifier; function defineStream(name, getter) { ObjectDefineProperty(process, name, { |