Investigate better options for WorkerDebuggeeRunnables, in particular MessageEventRunnable
Categories
(Core :: DOM: Workers, task)
Tracking
()
Tracking | Status | |
---|---|---|
firefox127 | --- | fixed |
People
(Reporter: jstutte, Assigned: edenchuang)
References
(Blocks 1 open bug)
Details
Attachments
(3 files, 1 obsolete file)
Currently we have two conflicting goals for WorkerDebuggeRunnable
s sent to the parent:
- We need to be able to throttle them, in particular if the debugger is running
- Events posted to the parent should be delivered even if the worker is dying
WorkerRunnable
seems to be designed to always have a living WorkerPrivate
even during Run
on a non-worker thread. This design forced us to keep the worker alive in WorkerDebuggeeRunnable
through a StrongWorkerRef
until the event is actually run.
In case of a postMessage
to the parent this should not be necessary, as the worker could well close immediately after having dispatched the message to the parent but before the parent actually run it. All the information needed to accept the message should be frozen at the moment of dispatch.
This opens the question if we could have a WorkerParentRunnable
base class that accounts for the differences between runnables meant to run on the worker and not, ensuring that we expect its WorkerPrivate
to be alive only during Dispatch
but not during Run
, freezing all needed information during the dispatch.
Reporter | ||
Comment 1•3 years ago
|
||
Some of the WorkerDebuggeeRunnables
are dispatched to a throttled event queue on the main thread. They used to carry with them a StrongWorkerRef
, which prevented the worker to be ever shut down while we wait for their processing, which might never happen.
We add now a ThreadSafeWeakWorkerRef
and use it here to determine, if the runnable is still meaningful on execution by canceling it in case the worker died.
We believe that cancelling is sufficient to avoid its mWorkerPrivate to be touched after it has been freed.
Updated•3 years ago
|
Reporter | ||
Comment 2•3 years ago
|
||
The patch here is just a proof of concept that canceling the runnable alone will lead to problems. And we might want to extract the ThreadSafeWeakWorkerRef
changes into a separate patch.
Reporter | ||
Updated•3 years ago
|
Updated•3 years ago
|
Updated•3 years ago
|
Updated•3 years ago
|
Reporter | ||
Comment 3•3 years ago
|
||
This will probably be part of a WorkerRunnable/WorkerDebuggeeRunnable refactoring we plan to do. :asuth, can you please tie the relevant bugs together?
Reporter | ||
Updated•2 years ago
|
Updated•2 years ago
|
Comment 4•2 years ago
|
||
When bug 1836700 (spun off from bug 1800659) removes the busy count, I think we can potentially get rid of the need for a special base class for the runnables.
That said, MessageEventRunnable by spec emits events on the Worker
binding which means that it needs a tear-off threadsafe object that holds a reference to the non-threadsafe Worker binding so it can acquire a reference to the holder on the worker thread. dom/fs/TargetPtrHolder.h has an implementation of this right now but we probably need to put the work in to properly create a document version in XPCOM as proposed in bug 1805830. Right now the WorkerPrivate is serving that role (in addition to the busy count stuff).
Assignee | ||
Comment 5•1 year ago
|
||
Most of WorkerRunnables that are dispatched to the parent thread keep a raw pointer of WorkerPrivate just for the thread correctness checking. Therefore, for this kind of WorkerRunnable, keeping a WorkerPrivate raw pointer is not necessary if we can find an alternative way for thread correctness checking.
So we can say, these WorkerRunnables could be extracted from WorkerRunnable to a new base class WorkerParentThreadRunnable.
And just let the subclasses of WorkerParentThreadRunnable determine if it needs a WorkerPrivate raw pointer or not.
BusyCount modification runnable is a kind of WorkerRunnable on the parent thread that needs a WorkerPrivate raw pointer. However, bug 1836700 will remove the busy count mechanism in WorkerPrivate. We can base on the result of bug 1836700 to ease the implementation of this bug.
Assignee | ||
Updated•1 year ago
|
Reporter | ||
Comment 6•1 year ago
|
||
Bug 1872913 contains an interesting case for such a shutdown hang as of comment 0.
It seems we post the CancelingOnParentRunnable
(holding the strong worker ref that blocks our shutdown) to the worker's mMainThreadDebuggeeEventTarget
but an incoming nsGlobalWindowInner::Suspend
pauses that queue before it will ever be executed. I wonder if the CancelingOnParentRunnable
should better be dispatched directly to the main thread queue? Or we need to drain/unpause the throttled queue on Cancel (but I fear that could always race with asynchronous events causing it to pause again) ?
Assignee | ||
Comment 7•10 months ago
|
||
Assignee | ||
Comment 8•10 months ago
|
||
Depends on D205178
Updated•9 months ago
|
Assignee | ||
Comment 9•9 months ago
|
||
Depends on D205679
Updated•9 months ago
|
Updated•9 months ago
|
Updated•9 months ago
|
Comment 10•9 months ago
|
||
Comment 11•9 months ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/379cd5044768
https://hg.mozilla.org/mozilla-central/rev/ffc69aa8f2c3
https://hg.mozilla.org/mozilla-central/rev/7802e5f1bd13
Comment 12•9 months ago
|
||
Perfherder has detected a devtools performance change
Improvements:
Ratio | Test | Platform | Options | Absolute values (old vs new) |
---|---|---|---|---|
25% | damp source-map-loader.getOriginalLocation.DAMP | macosx1015-64-shippable-qr | e10s fission stylo webrender-sw | 144.19 -> 107.91 |
24% | damp source-map-loader.getOriginalLocation.DAMP | macosx1015-64-shippable-qr | e10s fission stylo webrender | 147.16 -> 111.54 |
21% | damp source-map-loader.getOriginalLocation.DAMP | windows10-64-shippable-qr | e10s fission stylo webrender-sw | 191.73 -> 151.49 |
21% | damp source-map-loader.getOriginalLocation.DAMP | windows10-64-shippable-qr | e10s fission stylo webrender | 190.98 -> 151.81 |
Details of the alert can be found in the alert summary, including links to graphs and comparisons for each of the affected tests.
If you need the profiling jobs you can trigger them yourself from treeherder job view or ask a sheriff to do that for you.
You can run these tests on try with ./mach try perf --alert 42345
For more information on performance sheriffing please see our FAQ.
Assignee | ||
Updated•8 months ago
|
Description
•