Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timers: eventloop is blocked when there are two or more callback duration is larger than interval #15068

Closed
zhangzifa opened this issue Aug 29, 2017 · 2 comments
Assignees
Labels
timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.

Comments

@zhangzifa
Copy link
Contributor

zhangzifa commented Aug 29, 2017

  • Version: 6.x 7.x 8.x master:
  • Platform: n/a:
  • Module: timers:

When there are at least two timer set by setInterval, whose callback execution time are longer than interval, the eventloop will be blocked, meanwhile the 4.x is not. You may take the following code to have a test.

@Fishrock123 It seems the timers module refactoring brings this.

const http = require('http');

const sleep = function(ms) {
  const st = new Date().getTime();
  while (new Date().getTime() < st + ms);
};

const t1 = setInterval(function(){
  sleep(100);
}, 50)

const t2 = setInterval(function(){
  sleep(60);
}, 50);

http.createServer(function(req, res) {
  res.end('hello ' + new Date());
}).listen(8888);
@vsemozhetbyt vsemozhetbyt added the timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout. label Aug 29, 2017
@Fishrock123 Fishrock123 self-assigned this Aug 29, 2017
@zhangzifa
Copy link
Contributor Author

@Fishrock123 Could you help review timers: fix eventloop block #15072

I know there should be an extra test for this issue. However, I will be ooo in the following 5/6 days. I will add it when I am back.

@bnoordhuis
Copy link
Member

@Fishrock123 Ping, since you self-assigned.

zhangzifa added a commit to zhangzifa/node that referenced this issue Oct 2, 2017
When there are at least 2 timers set by setInterval whose callback
execution are longer than interval, the eventloop will be blocked.

This commit fix the above bug.

Fixes: nodejs#15068
MylesBorins pushed a commit that referenced this issue Oct 23, 2017
When there are at least 2 timers set by setInterval whose callback
execution are longer than interval, the eventloop will be blocked.

This commit fix the above bug.

PR-URL: #15072
Fixes: #15068
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
addaleax pushed a commit to ayojs/ayo that referenced this issue Oct 26, 2017
When there are at least 2 timers set by setInterval whose callback
execution are longer than interval, the eventloop will be blocked.

This commit fix the above bug.

PR-URL: nodejs/node#15072
Fixes: nodejs/node#15068
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this issue Nov 16, 2017
When there are at least 2 timers set by setInterval whose callback
execution are longer than interval, the eventloop will be blocked.

This commit fix the above bug.

PR-URL: #15072
Fixes: #15068
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this issue Nov 21, 2017
When there are at least 2 timers set by setInterval whose callback
execution are longer than interval, the eventloop will be blocked.

This commit fix the above bug.

PR-URL: #15072
Fixes: #15068
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this issue Nov 28, 2017
When there are at least 2 timers set by setInterval whose callback
execution are longer than interval, the eventloop will be blocked.

This commit fix the above bug.

PR-URL: #15072
Fixes: #15068
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
addaleax pushed a commit to ayojs/ayo that referenced this issue Dec 7, 2017
When there are at least 2 timers set by setInterval whose callback
execution are longer than interval, the eventloop will be blocked.

This commit fix the above bug.

PR-URL: nodejs/node#15072
Fixes: nodejs/node#15068
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants