Files
node/test/simple
Julien Gilli 934bfe23a1 timers: Avoid linear scan in _unrefActive.
Before this change, _unrefActive would keep the unrefList sorted when
adding a new timer.

Because _unrefActive is called extremely frequently, this linear scan
(O(n) at worse) would make _unrefActive show high in the list of
contributors when profiling CPU usage.

This commit changes _unrefActive so that it doesn't try to keep the
unrefList sorted. The insertion thus happens in constant time.

However, when a timer expires, unrefTimeout has to go through the whole
unrefList because it's not ordered anymore.

It is usually not large enough to have a significant impact on
performance because:
- Most of the time, the timers will be removed before unrefTimeout is
  called because their users (sockets mainly) cancel them when an I/O
  operation takes place.
- If they're not, it means that some I/O took a long time to happen, and
  the initiator of subsequents I/O operations that would add more timers
  has to wait for them to complete.

With this change, _unrefActive does not show as a significant
contributor in CPU profiling reports anymore.

Fixes #8160.
PR-URL: #8751

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-12-16 11:44:23 -08:00
..
2012-02-20 13:29:11 +01:00
2010-02-25 11:41:11 -08:00
2012-06-11 15:51:23 -07:00
2012-12-14 10:52:30 -08:00
2012-01-17 19:45:09 +01:00
2011-11-25 01:25:38 +01:00
2012-01-24 00:30:28 +06:00
2012-01-17 19:45:09 +01:00
2012-01-17 19:45:09 +01:00
2011-03-14 17:37:05 -07:00
2011-03-14 17:37:05 -07:00
2012-12-14 17:46:23 -08:00
2011-11-01 22:26:52 +01:00
2011-11-01 22:26:52 +01:00
2012-02-18 15:34:57 -08:00
2011-10-22 14:14:40 +09:00
2011-10-22 14:14:40 +09:00
2011-10-22 14:14:40 +09:00
2012-12-14 17:46:23 -08:00
2012-12-14 17:46:23 -08:00
2012-06-29 17:29:32 +02:00
2012-07-04 13:45:14 +02:00
2012-01-17 19:45:09 +01:00
2011-03-14 17:37:05 -07:00
2012-01-09 11:20:22 -08:00
2013-02-28 23:11:47 +01:00
2012-12-14 10:52:30 -08:00
2011-08-09 13:55:04 -07:00
2014-04-15 15:30:43 -07:00
2011-03-14 17:37:05 -07:00
2012-12-14 10:52:26 -08:00
2011-10-05 18:51:06 -07:00