[webkit-dev] Thread naming policy in WebKit

Yusuke SUZUKI utatane.tea at gmail.com
Wed Jan 4 20:28:03 PST 2017

Hi WebKittens!

Recently, I started naming threads in Linux. And I also started naming
threads created by WTF::AutomaticThread.
Previously, all the thread is not named in Linux. It makes difficult to
find problematic threads when using GDB in Linux.
For example, if you run the JSC shell, all the threads are named as "jsc"
(this is the name of the process).

The problem raised here is that we have no consistent policy for thread
I picked several names in WebKit.

In WebCore,
    IDB server is "IndexedDatabase Server"
    AsyncAudioDecoder is "Audio Decoder"
    GCController is "WebCore: GCController"
    Icon Database is "WebCore: IconDatabase"
    Audio's ReverbConvolver is "convolution background thread"
The thread name used by WorkQueue in WebCore is,
    Crypto Queue is "com.apple.WebKit.CryptoQueue"
    Image decoder is "org.webkit.ImageDecoder"
    Blob utility is "org.webkit.BlobUtility"
    Data URL decoder is "org.webkit.DataURLDecoder"
    Before this patch, all the AutomaticThreads (including JIT worklist /
DFG worklist) is "WTF::AutomaticThread"
    Super Sampler thread is "JSC Super Sampler"
    Asychronous Disasm is "Asynchronous Disassembler"
    Sampling profiler is "jsc.sampling-profiler.thread"
    WASM compiler thread is "jsc.wasm-b3-compilation.thread"
In WebKit2
    Network Cache is "IOChannel::readSync"
    IPC workqueue is "com.apple.IPC.ReceiveQueue"

To choose the appropriate naming policy, there are two requirements.
This is discussed in https://bugs.webkit.org/show_bug.cgi?id=166678 and

1. We should have super descriptive name including the iformation "This
thread is related to WebKit".
If we use WebKit as the framework, WebKit will launch several threads along
with the user application's threads.
So if the thread name does not include the above information, it is quite
confusing: Is this crash related to WebKit OR user's applications?
This should be met at least in macOS port. In the Linux port, this
requirement is a bit difficult to be met due to the second requirement.

2. The thread name should be <= 15 characters in Linux. <= 31 characters in
This is super unfortunate. But we need this requirement. But in macOS, I
think we do not have any limitation like that (correct?)
I cannot find "PTHREAD_MAX_NAMELEN_NP" definition in macOS.

To meet the above requirements as much as possible, I suggest the name, "
This policy is derived from the WorkQueue's naming policy, like
For example, we will name DFG compiler worklist thread as
"org.webkit.jsc.DFGCompiler" or "org.webkit.JavaScriptCore.DFGCompiler".

In Linux / Windows, we have the system to normalize the above name to
For example, when you specify "org.webkit.jsc.DFGCompiler", it will be
shown as "DFGCompiler" in Linux.
This naming policy meets (1) in macOS. And (2) in all the environments. In
macOS, the name is not modified.
So we can see the full name "org.webkit.jsc.DFGCompiler".
In Linux, we can see "DFGCompiler", it is quite useful compared to nameless

What do you think of?

Best regards,
Yusuke Suzuki
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-dev/attachments/20170105/9979ad74/attachment.html>

More information about the webkit-dev mailing list