Skip to content

Commit b0df227

Browse files
Oleksandr ChekhovskyiFishrock123
Oleksandr Chekhovskyi
authored andcommitted
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). PR-URL: #2324 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 8119693 commit b0df227

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
@@ -3567,10 +3567,6 @@ inline void PlatformInit() {
35673567
RegisterSignalHandler(SIGINT, SignalExit, true);
35683568
RegisterSignalHandler(SIGTERM, SignalExit, true);
35693569

3570-
// Block SIGPROF signals when sleeping in epoll_wait/kevent/etc. Avoids the
3571-
// performance penalty of frequent EINTR wakeups when the profiler is running.
3572-
uv_loop_configure(uv_default_loop(), UV_LOOP_BLOCK_SIGNAL, SIGPROF);
3573-
35743570
// Raise the open file descriptor limit.
35753571
struct rlimit lim;
35763572
if (getrlimit(RLIMIT_NOFILE, &lim) == 0 && lim.rlim_cur != lim.rlim_max) {
@@ -3635,6 +3631,15 @@ void Init(int* argc,
36353631
}
36363632
}
36373633

3634+
#ifdef __POSIX__
3635+
// Block SIGPROF signals when sleeping in epoll_wait/kevent/etc. Avoids the
3636+
// performance penalty of frequent EINTR wakeups when the profiler is running.
3637+
// Only do this for v8.log profiling, as it breaks v8::CpuProfiler users.
3638+
if (v8_is_profiling) {
3639+
uv_loop_configure(uv_default_loop(), UV_LOOP_BLOCK_SIGNAL, SIGPROF);
3640+
}
3641+
#endif
3642+
36383643
#if defined(NODE_HAVE_I18N_SUPPORT)
36393644
if (icu_data_dir == nullptr) {
36403645
// if the parameter isn't given, use the env variable.

0 commit comments

Comments
 (0)