Closed Bug 1927436 Opened 1 year ago Closed 1 year ago

[Spike] Investigate the current state of the list of Fenix threads and their usages

Categories

(Firefox for Android :: Performance, task)

All
Android
task

Tracking

()

RESOLVED FIXED
136 Branch
Tracking Status
firefox136 --- fixed

People

(Reporter: kaya, Assigned: segun)

References

Details

(Whiteboard: [fxdroid] [group1] )

Attachments

(1 file, 1 obsolete file)

Previously the list of the Fenix threads are noted here: https://github.com/mozilla-mobile/fenix/blob/main/docs/List-of-fenix-threads.md

We need to make sure whether this is still up-to-date, and if not, we should come up with the updated list. After we run this investigation, the outcome of this will help us with the next steps to optimize the thread usage on Fenix.

One thing I see missing explicitly from the list above is Store threads (these may be hidden in the "pools" though). Stores fall into one of two categories.

  1. The original Store implementation which will create a standalone thread for each instance. At any given time, this likely means that there are at least two threads created for global stores: the AppStore thread and the BrowserStore thread. The SyncStore thread is a likely candidate too - it may only be initialized when logged into sync but without checking deeply it is likely initiated in some case where we check login status. On top of this, there may be "Fragment" store threads created for whichever screen(s) is in scope.

  2. The new UiStore implementation allows re-using the main thread across Stores. The original intent here was for Fragment Stores to use this, but migration has been slow.

The main idea behind the UiStore is that the Fragment Stores should be small enough that we don't risk perceived performance impacts by running their logic on the main thread and additionally get the benefit of a massively simplified async model in our implementations (especially in testing).

My theory is that, since Stores should only be responsible for running pure functions over immutable data in their Reducers, that even our large global Stores like AppStore and BrowserStore could also safely be moved to the main thread. With the creation of UiStore we have a way to verify this in performances tests.

This has been on my radar for a long time but I keep failing to find the time to properly test. Thought I'd drop a note here in case these thoughts are useful for any of the follow-on work that results from this investigation.

Assignee: nobody → sfamisa
Whiteboard: [fxdroid] [group1]
Status: NEW → ASSIGNED

Hey folks,

I did a bit of investigation on this, and here's the list of threads we have right now. In addition, I added a draft patch for a "thread debug tool" in the fenix debug overlay. I will create a WIP patch shortly.

After opening a couple of tabs, and navigating around, the thread count seems to be about 79:

AutoSave-thread-1
BrowserIcons-thread-1
BrowserIcons-thread-2
BrowserIcons-thread-3
BrowserStore-thread-1
Cleaner-0
Cleaner-1
Cleaner-2
Cleaner-3
Cleaner-4
Cleaner-5
Cleaner-6
Cleaner-7
ConnectivityThread
DefaultDispatcher-worker-1
DefaultDispatcher-worker-10
DefaultDispatcher-worker-11
DefaultDispatcher-worker-12
DefaultDispatcher-worker-13
DefaultDispatcher-worker-14
DefaultDispatcher-worker-15
DefaultDispatcher-worker-16
DefaultDispatcher-worker-17
DefaultDispatcher-worker-18
DefaultDispatcher-worker-2
DefaultDispatcher-worker-3
DefaultDispatcher-worker-4
DefaultDispatcher-worker-5
DefaultDispatcher-worker-6
DefaultDispatcher-worker-7
DefaultDispatcher-worker-8
DefaultDispatcher-worker-9
FinalizerDaemon
FinalizerWatchdogDaemon
FxaAccountManager-thread-1
Gecko
GleanAPIPool
HeapTaskDaemon
HistoryMetadataService-thread-1
IPC I/O Parent
JNA Cleaner
Jit thread pool worker thread 0
LeakCanary-Background-iCanHasHeap-Updater
LeakCanary-Heap-Dump
NimbusDbScope-thread-1
PlacesStorageWriteScope-thread-1
Profile Saver
ReferenceQueueDaemon
RenderThread
Signal Catcher
StreamTrans #13
StreamTrans #8
StreamTrans #9
SurfaceSyncGroupTimer
ThumbnailStorage-thread-1
WM.task-1
WM.task-2
WM.task-3
WifiManagerThread
androidx.work-1
arch_disk_io_0
arch_disk_io_1
arch_disk_io_2
arch_disk_io_3
binder:27622_1
binder:27622_2
binder:27622_3
binder:27622_4
binder:27622_5
glean.MetricsPingScheduler
hwuiTask0
hwuiTask1
kotlinx.coroutines.DefaultExecutor
launcher
main
pool-18-thread-1
pool-21-thread-1
pool-27-thread-1
queued-work-looper
Attachment #9445036 - Attachment is obsolete: true
Pushed by sfamisa@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ff983063b6aa Update list of fenix threads in docs r=android-reviewers,kaya
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 136 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: