-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
node: improve performance of nextTick #985
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,5 @@ setTimeout(function() { | |
var ms = (hr[0] * 1e3) + (hr[1] / 1e6); | ||
var delta = ms - TIMEOUT; | ||
console.log('timer fired in', delta); | ||
assert.ok(delta > 0, 'Timer fired early'); | ||
assert.ok(delta > -0.5, 'Timer fired early'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait, does that mean the timer indeed fires early? How can that be? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes. it fires ~0.05ms early on occasion. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no idea and I've never seen that. Nothing comes to mind, no probable culprit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Were there no CI runs against this? Are we sure this won't cause subtle bugs? |
||
}, TIMEOUT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does breaking this out into a separate class really make a difference? I can't think of a good reason why that would be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand it, V8 does a better job creating hidden classes for objects constructed with a function constructor / can pre-allocate the expected number of properties for them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the code that estimates the number of properties a function constructor will introduce.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
V8 has a similar optimization for object literals but maybe it gets thrown off by the computed value. I'll take your and Trevor's word for it that it's faster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bnoordhuis I think it has to do with accessing the global
process
object. Though I'm not sure why it would have affect with only the object literal implementation.