Commit Graph
256 Commits
Author SHA1 Message Date
Justin Link 9fb0d64095 Bug 1826224: Enable high-precision timers on Windows for foreground processes when not on battery power r=smaug
Initially controlled by a pref and only enabled by default in Nightly.

Differential Revision: https://phabricator.services.mozilla.com/D189555
2023-10-31 14:34:39 +00:00
Natalia Csoregi 1be331f04c Backed out changeset 88295a805fb9 (bug 1826224) for causing bustage on TimerThread.cpp. CLOSED TREE 2023-10-31 06:52:41 +02:00
Justin Link b505dbd7f8 Bug 1826224: Enable high-precision timers on Windows for foreground processes when not on battery power r=smaug
Initially controlled by a pref and only enabled by default in Nightly.

Differential Revision: https://phabricator.services.mozilla.com/D189555
2023-10-31 03:24:34 +00:00
Sylvestre Ledru b0fe72dee5 Bug 1856795 - Remove redundant member init r=emilio
Done with:
./mach static-analysis check --checks="-*, readability-redundant-member-init" --fix .

https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-member-init.html

Differential Revision: https://phabricator.services.mozilla.com/D190002
2023-10-15 15:29:02 +00:00
Cristina Horotan 7388749830 Backed out 2 changesets (bug 1856795) for causing build bustage at BasicEvents.h CLOSED TREE
Backed out changeset 1d98b028923a (bug 1856795)
Backed out changeset eae2ac93e17c (bug 1856795)
2023-10-14 21:42:14 +03:00
Sylvestre Ledru 4a97019e39 Bug 1856795 - Remove redundant member init r=emilio
Done with:
./mach static-analysis check --checks="-*, readability-redundant-member-init" --fix .

https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-member-init.html

Differential Revision: https://phabricator.services.mozilla.com/D190002
2023-10-14 17:34:26 +00:00
Olli Pettay 59bac9f5f4 Bug 1856545 - Try to utilize idle time more, r=farre
We can go through quite a few more timers these days, since timers are stored now in an array and iterating through that is fast.
Also, relying on timer value for another thread or low priority timers does prevent idle tasks to run in some cases, and now that more timers
are iterated through, that behavior can be tweaked.

For RefreshDriver this is taking the simple approach and just let idle tasks to run if RefreshDriver isn't ticking. We do start RefreshDriverTimer pretty
much always when something in DOM or layout is changing.

Differential Revision: https://phabricator.services.mozilla.com/D189909
2023-10-06 11:04:04 +00:00
Cristina Horotan 9e5159a3b2 Backed out changeset 5873383c36e2 (bug 1856545) for causing talos max run time exceeded failures. CLOSED TREE 2023-10-06 04:07:39 +03:00
Olli Pettay c46d698d22 Bug 1856545 - Try to utilize idle time more, r=farre
We can go through quite a few more timers these days, since timers are stored now in an array and iterating through that is fast.
Also, relying on timer value for another thread or low priority timers does prevent idle tasks to run in some cases, and now that more timers
are iterated through, that behavior can be tweaked.

For RefreshDriver this is taking the simple approach and just let idle tasks to run if RefreshDriver isn't ticking. We do start RefreshDriverTimer pretty
much always when something in DOM or layout is changing.

Differential Revision: https://phabricator.services.mozilla.com/D189909
2023-10-05 18:10:30 +00:00
Justin Link dbd41cc54d Bug 1831014: Allowed the first timer in a wake-up to fire slightly early as well. r=smaug
- Prior to this change, we allowed any timer *except* the first to fire early. Being woken up
slightly before our first timer is due was resulting in a lot of "wasted" wake-ups (where we wake
up and do nothing other than go back to sleep).
- This change results in waking up TimerThread 10% less frequently in my test case of watching a
YouTube video.
- Made the allowed early firing tolerance be a constant value rather than calculated at run-time.
- Also cleaned up some includes.

Differential Revision: https://phabricator.services.mozilla.com/D184017
2023-08-04 20:00:10 +00:00
Cristian Tuns b4da885613 Backed out changeset 61d2e733a10c (bug 1831014) for causing build bustages TimerThread.h CLOSED TREE 2023-08-03 14:29:40 -04:00
Justin Link a00c413d29 Bug 1831014: Allowed the first timer in a wake-up to fire slightly early as well. r=smaug
- Prior to this change, we allowed any timer *except* the first to fire early. Being woken up
slightly before our first timer is due was resulting in a lot of "wasted" wake-ups (where we wake
up and do nothing other than go back to sleep).
- This change results in waking up TimerThread 10% less frequently in my test case of watching a
YouTube video.
- Made the allowed early firing tolerance be a constant value rather than calculated at run-time.
- Also cleaned up some includes.

Differential Revision: https://phabricator.services.mozilla.com/D184017
2023-08-03 17:44:18 +00:00
Justin Link 074be5cb26 Bug 1829983 - Disabled assert that's invalid on Windows r=dthayer
Differential Revision: https://phabricator.services.mozilla.com/D180882
2023-06-15 14:59:10 +00:00
Justin Link 4508908bdf Bug 1829983 - Added some debug output in case this assert fails again r=dthayer
Differential Revision: https://phabricator.services.mozilla.com/D177800
2023-05-12 23:37:27 +00:00
Justin Link 0ce9126a89 Bug 1828427 - Removed incorrect assertion r=gerard-majax
Differential Revision: https://phabricator.services.mozilla.com/D175663
2023-04-20 21:05:18 +00:00
Florian Quèze dc510c9008 Bug 1828013 - Add a scriptable API to list all current nsITimer instances, r=smaug.
Differential Revision: https://phabricator.services.mozilla.com/D175430
2023-04-20 09:43:41 +00:00
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