Threads in Firefox (from Ubuntu 12.04)

Doing a simple gdb attach on a recent version of Firefox (v23.0) I was very surprised by the complexity of the threading available:

Id Target Id Frame
34 Thread 0x7f0164575700 (LWP 2272) "dconf worker" 0x00007f016fdb6313 in poll () from /lib/x86_64-linux-gnu/
33 Thread 0x7f0161fda700 (LWP 2273) "gdbus" 0x00007f016fdb6313 in poll ()
from /lib/x86_64-linux-gnu/
32 Thread 0x7f016035d700 (LWP 2274) "Gecko_IOThread" 0x00007f016fdbdee9 in syscall () from /lib/x86_64-linux-gnu/
31 Thread 0x7f015f0ff700 (LWP 2275) "Socket Thread" 0x00007f016fdb6313 in poll () from /lib/x86_64-linux-gnu/

Or to summarize is a more easy to read manner:

“dconf worker”
“Socket Thread”
“JS GC Helper”
“JS Sour~ Thread”
“JS Watchdog”
“Hang Monitor”
“Cert Verify”
“mozStorage #1″
“mozStorage #2″
“mozStorage #3″
“Proxy R~olution”
“Cache I/O”
“mozStorage #4″
“DOM Worker”
“HTML5 Parser”
“mozStorage #5″
“URL Classifier”
“localStorage DB”
“mozStorage #6″
“mozStorage #7″
“DOM Worker”
“mozStorage #8″
“mozStorage #9″
“mozStorage #10″
“Analysis Helper”
“Image Scaler”
“mozStorage #11″
“ImageDecoder #5″

Firstly, what are each of these threads doing in Firefox? How does it really help in the browsing process?

WHere is the source codes for these?

What are the corresponding or equivalent functionality/features in Chrome browser?

Anyway to debug the runtime behavior of these threads?

How to trace through the different parts of the threads at runtime?

This is threading in Firefox:

Concept of “web worker” in Firefox (which essentially is THREADS?) and “ChromeWorker”:

Thread manager:

Firefox management of threads:

And for debugging:

To get the source code for Firefox, “apt-get source firefox” is issued.

Switching to the first thread “dconf worker” and looking at the backtrace:

(gdb) thread 23
[Switching to thread 23 (Thread 0xb41b8b40 (LWP 3934))]
#0 0xb77ba424 in __kernel_vsyscall ()
(gdb) bt
#0 0xb77ba424 in __kernel_vsyscall ()
#1 0xb7583690 in __GI___poll (fds=0xb72159f8, nfds=1, timeout=-1)
at ../sysdeps/unix/sysv/linux/poll.c:87
#2 0xb50bda7b in g_poll () from /lib/i386-linux-gnu/
#3 0xb50b00ae in ?? () from /lib/i386-linux-gnu/
#4 0xb50b056b in g_main_loop_run () from /lib/i386-linux-gnu/
#5 0xb428a134 in ?? ()
from /usr/lib/i386-linux-gnu/gio/modules/
#6 0xb50d36b3 in ?? () from /lib/i386-linux-gnu/
#7 0xb7652d4c in start_thread (arg=0xb41b8b40) at pthread_create.c:308
#8 0xb7591dde in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130

And looking into Gecko_IOThread:

Inside the file “BrowserProcessSubThread.cpp”:

// Friendly names for the well-known threads.
static const char* kBrowserThreadNames[BrowserProcessSubThread::ID_COUNT] = {
"Gecko_IOThread", // IO
// "Chrome_FileThread", // FILE
// "Chrome_DBThread", // DB
// "Chrome_HistoryThread", // HISTORY
#if defined(OS_LINUX)
"Gecko_Background_X11Thread", // BACKGROUND_X11

And hunting for more names inside the source codes:




PR_SetCurrentThreadName("Hang Monitor");


PR_SetCurrentThreadName("Socket Thread");

PR_SetCurrentThreadName("Proxy Resolution");

PR_SetCurrentThreadName("Wifi Monitor");

PR_SetCurrentThreadName("Link Monitor");

PR_SetCurrentThreadName("Event Tracer");

Wow…there appear a lot more threads not running….


One response to this post.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: