-
Notifications
You must be signed in to change notification settings - Fork 30k
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: minor refinements to TimersList & stricter undefined/null checks #17429
Conversation
Not using |
Yes but in practical terms this has basically no impact. I've tested access performance on an Object with 1e7 keys and 1e2 keys and it's constant. It's also likely that the keys will be pretty predictable since they're based on user code and unlikely to be random numbers, so constantly deleting and adding them is not really helping anyone.
And that is also being removed in #17324. As far as I can see, we're just sabotaging performance by using |
@mscdex Btw if there's a legitimate reason to not do this that I'm missing, I'm definitely all ears and will remove that change. I just haven't found it in my testing... And that also applies to the events PR linked above. Thanks for the feedback! |
Maybe run |
@Trott yeah, it's running right now. Forgot to post a link. https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/69/console |
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.
LGTM if benchmarks and CI are OK.
@apapirovski is memory usage the same without |
@apapirovski My concern was not about performance, but memory usage. IMHO it is not safe to make any assumptions about what gets passed to |
I did not realize that until now, that is a bad idea IMHO. Even third-party |
Addressed. I did actually look at memory as an issue but I think I had my iterations set too low. Once I bumped it up enough, I'm seeing regressions in performance too — not just memory. That said, if our policy is that we don't want to assume end-user input then Same as |
No longer use delete to remove keys on unrefed & refed lists, instead simply set to undefined. Move all the TimersList instantiation code into the constructor. Compare values to undefined & null as appropriate instead of truthy or falsy.
01d3ae1
to
253341a
Compare
@lpinca would you mind reviewing this given your prior comment here? The |
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.
SGTM.
Move all the TimersList instantiation code into the constructor. Compare values to undefined & null as appropriate instead of truthy or falsy. PR-URL: #17429 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
Landed in e55b7d6 |
Move all the TimersList instantiation code into the constructor. Compare values to undefined & null as appropriate instead of truthy or falsy. PR-URL: #17429 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
Move all the TimersList instantiation code into the constructor. Compare values to undefined & null as appropriate instead of truthy or falsy. PR-URL: #17429 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
A few small refinements to
TimersList
&ImmediateList
:createTimersList
helper function and instead do all instantiation directly within the constructorTIMEOUT_MAX
as2 ** 31 - 1
instead of having a comment explaining itNo longer usedelete
on unrefed & refed lists as it's expensive and offers no benefit since we never iterate over the dictionary object in regular usage, except in cases where user-code throws and we can likely accept the minute difference in performance in those casesnull
&undefined
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
timers