Skip to content

Commit

Permalink
src: fix v8::CpuProfiler idle sampling
Browse files Browse the repository at this point in the history
Ensure that samples are evenly distributed, which is required for v8::CpuProfiler
users to work correctly (v8-profiler / node-inspector).
  • Loading branch information
Oleksandr Chekhovskyi committed Aug 28, 2015
1 parent 422d56e commit 9ba84d8
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3587,10 +3587,6 @@ inline void PlatformInit() {
RegisterSignalHandler(SIGINT, SignalExit, true);
RegisterSignalHandler(SIGTERM, SignalExit, true);

// Block SIGPROF signals when sleeping in epoll_wait/kevent/etc. Avoids the
// performance penalty of frequent EINTR wakeups when the profiler is running.
uv_loop_configure(uv_default_loop(), UV_LOOP_BLOCK_SIGNAL, SIGPROF);

// Raise the open file descriptor limit.
struct rlimit lim;
if (getrlimit(RLIMIT_NOFILE, &lim) == 0 && lim.rlim_cur != lim.rlim_max) {
Expand Down Expand Up @@ -3674,6 +3670,15 @@ void Init(int* argc,
}
}

#ifdef __POSIX__
// Block SIGPROF signals when sleeping in epoll_wait/kevent/etc. Avoids the
// performance penalty of frequent EINTR wakeups when the profiler is running.
// Only do this for v8.log profiling, as it breaks v8::CpuProfiler users.
if (v8_is_profiling) {
uv_loop_configure(uv_default_loop(), UV_LOOP_BLOCK_SIGNAL, SIGPROF);
}
#endif

#if defined(NODE_HAVE_I18N_SUPPORT)
if (icu_data_dir == nullptr) {
// if the parameter isn't given, use the env variable.
Expand Down

0 comments on commit 9ba84d8

Please sign in to comment.