From 96ffcb9a210a2fa1248ae5931290193573512a96 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 29 Jan 2015 18:48:30 +0100 Subject: [PATCH] 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: https://github.com/iojs/io.js/pull/466 Reviewed-by: Bert Belder --- src/node.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/node.cc b/src/node.cc index 7c9032b..4386d37 100644 --- a/src/node.cc +++ b/src/node.cc @@ -3384,6 +3384,10 @@ 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) { -- 2.7.4