Commit Graph
340 Commits
Author SHA1 Message Date
Justin Link 8ea083a948 Bug 1783405 - Longer duration timers can have longer firing delays r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D174552
2023-04-11 14:44:44 +00:00
Justin Link 3e1226da16 Bug 1783405 - Look at the upcoming timers to see what can be bundled together when determining when to wake-up. r=smaug,bwc
Differential Revision: https://phabricator.services.mozilla.com/D173105
2023-04-11 14:44:43 +00:00
Justin Link f4a231c66b Bug 1783405 - Added statistics for early wake-ups r=smaug,bwc
Differential Revision: https://phabricator.services.mozilla.com/D173104
2023-04-11 14:44:43 +00:00
Justin Link 652b1ee2a7 Bug 1783405 - Don't wake up in AddTimer() if the currently-scheduled wake-up time can work r=smaug,bwc
Differential Revision: https://phabricator.services.mozilla.com/D173103
2023-04-11 14:44:43 +00:00
Justin Link 3333e52c23 Bug 1783405 - Explicitly track intended wake-up time r=smaug,bwc
The timeout of the next timer is a good proxy for when we are planning
to wake up for as long as we are always intending to wake-up for the
next timer but that is going to stop being the case soon.

Differential Revision: https://phabricator.services.mozilla.com/D173102
2023-04-11 14:44:42 +00:00
Justin Link 9c85343ec8 Bug 1783405 - Add detailed statistics pt 1 r=smaug,bwc
Differential Revision: https://phabricator.services.mozilla.com/D173101
2023-04-11 14:44:42 +00:00
Justin Link 8846a28915 Bug 1819190 - Changed some internal uses of pointers to references r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D171153
2023-03-03 09:22:36 +00:00
Iulian Moraru 27b46d0b5b Backed out changeset 9f0d0ce9c0df (bug 1770658) for causing dt failures on browser_aboutdebugging_devtoolstoolbox_reload.js. CLOSED TREE 2023-02-25 14:30:52 +02:00
Justin Link 0c9e85ad55 Bug 1770658 - Fire zero-delay timers right away r=florian
Differential Revision: https://phabricator.services.mozilla.com/D170468
2023-02-24 16:03:58 +00:00
Florian Quèze de376e1e72 Bug 1817034 - improve profiler markers in the timer thread, r=smaug.
Differential Revision: https://phabricator.services.mozilla.com/D169974
2023-02-17 13:11:08 +00:00
Justin Link eec1a83d5e Bug 1814718 - Buffer "timers fired per-wake-up" stats before sending to glean. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D169769
2023-02-15 10:07:44 +00:00
Justin Link b6770c8ba8 Bug 1814718 - Added telemetry for number of timers fired per Timer Thread wake-up. r=smaug,florian
Differential Revision: https://phabricator.services.mozilla.com/D168915
2023-02-15 10:07:44 +00:00
Sandor Molnar df36a8d502 Backed out changeset 56cd09827bab (bug 1814718) for causing mochitest failures in editor/libeditor/tests/test_undo_after_spellchecker_replaces_word.html CLOSED TREE 2023-02-11 05:23:12 +02:00
Justin Link ebcde4d94f Bug 1814718 - Added telemetry for number of timers fired per Timer Thread wake-up. r=smaug,florian
Differential Revision: https://phabricator.services.mozilla.com/D168915
2023-02-10 20:30:04 +00:00
Florian Quèze 4468884513 Bug 1815642 - Capture the stack of adding timers named nonfunction:JS when adding profiler markers, r=canaltinova.
Differential Revision: https://phabricator.services.mozilla.com/D169177
2023-02-08 10:17:32 +00:00
Justin Link 9b72b7fc50 Bug 1812080 - Fixed Timer Thread wake-up logic when adding timers r=smaug,florian
Really we want to wake-up the Timer Thread now if the newly-added timer
wants to fire before the Timer Thread was scheduled to wake up. The
previous logic happened to work correctly under previous insertion
behavior isn't correct now.

Differential Revision: https://phabricator.services.mozilla.com/D168496
2023-02-02 16:06:33 +00:00
Justin Link c935c71c07 Bug 1787974 - Remove leading canceled timers before deciding if we added a new front timer r=smaug
Due to the possible presence of canceled timers at the "front" of the
list, mTimers[0] won't necessarily hold the next timer to be fired
unless we've cleaned up those front timers recently.

Differential Revision: https://phabricator.services.mozilla.com/D166575
2023-01-20 17:11:13 +00:00
Justin Link 65faacebaf Bug 1787974 - Fixed small logic change in FindNextFireTimeForCurrentThread(). r=smaug
I also took a stab at documenting the behavior since I found it a bit
difficult to follow.

Differential Revision: https://phabricator.services.mozilla.com/D165120
2023-01-20 17:11:12 +00:00
Justin Link 9a82dfd19a Bug 1787974 - Fixed problem where AddTimerInternal() could add a new timer in the wrong spot. r=smaug
The previous version used IndexOfFirstElementGt which is implemented
with a binary search. That doesn't work correctly because the mTimers
array that is being searched is maintained in sorted order
*only if the "cancelled" timers are skipped*. This revision replaces the
binary search with a linear search which can handle this without
problem. Given that the number of timers present at any one time is
fairly modest, a linear search is probably a more appropriate choice
anyway.

Also added a new function, VerifyTimerListConsistency, which is called
once per wake-up in the main loop and enabled only in DEBUG builds, that
checks mTimers for ordering and consistency.

Differential Revision: https://phabricator.services.mozilla.com/D164294
2023-01-20 17:11:12 +00:00
Gerald Squelart 2e3fbffdda Bug 1787974 - AddTimerInternal efficiently inserts by shifting entries until next gap r=smaug
This makes the code more complex, but it is needed to keep this most-used
function efficient related to its old implementation using `std::push_heap`.

Differential Revision: https://phabricator.services.mozilla.com/D164292
2023-01-20 17:11:11 +00:00
Gerald Squelart 8c00fb4d09 Bug 1787974 - Changing mTimers from heap to timestamp-sorted array r=smaug
Inserting elements in the sorted array is more costly than pushing to a binary
heap, but this is balanced by the removal of indirections and de/allocations,
and the upcoming re-use of empty entries.

In the end, this change is necessary to allow future improvements like timer-
coalescing, where we'll need to see multiple timers in order.

Bonus: FindNextFireTimeForCurrentThread changes a lot, because it used to have
to `pop_heap` elements and then `push_heap` them back! (Sometimes resulting in
subtle changes for timers with the same timeout.) So this one benefits the
most.

Differential Revision: https://phabricator.services.mozilla.com/D164291
2023-01-20 17:11:11 +00:00
Gerald Squelart 94eed5ea1a Bug 1787974 - In TimerThread::Shutdown, only Take non-null entries r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D164290
2023-01-20 17:11:11 +00:00
Gerald Squelart af0ac64ae3 Bug 1787974 - Entry::Forget doesn't need a parameter r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D164289
2023-01-20 17:11:10 +00:00
Gerald Squelart 62b5f945dd Bug 1787974 - Entry constructor only takes an nsTimerImpl* r=smaug
So entries now store the given timeout value (instead of clamping it to after "now").
And we store this timeout first, as it's accessed more frequently.

Differential Revision: https://phabricator.services.mozilla.com/D164288
2023-01-20 17:11:09 +00:00
Gerald Squelart 9e24f70602 Bug 1787974 - TimerThread stores Entry's instead of UniquePtrs to Entry's r=smaug
This removes memory heap allocations and deallocations, and indirections to access entries.

Differential Revision: https://phabricator.services.mozilla.com/D164287
2023-01-20 17:11:09 +00:00
Gerald Squelart 132204b11f Bug 1787974 - nsTimerImpl directly keeps track of whether it's in a TimerThread::Entry r=smaug
nsTimerImplHolder can now be removed.

Differential Revision: https://phabricator.services.mozilla.com/D164286
2023-01-20 17:11:08 +00:00
Gerald Squelart 397d620e2d Bug 1787974 - Do a linear search in RemoveTimerInternal to stop going through the holder r=smaug
Note that it's about 4 times slower in practice! But this will be balanced in later patches.

Differential Revision: https://phabricator.services.mozilla.com/D164285
2023-01-20 17:11:08 +00:00
Otto Länd c1900835a6 Bug 1799222, 1799222: apply code formatting via Lando
# ignore-this-changeset
2022-12-16 19:09:03 +00:00
Nika Layzell 119713a821 Bug 1799222 - Part 1: Prevent accidental dispatches to threadpool and timer threads, r=xpcom-reviewers,necko-reviewers,geckoview-reviewers,media-playback-reviewers,jesup,m_kato,padenot,kmag
Differential Revision: https://phabricator.services.mozilla.com/D161349
2022-12-16 17:09:16 +00:00
Cristian Tuns de12c42c7f Backed out changeset 42315c023471 (bug 1799222) for causing multiple failures CLOSED TREE 2022-12-06 16:35:58 -05:00
Nika Layzell e8f474cee1 Bug 1799222 - Prevent accidental dispatches to threadpool and timer threads, r=xpcom-reviewers,necko-reviewers,geckoview-reviewers,media-playback-reviewers,jesup,m_kato,padenot,kmag
Differential Revision: https://phabricator.services.mozilla.com/D161349
2022-12-06 20:44:15 +00:00
Fabrice Desré e29be44cb7 Bug 1761040 - Prefix thread safety macros with MOZ_ r=geckoview-reviewers,media-playback-reviewers,alwu,jesup,m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152575
2022-08-03 16:39:41 +00:00
Andreea Pavel fc724b92fc Backed out changeset b9d2965591b9 (bug 1761040) for landing with wrong author CLOSED TREE DONTBUILD 2022-08-03 18:55:00 +03:00
Andreea Pavel eda47f3911 Bug 1761040 - Prefix thread safety macros with MOZ_ r=geckoview-reviewers,media-playback-reviewers,alwu,jesup,m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152575
2022-08-03 15:27:43 +00:00
Andreea Pavel c2e97d2e06 Backed out changeset a907159a482f (bug 1761040) for causing build bustages on a CLOSED TREE 2022-08-02 04:59:08 +03:00
Fabrice Desré d2d02e8493 Bug 1761040 - Prefix thread safety macros with MOZ_ r=geckoview-reviewers,media-playback-reviewers,alwu,jesup,m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152575
2022-08-02 00:49:41 +00:00
Gerald Squelart 91e7cef5bf Bug 1767396 - Don't wake up the timer thread when removing timers - r=florian,smaug
Differential Revision: https://phabricator.services.mozilla.com/D146031
2022-06-20 11:33:09 +00:00
Gerald Squelart 95dacf976a Bug 1767396 - AddTimer also awakens the timer thread if the new timer has a zero delay - r=smaug
This ensures that 0-delay timers are executed very quickly; without this, they
would rely on the timer thread waking up "naturally" as scheduled, but on some
platforms there could be significant delays (many milliseconds) before the
thread would actually wake up, compared to notifications that are handled
almost immediately.

Even though by specs, timers may be subject to being late, some users of
0-delay timers, in particular through JS' `setTimeout(code, 0)`, rely on the
code being executed as soon as possible (i.e., queued pretty much immediately
on the event loop).
Until now, this was almost guaranteed by the very frequent calls to
RemoveTimer, which always notified the timer thread and made it wake up very
quickly.
However the following patch is going to remove notifications from RemoveTimer,
so before that one lands we now need to ensure that 0-delay timer will still
be invoked at least as quickly as before.

Depends on D146030

Differential Revision: https://phabricator.services.mozilla.com/D149706
2022-06-20 11:33:09 +00:00
Gerald Squelart 6229a37bc7 Bug 1767396 - AUTO_TIMERS_STATS - r=florian
This will help during development, to measure before/after times in TimerThread functions.

Differential Revision: https://phabricator.services.mozilla.com/D146030
2022-06-20 11:33:08 +00:00
Narcis Beleuzu 0f0ea03aa3 Backed out 2 changesets (bug 1767396) for wpt failures on iframe-focus-event-after-iframe-gets-focus.html CLOSED TREE
Backed out changeset 39b9ecc2224a (bug 1767396)
Backed out changeset 77aa60771db2 (bug 1767396)
2022-05-20 02:54:56 +03:00
Gerald Squelart dfd3e8a775 Bug 1767396 - Don't wake up the timer thread when removing timers - r=florian,smaug
Differential Revision: https://phabricator.services.mozilla.com/D146031
2022-05-19 20:31:25 +00:00
Gerald Squelart 88643a5ee7 Bug 1767396 - AUTO_TIMERS_STATS - r=florian
This will help during development, to measure before/after times in TimerThread functions.

Differential Revision: https://phabricator.services.mozilla.com/D146030
2022-05-19 20:31:24 +00:00
Gerald Squelart cc9f3020d5 Bug 1766357 - Remove unused and empty TimerThread::InitLocks - r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D144660
2022-04-27 01:14:37 +00:00
Razvan Cojocaru d1849133f4 Bug 1757668 - Use TimeDuration::ToMicroseconds() in TimerThread::Run(). r=sefeng,nika
Modify the code so that instead of getting microseconds by first
getting milliseconds, then multiplying by 1000, it retrieves the
microseconds value directly.

Differential Revision: https://phabricator.services.mozilla.com/D143472
2022-04-12 19:39:48 +00:00
Randell Jesup 687bab8ee0 Bug 1207753 - xpcom Timer thread-safety annotations r=nika
Differential Revision: https://phabricator.services.mozilla.com/D130572
2022-03-19 03:43:57 +00:00
Randell Jesup 855202c183 Bug 1207753 - Add MOZ_UNANNOTATED to all Mutexes/Monitors r=nika,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D140849
2022-03-16 18:47:08 +00:00
Noemi Erli 16f5f5f2b9 Backed out changeset 12a59e5a50bf (bug 1207753) for causing build bustage CLOSED TREE 2022-03-16 18:32:51 +02:00
Randell Jesup a98b1f8218 Bug 1207753 - Add MOZ_UNANNOTATED to all Mutexes/Monitors r=nika,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D140849
2022-03-16 16:16:14 +00:00
Butkovits Atila 01197944a0 Backed out changeset a68ee4b09f92 (bug 1207753) for causing Hazard bustages. CLOSED TREE 2022-03-16 14:38:14 +02:00
Randell Jesup fe15f2115d Bug 1207753 - Add MOZ_UNANNOTATED to all Mutexes/Monitors r=nika,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D140849
2022-03-16 12:01:14 +00:00