Граф коммитов

235 Коммитов

Автор SHA1 Сообщение Дата
Randell Jesup e47f68f60e Bug 1862556: Allow LongTask markers to be generated for any nsThread r=nika
Differential Revision: https://phabricator.services.mozilla.com/D192532
2023-12-07 04:15:44 +00:00
Cristian Tuns d7a07e4b57 Backed out 2 changesets (bug 1862556, bug 1862557) for causing build bustages in nsThreadManager.cpp CLOSED TREE
Backed out changeset 4ef47a21279a (bug 1862557)
Backed out changeset 2573ea9f377b (bug 1862556)
2023-12-06 17:33:12 -05:00
Randell Jesup c645765422 Bug 1862556: Allow LongTask markers to be generated for any nsThread r=nika
Differential Revision: https://phabricator.services.mozilla.com/D192532
2023-12-06 18:38:49 +00:00
Nika Layzell 7b8afaf1c9 Bug 1851045 - Part 3: Fix potential issue with late shutdown nsThread creation, r=xpcom-reviewers,KrisWright
This fixes the issue described in comment 7 by doing a few changes to how threads are created, and members on nsThreadManager are managed.

 * The thread list is moved to be a member of `nsThreadManager`, which is
   already a statically allocated singleton.

 * The flag for whether new thread creation is allowed is moved from being an
   atomic to being guarded by the same mutex as the thread list, meaning that
   it could be checked and a new thread could be added to the list atomically.

 * Threads which require shutdown are initialized atomically from the point of
   view of the thread manager, meaning that the check in ShutdownNonMainThreads
   is guaranteed to catch all successfully started nsThread instances.

Differential Revision: https://phabricator.services.mozilla.com/D188623
2023-09-27 19:14:16 +00:00
Iulian Moraru ca7afe12bc Backed out 3 changesets (bug 1851045) for causing multiple crashes related to LinkedList.
Backed out changeset c813616ed664 (bug 1851045)
Backed out changeset c53ebef234df (bug 1851045)
Backed out changeset 3350d1b78562 (bug 1851045)
2023-09-21 03:07:37 +03:00
Nika Layzell 8d47a92e50 Bug 1851045 - Part 3: Fix potential issue with late shutdown nsThread creation, r=xpcom-reviewers,KrisWright
This fixes the issue described in comment 7 by doing a few changes to how threads are created, and members on nsThreadManager are managed.

 * The thread list is moved to be a member of `nsThreadManager`, which is
   already a statically allocated singleton.

 * The flag for whether new thread creation is allowed is moved from being an
   atomic to being guarded by the same mutex as the thread list, meaning that
   it could be checked and a new thread could be added to the list atomically.

 * Threads which require shutdown are initialized atomically from the point of
   view of the thread manager, meaning that the check in ShutdownNonMainThreads
   is guaranteed to catch all successfully started nsThread instances.

Differential Revision: https://phabricator.services.mozilla.com/D188623
2023-09-20 21:46:05 +00:00
Florian Quèze 449a69c5a8 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 69cc3ed388 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
Andreas Pehrson a1396c7b11 Bug 1800213 - Add a flag for creating nsThreads with a NONMAINUITHREAD MessageLoop. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D166062
2023-02-28 14:32:42 +00:00
Nika Layzell 829856daa2 Bug 1805963 - Part 2: remove support for local execution, r=xpcom-reviewers,jstutte
The only consumer of this feature has been removed, so we don't need it
anymore. It acts very differently than other runnables run on the main thread,
so removing it will simplify things.

Differential Revision: https://phabricator.services.mozilla.com/D164841
2022-12-21 22:01:25 +00:00
Marian-Vasile Laza 06e6971fa0 Backed out 2 changesets (bug 1805963) for causing mochitest failures on LSObject.cpp. CLOSED TREE
Backed out changeset d70e48585724 (bug 1805963)
Backed out changeset f627a5289831 (bug 1805963)
2022-12-20 23:53:40 +02:00
Nika Layzell ada6120335 Bug 1805963 - Part 2: remove support for local execution, r=xpcom-reviewers,jstutte
The only consumer of this feature has been removed, so we don't need it
anymore. It acts very differently than other runnables run on the main thread,
so removing it will simplify things.

Differential Revision: https://phabricator.services.mozilla.com/D164841
2022-12-20 20:22:03 +00:00
Nika Layzell 9e65358787 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 77f27d96b0 Backed out changeset 42315c023471 (bug 1799222) for causing multiple failures CLOSED TREE 2022-12-06 16:35:58 -05:00
Nika Layzell 40a3a64aee 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é c50cb528fc 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 3ccd75af8d Backed out changeset b9d2965591b9 (bug 1761040) for landing with wrong author CLOSED TREE DONTBUILD 2022-08-03 18:55:00 +03:00
Andreea Pavel fdb7cb2ecd 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 89d63c91e6 Backed out changeset a907159a482f (bug 1761040) for causing build bustages on a CLOSED TREE 2022-08-02 04:59:08 +03:00
Fabrice Desré 0f4ac7ad97 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
Jens Stutte ddb3007e4e Bug 1770451 - Release assert if a thread shutdown is unexpectedly going to cause a hang on the joining thread. r=xpcom-reviewers,nika
There is a code path that can make us not dispatch the `nsThreadShutdownAckEvent` at the end of `nsThread::ThreadFunc`. The only known and legitimate way to arrive here should be via StopWaitingAndLeakThread. We want to ensure that if we take this code path someone else already marked the shutdown context as complete.

Differential Revision: https://phabricator.services.mozilla.com/D148761
2022-06-15 18:15:01 +00:00
Nika Layzell 6c4dce02a1 Bug 1713773 - Part 1: Simplify nsThreadManager shutdown, r=xpcom-reviewers,mccr8
Differential Revision: https://phabricator.services.mozilla.com/D142600
2022-04-12 20:22:24 +00:00
Iulian Moraru 4ab566ae1b Backed out changeset 75811190935c (bug 1713773) for causing leaks on mutex/nsthread. 2022-04-11 19:01:16 +03:00
Nika Layzell 017ada70cf Bug 1713773 - Simplify nsThreadManager shutdown, r=xpcom-reviewers,mccr8
Differential Revision: https://phabricator.services.mozilla.com/D142600
2022-04-11 14:33:45 +00:00
Nika Layzell 5b2ada26c5 Bug 1738103 - Part 4: Add XPCOM support for shutdown tasks, r=necko-reviewers,KrisWright
Tasks registered with shutdown tasks are called when the target
nsISerialEventTarget is about to be destroyed.

Differential Revision: https://phabricator.services.mozilla.com/D129840
2022-03-23 22:22:04 +00:00
Nika Layzell ecac1fbfef Bug 1747526 - Return a handle from asyncShutdown to observe and cancel thread shutdown progress, r=xpcom-reviewers,KrisWright
This change introduces a new interface, nsIThreadShutdown, which is used
to handle the relevant state for communicating thread shutdown state
between the joining and terminating threads. This type is now returned
from `nsIThread::AsyncShutdown` and can be used to register callbacks
for when thread shutdown is complete, as well as cancel shutdown
entirely, leading to the underlying PRThread never being joined using
PR_JoinThread. This leaking limitation may be avoidable if support for
detaching PRThreads is added to NSPR, or nsThread switches to a more
feature-complete threading API.

This patch also uses the new interface to rework nsThreadPool's Shutdown
and ShutdownWithTimeout methods to avoid poking at nsThread internals
and instead use the publicly facing methods. This allows us to start
async shutdown for all threads and spin the event loop until they all
complete, or a timeout timer fires.

Differential Revision: https://phabricator.services.mozilla.com/D136045
2022-02-08 23:58:03 +00:00
Jens Stutte 55a8b2e138 Bug 1735129: Add thread-safe name getter to nsThread. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D128356
2021-10-21 11:51:08 +00:00
Andreas Pehrson 9717c27492 Bug 1695580 - In xpcom, cancel pending DelayedRunnable timers on shutdown. r=KrisWright
Because DelayedRunnables are fire-and-forget, there is no way for a targeted
EventTarget to clean them up on shutdown. Thus if a timer fires after
EventTarget shutdown it will fail to dispatch the timer event, and avoid
releasing the timer callback because it's not on the targeted thread. This
causes a leak as there is a ref-cycle between nsTimerImpl::mCallback and
DelayedRunnable::mTimer.

This patch adds nsIDelayedRunnableObserver for a target to observe which
DelayedRunnables are relying on their timer to run them. This allows the target
to schedule a shutdown task to cancel those timers and release the runnables on
the target thread.

Supported DelayedRunnable targets with this patch are TaskQueues,
eventqueue-based nsThreads and XPCOMThreadWrappers that wrap a supported
nsThread.

An assertion makes sure at runtime that future new uses of DelayedRunnable
target nsIDelayedRunnableObserver-supported event targets.

Differential Revision: https://phabricator.services.mozilla.com/D109781
2021-04-06 20:15:11 +00:00
Brindusan Cristian f78d18d827 Backed out 8 changesets (bug 1695580) for causing build bustages on DataMutex.h. CLOSED TREE
Backed out changeset ec0b0fcc8d88 (bug 1695580)
Backed out changeset 982a46056fcb (bug 1695580)
Backed out changeset e38e8b90f119 (bug 1695580)
Backed out changeset 6fdd154aa151 (bug 1695580)
Backed out changeset d04f7a7ec375 (bug 1695580)
Backed out changeset 2103cd9e58b7 (bug 1695580)
Backed out changeset de9a7dd7fc79 (bug 1695580)
Backed out changeset ae16f09be41b (bug 1695580)
2021-04-06 17:41:19 +03:00
Andreas Pehrson f9c6ad1082 Bug 1695580 - In xpcom, cancel pending DelayedRunnable timers on shutdown. r=KrisWright
Because DelayedRunnables are fire-and-forget, there is no way for a targeted
EventTarget to clean them up on shutdown. Thus if a timer fires after
EventTarget shutdown it will fail to dispatch the timer event, and avoid
releasing the timer callback because it's not on the targeted thread. This
causes a leak as there is a ref-cycle between nsTimerImpl::mCallback and
DelayedRunnable::mTimer.

This patch adds nsIDelayedRunnableObserver for a target to observe which
DelayedRunnables are relying on their timer to run them. This allows the target
to schedule a shutdown task to cancel those timers and release the runnables on
the target thread.

Supported DelayedRunnable targets with this patch are TaskQueues,
eventqueue-based nsThreads and XPCOMThreadWrappers that wrap a supported
nsThread.

An assertion makes sure at runtime that future new uses of DelayedRunnable
target nsIDelayedRunnableObserver-supported event targets.

Differential Revision: https://phabricator.services.mozilla.com/D109781
2021-04-06 12:16:11 +00:00
Chris H-C b98fffa595 Bug 1688937 - Remove now-unused thread counting r=KrisWright
Depends on D103190

Differential Revision: https://phabricator.services.mozilla.com/D103191
2021-02-01 18:25:27 +00:00
Simon Giesecke dd80614fa0 Bug 1678062 - Remove unnecessary includes. r=andi
Differential Revision: https://phabricator.services.mozilla.com/D97467

Depends on D96561
2020-11-23 16:12:02 +00:00
Bas Schouten ba72f1b5e7 Bug 1669256 - Part 4: Remove broken code to control input event prioritization and fix it. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D92712
2020-10-09 16:57:47 +00:00
Bas Schouten 25a1b0f61f Bug 1669256 - Part 1: Remove AbstractEventQueue and de-templatize ThreadEventQueue. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D92709
2020-10-09 17:56:34 +00:00
Bas Schouten 45e747487b Bug 1669214 - Part 1: Remove environment variable to disable TaskController. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D92450
2020-10-06 13:19:51 +00:00
Bas Schouten 6323c24374 Bug 1606706 - Part 3: Enable new TaskController code by default. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D74673
2020-07-01 01:36:08 +00:00
Brindusan Cristian d41e442d47 Backed out 2 changesets (bug 1606706) for wpt leaks. CLOSED TREE
Backed out changeset 42b8f6456d16 (bug 1606706)
Backed out changeset 3fe0b4051541 (bug 1606706)
2020-06-25 14:53:30 +03:00
Bas Schouten f9399d1df7 Bug 1606706 - Part 3: Enable new TaskController code by default. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D74673
2020-06-25 08:04:01 +00:00
Jean-Yves Avenard 1e2af615c7 Bug 1644009 - P9. Add nsIDirectTaskDispatcher interface. r=froydnj
We extract the dealing of direct tasks from the TailDispatcher object and move into to the existing nsThread and TaskQueue classes.
TaskQueue is made to work with do_QueryInterface.

We continue accessing the direct tasks dispatcher via the TailDispatcher for now, which itself will forward the dealing of such tasks to the underlying thread.

Differential Revision: https://phabricator.services.mozilla.com/D79093
2020-06-12 05:10:25 +00:00
Bas Schouten 45104a7a29 Bug 1644292: Duplicate code for runnable telemetry for runnables executed inside TaskController. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D78888
2020-06-09 13:02:37 +00:00
Bas Schouten 8032d4373e Bug 1606706 - Part 2: Integrate new TaskController code into tree and allow usage by pref. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D74672
2020-06-04 00:02:18 +00:00
Bas Schouten c01e9666a7 Bug 1606706 - Part 1: Add new TaskController code to the tree. r=smaug,froydnj
Differential Revision: https://phabricator.services.mozilla.com/D74671
2020-06-03 23:39:58 +00:00
Bogdan Tara 2719f07eb0 Backed out 2 changesets (bug 1606706) for talos tests timeouts CLOSED TREE
Backed out changeset ab3e1a067a71 (bug 1606706)
Backed out changeset c47cf57dab71 (bug 1606706)
2020-06-03 11:51:04 +03:00
Bas Schouten 3a3972c388 Bug 1606706 - Part 2: Integrate new TaskController code into tree and allow usage by pref. r=smaug,?
Differential Revision: https://phabricator.services.mozilla.com/D74672
2020-06-02 11:36:38 +00:00
Bas Schouten e79c5d94a5 Bug 1606706 - Part 1: Add new TaskController code to the tree. r=smaug,froydnj
Differential Revision: https://phabricator.services.mozilla.com/D74671
2020-06-02 21:28:24 +00:00
Jean-Yves Avenard 0afd0b06c9 Bug 1634253 - P2. Dissociate running a BackgroundHangMonitor from main thread. r=froydnj
This will allow to have other threads to use one such as the compositor thread.

Differential Revision: https://phabricator.services.mozilla.com/D73820
2020-05-08 20:20:32 +00:00
Jean-Yves Avenard dd75a6a8ab Bug 1634253 - P1. Fix constness. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D73819
2020-05-08 20:20:35 +00:00
Narcis Beleuzu 58a833221c Backed out 9 changesets (bug 1634253) for bc failures on browser_bug295977_autoscroll_overflow.js . CLOSED TREE
Backed out changeset d41b75c1f7ec (bug 1634253)
Backed out changeset 5f8a1ee17b81 (bug 1634253)
Backed out changeset 43eda078b405 (bug 1634253)
Backed out changeset e98212a74709 (bug 1634253)
Backed out changeset 855e222ceb14 (bug 1634253)
Backed out changeset 9f01acdf4367 (bug 1634253)
Backed out changeset ea62cb1ec472 (bug 1634253)
Backed out changeset fa3e7588e7d6 (bug 1634253)
Backed out changeset 139e7035e736 (bug 1634253)
2020-05-08 23:09:31 +03:00
Jean-Yves Avenard 3e533d2327 Bug 1634253 - P2. Dissociate running a BackgroundHangMonitor from main thread. r=froydnj
This will allow to have other threads to use one such as the compositor thread.

Differential Revision: https://phabricator.services.mozilla.com/D73820
2020-05-07 08:04:39 +00:00
Jean-Yves Avenard 2494dc377e Bug 1634253 - P1. Fix constness. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D73819
2020-05-07 08:04:41 +00:00