Don't wake up the Timer thread when adding a timer after the next planned wake-up of the Timer thread
Categories
(Core :: XPCOM, enhancement)
Tracking
()
Tracking | Status | |
---|---|---|
firefox114 | --- | ? |
People
(Reporter: florian, Assigned: mozbugz)
References
Details
Attachments
(2 obsolete files)
Example profile of removing and re-adding timers frequently: https://share.firefox.dev/3FC8BCg (this is the code using timers to show a tooltip 500ms after the mouse stopped moving; the time is removed and re-added at every frame, so about every 16ms).
Bug 1767396 will remove the Timer thread wakeup when removing the timer, but we will still wake-up the Timer thread when re-adding the timer with a new duration. This can probably be avoided too, if we can detect that the Timer thread will already wake-up before the time when the new timer will need to be fired.
Assignee | ||
Comment 1•3 years ago
|
||
Instead of just a flag saying whether the thread is waiting for a timer or not,
we now store the time at which the next timer will fire, or a null timestamp if
there are no pending timers.
Updated•3 years ago
|
Assignee | ||
Comment 2•3 years ago
|
||
Since we now know when the next scheduled wake-up will happen, if a new timer
would fire after that, we don't need to immediately notify the timer thread
anymore.
Depends on D153674
Assignee | ||
Comment 3•3 years ago
|
||
As explained in https://phabricator.services.mozilla.com/D153675#5044255 , I don't think this would actually help at all, compared to the existing code that only notifies the timer thread if the new timer is at the front of the list.
So I'm putting this on pause, it could still be useful in the future, when the coalescing timers work will change how the list is managed...
Updated•3 years ago
|
Updated•3 years ago
|
Assignee | ||
Comment 4•3 years ago
|
||
This (not waking up the timer thread when adding a timer after the next planned wake-up) is already happening with the current code, so there's no need to complicate things at this time.
We may need to do something like this again when bug 1783405 happens, or at least make sure that we keep this behavior there (I'll add a note to that bug).
Updated•2 years ago
|
Description
•