Skip to content

Commit 9ba84d8

Browse files
author
Oleksandr Chekhovskyi
committed
src: fix v8::CpuProfiler idle sampling
Ensure that samples are evenly distributed, which is required for v8::CpuProfiler users to work correctly (v8-profiler / node-inspector).
1 parent 422d56e commit 9ba84d8

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/node.cc

+9-4
Original file line numberDiff line numberDiff line change
@@ -3587,10 +3587,6 @@ inline void PlatformInit() {
35873587
RegisterSignalHandler(SIGINT, SignalExit, true);
35883588
RegisterSignalHandler(SIGTERM, SignalExit, true);
35893589

3590-
// Block SIGPROF signals when sleeping in epoll_wait/kevent/etc. Avoids the
3591-
// performance penalty of frequent EINTR wakeups when the profiler is running.
3592-
uv_loop_configure(uv_default_loop(), UV_LOOP_BLOCK_SIGNAL, SIGPROF);
3593-
35943590
// Raise the open file descriptor limit.
35953591
struct rlimit lim;
35963592
if (getrlimit(RLIMIT_NOFILE, &lim) == 0 && lim.rlim_cur != lim.rlim_max) {
@@ -3674,6 +3670,15 @@ void Init(int* argc,
36743670
}
36753671
}
36763672

3673+
#ifdef __POSIX__
3674+
// Block SIGPROF signals when sleeping in epoll_wait/kevent/etc. Avoids the
3675+
// performance penalty of frequent EINTR wakeups when the profiler is running.
3676+
// Only do this for v8.log profiling, as it breaks v8::CpuProfiler users.
3677+
if (v8_is_profiling) {
3678+
uv_loop_configure(uv_default_loop(), UV_LOOP_BLOCK_SIGNAL, SIGPROF);
3679+
}
3680+
#endif
3681+
36773682
#if defined(NODE_HAVE_I18N_SUPPORT)
36783683
if (icu_data_dir == nullptr) {
36793684
// if the parameter isn't given, use the env variable.

0 commit comments

Comments
 (0)