Files
node/test/parallel
Julien Gilli e5bb66886b 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: https://github.com/joyent/node/issues/8160

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>

Conflicts:
	lib/timers.js

Fixes: https://github.com/nodejs/node-convergence-archive/issues/23
Ref: https://github.com/nodejs/node/issues/268
PR-URL: https://github.com/nodejs/node/pull/2540
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
2015-09-02 08:14:25 -04:00
..
2015-05-19 21:21:27 +02:00
2015-05-19 21:21:27 +02:00
2015-05-19 21:21:27 +02:00
2015-05-19 21:21:27 +02:00
2015-08-20 20:16:47 +02:00
2015-05-19 21:21:27 +02:00
2015-05-19 21:21:27 +02:00
2015-05-19 21:21:27 +02:00
2015-05-19 21:21:27 +02:00
2015-05-19 21:21:27 +02:00
2015-05-19 21:21:27 +02:00
2015-06-05 22:58:14 -04:00
2015-06-05 22:58:14 -04:00
2015-05-19 21:21:27 +02:00
2015-08-23 17:59:43 -04:00
2015-05-19 21:21:27 +02:00
2015-08-23 17:59:43 -04:00
2015-08-04 11:56:11 -07:00
2015-06-15 16:37:37 +02:00