Skip to content

Commit 96ffcb9

Browse files
bnoordhuispiscisaureus
authored andcommitted
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. PR: #466 Reviewed-by: Bert Belder <[email protected]>
1 parent 3e675e4 commit 96ffcb9

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
@@ -3384,6 +3384,10 @@ inline void PlatformInit() {
33843384
RegisterSignalHandler(SIGINT, SignalExit, true);
33853385
RegisterSignalHandler(SIGTERM, SignalExit, true);
33863386

3387+
// Block SIGPROF signals when sleeping in epoll_wait/kevent/etc. Avoids the
3388+
// performance penalty of frequent EINTR wakeups when the profiler is running.
3389+
uv_loop_configure(uv_default_loop(), UV_LOOP_BLOCK_SIGNAL, SIGPROF);
3390+
33873391
// Raise the open file descriptor limit.
33883392
struct rlimit lim;
33893393
if (getrlimit(RLIMIT_NOFILE, &lim) == 0 && lim.rlim_cur != lim.rlim_max) {

0 commit comments

Comments
 (0)