Skip to content

Commit 310ce15

Browse files
committed
src: reduce cpu profiler overhead
Reduce the overhead of the CPU profiler by suppressing SIGPROF signals when sleeping / polling for events. Avoids unnecessary wakeups when the CPU profiler is active. The benefits are quite substantial on systems where it is expensive to query the system time (most virtualized environments). Before, it was common to see over 20% of wall clock time being spent on clock_gettime() system calls.
1 parent cbc1262 commit 310ce15

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/node.cc

+4
Original file line numberDiff line numberDiff line change
@@ -3331,6 +3331,10 @@ inline void PlatformInit() {
33313331
RegisterSignalHandler(SIGINT, SignalExit, true);
33323332
RegisterSignalHandler(SIGTERM, SignalExit, true);
33333333

3334+
// Block SIGPROF signals when sleeping in epoll_wait/kevent/etc. Avoids the
3335+
// performance penalty of frequent EINTR wakeups when the profiler is running.
3336+
uv_loop_configure(uv_default_loop(), UV_LOOP_BLOCK_SIGNAL, SIGPROF);
3337+
33343338
// Raise the open file descriptor limit.
33353339
struct rlimit lim;
33363340
if (getrlimit(RLIMIT_NOFILE, &lim) == 0 && lim.rlim_cur != lim.rlim_max) {

0 commit comments

Comments
 (0)