Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2020-06-22 12:35:23 +0300
committerJames M Snell <jasnell@gmail.com>2020-06-25 21:52:53 +0300
commit40bc3095ab86d5311b211c2fd08048d9704b6ab2 (patch)
tree1d238c146866d1c0077f40baff79ca8e912be423 /src/env.cc
parentcb2c8106a7aced1a226eba468e27ac75b2ee8bfc (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 'src/env.cc')
-rw-r--r--src/env.cc44
1 files changed, 1 insertions, 43 deletions
diff --git a/src/env.cc b/src/env.cc
index 4030df9ec90..991ba3cf98d 100644
--- a/src/env.cc
+++ b/src/env.cc
@@ -485,7 +485,7 @@ Environment::~Environment() {
CHECK_EQ(base_object_count_, 0);
}
-void Environment::InitializeLibuv(bool start_profiler_idle_notifier) {
+void Environment::InitializeLibuv() {
HandleScope handle_scope(isolate());
Context::Scope context_scope(context());
@@ -499,17 +499,6 @@ void Environment::InitializeLibuv(bool start_profiler_idle_notifier) {
uv_check_start(immediate_check_handle(), CheckImmediate);
- // Inform V8's CPU profiler when we're idle. The profiler is sampling-based
- // but not all samples are created equal; mark the wall clock time spent in
- // epoll_wait() and friends so profiling tools can filter it out. The samples
- // still end up in v8.log but with state=IDLE rather than state=EXTERNAL.
- // TODO(bnoordhuis) Depends on a libuv implementation detail that we should
- // probably fortify in the API contract, namely that the last started prepare
- // or check watcher runs first. It's not 100% foolproof; if an add-on starts
- // a prepare or check watcher after us, any samples attributed to its callback
- // will be recorded with state=IDLE.
- uv_prepare_init(event_loop(), &idle_prepare_handle_);
- uv_check_init(event_loop(), &idle_check_handle_);
uv_async_init(
event_loop(),
&task_queues_async_,
@@ -518,8 +507,6 @@ void Environment::InitializeLibuv(bool start_profiler_idle_notifier) {
&Environment::task_queues_async_, async);
env->RunAndClearNativeImmediates();
});
- uv_unref(reinterpret_cast<uv_handle_t*>(&idle_prepare_handle_));
- uv_unref(reinterpret_cast<uv_handle_t*>(&idle_check_handle_));
uv_unref(reinterpret_cast<uv_handle_t*>(&task_queues_async_));
{
@@ -536,10 +523,6 @@ void Environment::InitializeLibuv(bool start_profiler_idle_notifier) {
// the one environment per process setup, but will be called in
// FreeEnvironment.
RegisterHandleCleanups();
-
- if (start_profiler_idle_notifier) {
- StartProfilerIdleNotifier();
- }
}
void Environment::ExitEnv() {
@@ -567,8 +550,6 @@ void Environment::RegisterHandleCleanups() {
register_handle(reinterpret_cast<uv_handle_t*>(timer_handle()));
register_handle(reinterpret_cast<uv_handle_t*>(immediate_check_handle()));
register_handle(reinterpret_cast<uv_handle_t*>(immediate_idle_handle()));
- register_handle(reinterpret_cast<uv_handle_t*>(&idle_prepare_handle_));
- register_handle(reinterpret_cast<uv_handle_t*>(&idle_check_handle_));
register_handle(reinterpret_cast<uv_handle_t*>(&task_queues_async_));
}
@@ -600,29 +581,6 @@ void Environment::CleanupHandles() {
}
}
-void Environment::StartProfilerIdleNotifier() {
- if (profiler_idle_notifier_started_)
- return;
-
- profiler_idle_notifier_started_ = true;
-
- uv_prepare_start(&idle_prepare_handle_, [](uv_prepare_t* handle) {
- Environment* env = ContainerOf(&Environment::idle_prepare_handle_, handle);
- env->isolate()->SetIdle(true);
- });
-
- uv_check_start(&idle_check_handle_, [](uv_check_t* handle) {
- Environment* env = ContainerOf(&Environment::idle_check_handle_, handle);
- env->isolate()->SetIdle(false);
- });
-}
-
-void Environment::StopProfilerIdleNotifier() {
- profiler_idle_notifier_started_ = false;
- uv_prepare_stop(&idle_prepare_handle_);
- uv_check_stop(&idle_check_handle_);
-}
-
void Environment::PrintSyncTrace() const {
if (!trace_sync_io_) return;