-
Notifications
You must be signed in to change notification settings - Fork 30.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
timers: use HandleWrap::Unrefed #6699
timers: use HandleWrap::Unrefed #6699
Conversation
LGTM but the commit log should say |
87b60b5
to
b6e0b10
Compare
I think the CI went down for a security update, new CI: https://ci.nodejs.org/job/node-test-pull-request/2604/ Edit: CI is green. |
also cc @misterdjules |
The changes themselves look like they wouldn't introduce any major regression. What's the motivation for this change? What's the problem about relying on the Also, as you noted:
While I don't know if using ref/unref on timers without using These two different types are:
The two lists of timers lists, However with this change, the lines become even less clear between an internal timer and an unrefed "external" or "user" timer, which is why we run into the problem you mentioned above. It seems to me that we would gain a lot in implementation clarity by refactoring the timers implementation to make the difference between internal timers and external unrefed timers clearer by e.g adding the concept of an "internal" timer to the implementation. I believe it would fix the issue mentioned above. I hope that helps. |
There isn't one, but it's an unideal hack.
I don't disagree but it isn't easy to fix and is out of scope. :( Also consider un/refing one of the internal lists will effect many times, not just one.
You can just check the handle like this PR, what use is it to us?
How so?
I'm not sure about that. I've considered exposing It would be possible to check if it is in the same tick, probably, but you've still got a problem then because the backing handle may or may not be shared and it's somewhat hard to tell without mucking with internals. That wouldn't a problem if no-one touched unrefed timer handles in the ecosystem but I doubt that is the case, and still doesn't resolve unrefing at a later time. (Yay undeterministic APIs 😞) Scoped, does this change seem fine to you? I should probably open the issue for the other thing but I'm not sure of a reasonable way to go about it, it's not exactly simple. :( |
My point was that with this change, by just checking the
It seems like it might break at least one edge case, and it doesn't seem to be solving any problem. What's the motivation for this change? |
Cleanup. Keep in mind there wasn't a good way to tell what the previous shared internal handle was either from just looking at the handle, so I'm not sure how real that concern is? |
The code after the change doesn't look cleaner to me, because it seems we lose a very important piece of data which is a marker that identifies that the We're lucky currently to have external unrefed timers to be moved out of their
Absolutely, I didn't mean to say the contrary. I updated my previous comment to hopefully clear the confusion. My concern is different, hopefully I managed to present it in a way that is clearer this time. |
Consider that you also haven't been able to know if a Referenced TimerWrap was an internal
You don't unref the handle itself from |
I don't think using limitations of other aspects of the implementation as a reference for what we want to achieve is going to help us improve that implementation. It seems to me that it's another argument in favor of trying to not conflate
I don't understand what you mean. Do you mean that the handle itself is not "unrefered" when
I agree, and I have not suggested otherwise. What I've been trying to convey in my comments is that removing the I would instead like to explore other approaches such as:
There are probably other approaches to this problem, but the key to me would be to have the internal nature of timers and their "internal handle's refedness" being two orthogonal concepts. |
Ah, yes. I would tend to agree. I'll take a look at those options when I get the chance. I original considered having a ref back to the lists list on the |
The logic behind this revolves around the following: 1. A timer will never fire before nextTick. - Thus it is ok to schedule it during nextTick. 2. Timer properties are unimportant until scheduled. See discussion in nodejs#6699 for more background.
c133999
to
83c7a88
Compare
Ping @Fishrock123 ... still want to pursue this? |
@jasnell No; but this is a reminder for me to look into doing what @misterdjules described |
Closing due to long inactivity. |
Checklist
Affected core subsystem(s)
timers
Description of change
So, there a couple things going on here:
CI: https://ci.nodejs.org/job/node-test-pull-request/2594/