-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Conversation
What do browsers do when the callback overruns its time slot, i.e. what happens when the interval is 10 ms but the callback takes 12 ms to complete? Is every other interval dropped? Have you measured the impact of backing all interval timers with a libuv handle? A handle is a weak persistent reference that requires special post-processing by the garbage collector. You might see a noticeable uptick in time spent inside the GC with this change. |
See the second ph in #8066.
Increasing GC work definitely will be. However, I can not imagine a usercase where often creation and deletion of intervals is reasonably. If we start from the "effective everywhere" then let's use "idle Moreover, little interest to the issue (for a long time) indicates that intervals are used in rarely. |
Right version of "setInterval" based on "idle pattern" conflicts w/ tests of async_listener. (No matter after #8110). |
Hm... this is very likely to seriously impact timer performance... |
@loyd, no I'm talking about calling out C++ methods from timers |
@indutny Then, instead of diff --git a/lib/timers.js b/lib/timers.js
index cf9f8b0..066246a 100644
--- a/lib/timers.js
+++ b/lib/timers.js
@@ -98,8 +98,10 @@ function listOnTimeout() {
debug('timeout callback %d', msecs);
var now, diff, first, hasQueue, threw;
+ var st = Date.now() - Timer.now();
+
while (first = L.peek(list)) {
- now = Timer.now();
+ now = Date.now() - st;
debug('now: %d', now);
diff = now - first._idleStart; But test-timers-ordering accidentally falls (sometimes the diff is less than 1ms). |
Ok, it happens because |
@indutny Calling |
@trevnorris ... any further thoughts on this? Any reason to keep this open? |
Given the nature of this change, a new PR would need to be opened against master on http://github.com/nodejs/node if this is something that should be pursued. Closing this here. |
Fixed:
this
within unref'd timer point to_handle
, not timer.listOnTimeout
updatesnow
for every element of the list. It gives independence from the time of callbacks. See Wrong behavior of nested setTimeout #8133 and setTimeout drifts after busy wait #8105.