Commit Graph
82 Commits
Author SHA1 Message Date
Jon Coppeard 987403de0c Bug 1904782 - Part 2: Make TaskController select threads for tasks deterministically r=xpcom-reviewers,nika
This replaces TaskController::mThreadPoolCV with an individual condition
variable for each thread, and uses these to wake individual threads. The task
for each thread is assigned beforehand by setting mCurrentTask.

The counter mIdleThreadCount is used to quickly tell if there are any threads
free.

This splits TaskController::RunPoolThread to move the task selection part to
SelectTaskToRun. MaybeDispatchOneTask is called whenever there may be a new
task to dispatch (this runs from both the main thread and pool threads).

I tried to keep the same behaviour with mEffectiveTaskPriority but I don't
fully understand what this is being used for.

Differential Revision: https://phabricator.services.mozilla.com/D214958
2024-07-11 08:56:13 +00:00
Jon Coppeard dd6eedfbda Bug 1904782 - Part 1: Pass current thread pointer to TaskController::RunPoolThread and refactor r=xpcom-reviewers,nika
This passes a pointer to the current pool thread to RunPoolThread, removing the
need for thread local storage. It also does some refactoring, moving the
PoolThread definition out of the header file.

This also changes the thread vector to use UniquePtr is necessary for the next
patch which adds a CondVar to PoolThread.

Differential Revision: https://phabricator.services.mozilla.com/D214957
2024-07-11 08:56:13 +00:00
Denis Palmeiro 5c062218b6 Bug 1887068: Add perfetto event traces for taskcontroller tasks and dom performance measurement markers. r=smaug
Depends on D205662

Differential Revision: https://phabricator.services.mozilla.com/D205663
2024-04-15 15:34:04 +00:00
Cristina Horotan 886fe5f5a4 Backed out 4 changesets (bug 1887068, bug 1890934) on request by causing build bustages
Backed out changeset 68a7a8a3bb0f (bug 1890934)
Backed out changeset 658f4b57b8ec (bug 1887068)
Backed out changeset 61a9d3a1e592 (bug 1887068)
Backed out changeset efbf5c7065e3 (bug 1887068)
2024-04-12 02:14:44 +03:00
Denis Palmeiro a63122839e Bug 1887068: Add perfetto event traces for taskcontroller tasks and dom performance measurement markers. r=smaug
Depends on D205662

Differential Revision: https://phabricator.services.mozilla.com/D205663
2024-04-10 17:48:08 +00:00
Cristian Tuns d9503794a6 Backed out 3 changesets (bug 1887068) for causing build bustages in toolkit/* CLOSED TREE
Backed out changeset c6863f012b03 (bug 1887068)
Backed out changeset 3a4d2b74219e (bug 1887068)
Backed out changeset 90a702920d77 (bug 1887068)
2024-04-09 18:19:08 -04:00
Denis Palmeiro f61b8829df Bug 1887068: Add perfetto event traces for taskcontroller tasks and dom performance measurement markers. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D205663
2024-04-09 19:05:36 +00:00
Tooru Fujisawa 6381a13f47 Bug 1860969 - Add testcase for incomplete task and rescheduling in TaskController. r=bas
Also fix the null-check.

Differential Revision: https://phabricator.services.mozilla.com/D198504
2024-03-19 03:59:15 +00:00
Olli Pettay e5b50f825f Bug 1874969 - Consider to use GetHeterogeneousCpuInfo when deciding how many background threads TaskController should have, r=mstange
Differential Revision: https://phabricator.services.mozilla.com/D198745
2024-01-17 16:44:08 +00:00
Bas Schouten c185db056d Bug 1869835 - Part 4: Convert TaskMarker to the new MarkerSchema so it gets full ETW support. r=smaug,canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D196375
2023-12-21 18:17:42 +00:00
Olli Pettay 08316ea706 Bug 1869298 - try to insert normal priority main thread tasks to the end, r=bas
Differential Revision: https://phabricator.services.mozilla.com/D196122
2023-12-18 12:26:00 +00:00
Tooru Fujisawa 0b409e3235 Bug 1846407 - Use enum class for Task::Run return value. r=bas,win-reviewers,rkraesig
Differential Revision: https://phabricator.services.mozilla.com/D185043
2023-10-18 15:23:29 +00:00
Noemi Erli fc342c9628 Backed out changeset 7718734e95b1 (bug 1846407) for causing bustages in nsWindow.cpp CLOSED TREE 2023-10-18 05:31:49 +03:00
Tooru Fujisawa bebceb1b21 Bug 1846407 - Use enum class for Task::Run return value. r=bas,win-reviewers,rkraesig
Differential Revision: https://phabricator.services.mozilla.com/D185043
2023-10-18 01:54:43 +00:00
Cristian Tuns 457378e9e0 Backed out changeset a44ec30d604f (bug 1846407) for causing build bustages in ScriptLoader.cpp CLOSED TREE 2023-10-17 18:46:25 -04:00
Tooru Fujisawa 83e7121bc5 Bug 1846407 - Use enum class for Task::Run return value. r=bas,win-reviewers,rkraesig
Differential Revision: https://phabricator.services.mozilla.com/D185043
2023-10-17 22:16:58 +00:00
Emilio Cobos Álvarez 416ace7d70 Bug 1858080 - Restore an include that's needed in some configurations. CLOSED TREE 2023-10-10 20:12:25 +03:00
Emilio Cobos Álvarez 7493849b28 Bug 1858080 - Cleaner TaskController shutdown. r=bas
Using a static std::unique_ptr introduces atexit destructors which can
cause the thread pool to exit in a non-clean state.

Use StaticAutoPtr to avoid this. Clean-up a bit while at it.

We could move the thread-joining into the TaskController destructor too,
that might be worth doing.

Differential Revision: https://phabricator.services.mozilla.com/D190552
2023-10-10 16:22:36 +00:00
Tooru Fujisawa 268184d652 Bug 1839102 - Use enum class for Task kind. r=bas
Differential Revision: https://phabricator.services.mozilla.com/D182980
2023-07-26 05:09:29 +00:00
Sandor Molnar 25031486a3 Backed out changeset b99cc4960043 (bug 1839102) for causing build bustages in idget/windows/nsWindow.cpp CLOSED TREE 2023-07-26 05:53:26 +03:00
Tooru Fujisawa 25becb8a76 Bug 1839102 - Use enum class for Task kind. r=bas
Differential Revision: https://phabricator.services.mozilla.com/D182980
2023-07-26 02:26:15 +00:00
Florian Quèze de6cef3975 Bug 1836191 - remove PerformanceCounter that was only used by ChromeUtils.requestPerformanceMetrics, r=smaug.
Differential Revision: https://phabricator.services.mozilla.com/D179697
2023-06-08 21:53:18 +00:00
Randell Jesup cc7d3c0765 Bug 1825117: Add Telemetry for Runnable execution times if they're long r=nika
Differential Revision: https://phabricator.services.mozilla.com/D173878
2023-04-13 19:22:45 +00:00
Randell Jesup a81eecaf48 Bug 1746479: xpcom TaskController cleanup r=bas
Differential Revision: https://phabricator.services.mozilla.com/D134061
2023-03-31 14:03:19 +00:00
Florian Quèze 9e4a8777b9 Bug 1817498 - Unlock the TaskController mGraphMutex mutex before calling into BackgroundHangThread APIs, r=bas.
Differential Revision: https://phabricator.services.mozilla.com/D171260
2023-03-07 12:37:03 +00:00
Nazım Can Altınova 5b013c2457 Bug 1807015 - Do not call Timestamp::Now when profiler is not running for event delay data r=nika,mstange
Differential Revision: https://phabricator.services.mozilla.com/D166950
2023-02-14 09:46:18 +00:00
Nazım Can Altınova c91a8714b7 Bug 1803751 - Make some marker fields searchable and bump the profile version r=julienw
Differential Revision: https://phabricator.services.mozilla.com/D163714
2022-12-13 14:19:07 +00:00
Iulian Moraru 94985653c4 Backed out changeset 27f8690ebc50 (bug 1803751) for causing xpcshell failures on test_feature_mainthreadio.js. CLOSED TREE 2022-12-12 17:43:23 +02:00
Nazım Can Altınova 76eaba45b7 Bug 1803751 - Make some marker fields searchable and bump the profile version r=julienw
Differential Revision: https://phabricator.services.mozilla.com/D163714
2022-12-12 13:11:56 +00:00
Florian Quèze 701d98ab91 Bug 1770087 - Show the task priority in task controller Runnable markers, r=bas,gerald.
Differential Revision: https://phabricator.services.mozilla.com/D146761
2022-06-15 15:00:40 +00:00
Bas Schouten 10a4d377e0 Bug 1767875: Avoid ever waking up more than one thread at a time. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D145962
2022-05-10 23:52:31 +00:00
Olli Pettay 49d4d2f5d1 Bug 1762090, don't block refreshdrivers for too long time on linux, r=mstange
Explicitly detect the case when main thread has been empty, and if so, don't give other tasks
extra time.

Differential Revision: https://phabricator.services.mozilla.com/D142740
2022-04-06 00:40:25 +00:00
Randell Jesup cd382aae30 Bug 1207753: Basic thread-safety annotations to quiet errors until real annotations land r=nika
Differential Revision: https://phabricator.services.mozilla.com/D141062
2022-03-17 18:39:15 +00:00
Olli Pettay 6053195932 Bug 1755006, reduce framerate if the main thread is busy handling also other tasks, r=mstange
Differential Revision: https://phabricator.services.mozilla.com/D140046
2022-03-14 23:28:33 +00:00
Cristian Tuns c9f9f7de1f Backed out changeset 0211ed711a1c (bug 1755006) for causing mochitest failures on browser_ext_pageAction_context.js,browser_panel_list_accessibility.js CLOSED TREE 2022-03-14 06:53:10 -04:00
Olli Pettay 0adad430a5 Bug 1755006, reduce framerate if the main thread is busy handling also other tasks, r=mstange
Differential Revision: https://phabricator.services.mozilla.com/D140046
2022-03-13 21:26:14 +00:00
Marian-Vasile Laza c71ed5e057 Backed out changeset d3f40b4651f5 (bug 1755006) for causing mochitest failures on test_pointerlock-api.html. CLOSED TREE 2022-03-10 17:54:53 -08:00
Olli Pettay 0005e7e8e8 Bug 1755006, reduce framerate if the main thread is busy handling also other tasks, r=mstange
Differential Revision: https://phabricator.services.mozilla.com/D140046
2022-03-10 23:04:55 +00:00
Jan de Mooij 3f34142ba6 Bug 1747719 - Use a larger stack size for TaskController threads for ASan builds. r=jonco,bas
ASan builds use more stack space so need a larger stack size. Note that this matches
what we already do for the JS overrecursion limit for the main thread.

This fixes overrecursion errors from the parser when parsing JS files off-thread
on YouTube.

Differential Revision: https://phabricator.services.mozilla.com/D135201
2022-01-18 09:38:53 +00:00
Florian Quèze 23e763f19d Bug 1738285 - move AUTO_PROFILE_FOLLOWING_RUNNABLE to its own header, r=gerald.
Differential Revision: https://phabricator.services.mozilla.com/D129825
2021-10-28 20:35:06 +00:00
Bob Owen 0b72cdd84f Bug 1546154 p5: Remove CoInitializeEx call from TaskController. r=bas
Threads are implicitly members of the multi-threaded apartment and calls to
CoInitializeEx (and CoUninitializeEx) cause user32 to load.

Differential Revision: https://phabricator.services.mozilla.com/D124933
2021-09-20 10:09:02 +00:00
Marian-Vasile Laza 9099bcacd0 Backed out 7 changesets (bug 1546154) for causing build bustages on ContentProcess.cpp. CLOSED TREE
Backed out changeset 0bd777eee249 (bug 1546154)
Backed out changeset 611812ee62a2 (bug 1546154)
Backed out changeset cef0aa18a3ab (bug 1546154)
Backed out changeset cfda47fb0a46 (bug 1546154)
Backed out changeset f3e005f5fedc (bug 1546154)
Backed out changeset 7f50fca0c2cd (bug 1546154)
Backed out changeset bbb0b25450f5 (bug 1546154)
2021-09-15 14:12:55 +03:00
Bob Owen f0d0b90897 Bug 1546154 p5: Remove CoInitializeEx call from TaskController. r=bas
Threads are implicitly members of the multi-threaded apartment and calls to
CoInitializeEx (and CoUninitializeEx) cause user32 to load.

Differential Revision: https://phabricator.services.mozilla.com/D124933
2021-09-15 10:21:05 +00:00
Florian Quèze dfecdf3297 Bug 1728866 - Remove the word 'thread' from TaskController thread names, r=bas.
Differential Revision: https://phabricator.services.mozilla.com/D124389
2021-09-09 20:21:45 +00:00
Gerald Squelart d44f7319af Bug 1722261 - Use AUTO_PROFILER_REGISTER_THREAD where possible - r=canaltinova
With the new ThreadRegistration classes, it becomes more important to properly balance registrations with unregistrations. Though mismatches are safely handled when they happen, in particular missing unregistrations can lead to leaks that make tests fail.

This patch changes `PROFILER_REGISTER_THREAD` in TaskController.cpp to `AUTO_PROFILER_REGISTER_THREAD`, to ensure that TaskController threads get unregistered when they're finished.

In AsyncLogger.h, a pair of `PROFILER_REGISTER_THREAD` and `PROFILER_UNREGISTER_THREAD` is converted to a single `AUTO_PROFILER_REGISTER_THREAD`. This is equivalent, but the latter is safer, in case the code in-between later changes to include early breaks or returns.

Differential Revision: https://phabricator.services.mozilla.com/D123228
2021-08-24 04:47:12 +00:00
Jon Coppeard 58e411d98d Bug 1717204 - Increase the number of threads used by the XPCOM thread pool to match the number of cores r=bas
Currently the XPCOM thead pool creates one less thread than the number of
cores. The JS helper thread pool creates an equal number.

I tested increasing the number of threads to match the number of cores and
found it resolved this regression.

Differential Revision: https://phabricator.services.mozilla.com/D118327
2021-06-23 14:09:18 +00:00
Jon Coppeard db60fbe73c Bug 1716940 - Increase TaskController thread stack size r=bas
This increases the stack size used for task controller threads to the size
previously used for JS helper threads. Some parsing use cases can use a lot of
stack.

Differential Revision: https://phabricator.services.mozilla.com/D118184
2021-06-17 16:14:20 +00:00
Jon Coppeard 39f6787517 Bug 1716940 - Pass external thread stack size through to the JS engine r=sfink,bas
This adds plumbing to make the JS engine set the stack quota based on the
actual stack size for external thread pool threads (and internal thread pool
ones).

The quota is calculated as 90% of the size, which is currently hardcoded into
the constants.

Differential Revision: https://phabricator.services.mozilla.com/D118183
2021-06-17 16:14:19 +00:00
Jon Coppeard e72b0f5573 Bug 1713287 - Change the number of threads TaskController creates to match those required by the JS engine r=bas
Currently parallel Wasm compilation requires at least two threads for
architectural reasons. This patch updates the TaskController thread policy such
that there are always two threads available, even on single core systems.

Differential Revision: https://phabricator.services.mozilla.com/D117002
2021-06-09 09:23:20 +00:00
Jon Coppeard 8e511303bb Bug 1704923 - Pass the number of threads when setting up an external thread pool r=sfink,bas
The JS helper thread system needs to know how many threads are available, in
particular because parallel Wasm compilation needs at least two threads to
avoid deadlock. This adds a method to get the count from TaskController and
passes it through to the JS engine when setting up the thread pool.

Differential Revision: https://phabricator.services.mozilla.com/D116220
2021-06-03 10:24:13 +00:00