Skip to content

Optimize timer._unrefActive #268

Closed
Closed
@piscisaureus

Description

@piscisaureus

@misterdjules pointed out that node had become significantly faster after optimizing timer._unrefActive(). To get the idea: https://github.com/joyent/node/commits/v0.10/lib/timers.js.

It turns out that timer._unrefActive() was added somewhere in 2013 to fix an issue related to unref()ing http requests; when an http request object is unref'ed, it's associated timeout timer also needs to be unref'ed or it'll keep the loop open. But it's really a performance bottleneck; _unrefActive() performs what is basically a linear scan of a linked list.

What seems more reasonable is to make timers that are stored in the linked list (through Timer.active()) always be unref'ed, and just use a separate TimerWrap object for all user timers that are scheduled through setTimeout/setInterval.

Metadata

Metadata

Assignees

Labels

timersIssues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions