Open Bug 1620381 Opened 5 years ago Updated 2 years ago

Convert the thread 'IPDL Background' to use the background thread pool

Categories

(Core :: IPC, task, P3)

task

Tracking

()

People

(Reporter: KrisWright, Unassigned)

References

(Blocks 1 open bug)

Details

The thread IPDL Background [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/glue/BackgroundImpl.cpp#1325
[2] https://searchfox.org/mozilla-central/rev/91f6c02fcf4c16f78fdc4417f61f192688294066/xpcom/threads/nsThreadUtils.h#1730-1757

This is a difficult problem:

  • The BackgroundParent actors are (as a consequence of being IPDL actors) bound to a thread and moving them would set off thread-safety assertions.
  • More fundamentally, there's a guarantee of sequentiality for all messages on the same top-level actor, and some of the PBackground subprotocols even implicitly depend on mutual exclusion between different PBackground instances (e.g., by accessing global data without locking)

Fortunately, there's only one of these threads in the entire browser instance, so this seems low priority.

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