Open Bug 1620368 Opened 4 years ago Updated 2 years ago

Convert mscom::Ensure to use the background thread pool when possible

Categories

(Core :: IPC: MSCOM, task, P3)

task

Tracking

()

REOPENED

People

(Reporter: KrisWright, Unassigned)

References

(Blocks 1 open bug)

Details

The thread COM MTA [1] uses the NS_NewNamedThread method, so it might be possible to move it to the background thread pool.

In an effort to reduce the number of ad-hoc threads in the browser, we want to convert instances of NS_NewNamedThread to use the background thread pool [2] wherever possible. If your thread may block, you can also include the NS_DISPATCH_EVENT_MAY_BLOCK flag.

[1] https://searchfox.org/mozilla-central/rev/c79c0d65a183d9d38676855f455a5c6a7f7dadd3/ipc/mscom/EnsureMTA.cpp#35
[2] https://searchfox.org/mozilla-central/rev/91f6c02fcf4c16f78fdc4417f61f192688294066/xpcom/threads/nsThreadUtils.h#1730-1757

Sorry, as much as I'd like to, this one can't be changed over to use a background thread pool; its presence is required to maintain state specific to Microsoft COM.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → WONTFIX

I wonder if it would make sense to add a comment to our codebase where we explain why a thread is needed, ie:

// Bug 1620368 - This thread is required to maintain state specific to Microsoft COM

We might be able to shut this thread down after COM initialization has completed and then use the pool for remaining work, but I think we'd need some additional enhancements to the background thread pool to make that possible. I'll file a bug.

I filed bug 1626346 for the required prerequisite. Reopening provided that we follow the guidance I outlined in comment 3.

Status: RESOLVED → REOPENED
Depends on: 1626346
Priority: -- → P3
Resolution: WONTFIX → ---
Summary: Convert the thread 'COM MTA' to use the background thread pool → Convert mscom::Ensure to use the background thread pool when possible

(In reply to (No longer employed by Mozilla) Aaron Klotz from comment #4)

I filed bug 1626346 for the required prerequisite. Reopening provided that we follow the guidance I outlined in comment 3.

Bug 1626346 is no longer relevant after bug 1707954, since all background threads are now implicitly part of the MTA. So, we should be able to shut down the mscom persistent MTA thread once ProcessRuntime initialisation is complete and dispatch any subsequent EnsureMTA calls via the background thread pool.

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.