node/test
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
..
addons test: modify async native test.js to test for #4820 2013-02-21 13:14:07 -08:00
disabled Merge remote-tracking branch 'ry/v0.8' into master 2013-02-18 10:21:08 -08:00
external/ssl-options tests: add TLS tests matrix 2014-10-23 10:45:12 -07:00
fixtures test: fix test-tls-server-verify 2014-07-23 23:51:14 +04:00
gc test: use the debug build of node-weak when necessary 2012-06-13 17:58:28 -07:00
internet test: move two tests from simple/ to internet/ 2013-07-20 12:36:33 +02:00
message lib: name EventEmitter prototype methods 2014-05-07 12:11:57 -07:00
pummel fs: make unwatchFile() insensitive to path 2014-02-06 13:04:35 +04:00
simple timers: Avoid linear scan in _unrefActive. 2014-12-16 11:44:23 -08:00
timers timers: backport f8193ab 2014-07-31 08:53:24 -07:00
common.js test: check for multi-localhost support 2014-10-13 14:17:39 -07:00