Closed Bug 1768822 Opened 3 years ago Closed 3 years ago

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)

enhancement

Tracking

()

RESOLVED FIXED
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.

See Also: → 1770658

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.

Assignee: nobody → gsquelart
Status: NEW → ASSIGNED

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

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...

Attachment #9288392 - Attachment is obsolete: true
Attachment #9288391 - Attachment is obsolete: true

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).

Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: