<div dir="ltr">Hi WebKittens!<div><br></div><div>Recently, I started naming threads in Linux. And I also started naming threads created by WTF::AutomaticThread.</div><div>Previously, all the thread is not named in Linux. It makes difficult to find problematic threads when using GDB in Linux.</div><div>For example, if you run the JSC shell, all the threads are named as &quot;jsc&quot; (this is the name of the process).</div><div><br></div><div>The problem raised here is that we have no consistent policy for thread names.</div><div>I picked several names in WebKit.</div><div><br></div><div>In WebCore,</div><div>    IDB server is &quot;IndexedDatabase Server&quot;</div><div>    AsyncAudioDecoder is &quot;Audio Decoder&quot;</div><div>    GCController is &quot;WebCore: GCController&quot;</div><div>    Icon Database is &quot;WebCore: IconDatabase&quot;</div><div>    Audio&#39;s ReverbConvolver is &quot;convolution background thread&quot;</div><div>The thread name used by WorkQueue in WebCore is,</div><div>    Crypto Queue is &quot;com.apple.WebKit.CryptoQueue&quot;</div><div>    Image decoder is &quot;org.webkit.ImageDecoder&quot;</div><div>    Blob utility is &quot;org.webkit.BlobUtility&quot;</div><div>    Data URL decoder is &quot;org.webkit.DataURLDecoder&quot;</div><div>In JSC</div><div>    Before this patch, all the AutomaticThreads (including JIT worklist / DFG worklist) is &quot;WTF::AutomaticThread&quot;</div><div>    Super Sampler thread is &quot;JSC Super Sampler&quot;</div><div>    Asychronous Disasm is &quot;Asynchronous Disassembler&quot;</div><div>    Sampling profiler is &quot;jsc.sampling-profiler.thread&quot;</div><div>    WASM compiler thread is &quot;jsc.wasm-b3-compilation.thread&quot;</div><div>In WebKit2</div><div>    Network Cache is &quot;IOChannel::readSync&quot;</div><div>    IPC workqueue is &quot;com.apple.IPC.ReceiveQueue&quot;</div><div><br></div><div>To choose the appropriate naming policy, there are two requirements.</div><div>This is discussed in <a href="https://bugs.webkit.org/show_bug.cgi?id=166678">https://bugs.webkit.org/show_bug.cgi?id=166678</a> and <a href="https://bugs.webkit.org/show_bug.cgi?id=166684">https://bugs.webkit.org/show_bug.cgi?id=166684</a></div><div><br></div><div>1. We should have super descriptive name including the iformation &quot;This thread is related to WebKit&quot;.</div><div>If we use WebKit as the framework, WebKit will launch several threads along with the user application&#39;s threads.</div><div>So if the thread name does not include the above information, it is quite confusing: Is this crash related to WebKit OR user&#39;s applications?</div><div>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.</div><div><br></div><div>2. The thread name should be &lt;= 15 characters in Linux. &lt;= 31 characters in Windows.</div><div>This is super unfortunate. But we need this requirement. But in macOS, I think we do not have any limitation like that (correct?)</div><div>I cannot find &quot;PTHREAD_MAX_NAMELEN_NP&quot; definition in macOS.</div><div><br></div><div>To meet the above requirements as much as possible, I suggest the name, &quot;<a href="http://org.webkit.MODULE.NAME">org.webkit.MODULE.NAME</a>(15characters)&quot;.</div><div>This policy is derived from the WorkQueue&#39;s naming policy, like &quot;org.webkit.ImageDecoder&quot;.</div><div>For example, we will name DFG compiler worklist thread as &quot;org.webkit.jsc.DFGCompiler&quot; or &quot;org.webkit.JavaScriptCore.DFGCompiler&quot;.</div><div><br></div><div>In Linux / Windows, we have the system to normalize the above name to &quot;NAME(15characters)&quot;.</div><div>For example, when you specify &quot;org.webkit.jsc.DFGCompiler&quot;, it will be shown as &quot;DFGCompiler&quot; in Linux.</div><div>This naming policy meets (1) in macOS. And (2) in all the environments. In macOS, the name is not modified.</div><div>So we can see the full name &quot;org.webkit.jsc.DFGCompiler&quot;.</div><div>In Linux, we can see &quot;DFGCompiler&quot;, it is quite useful compared to nameless threads.</div><div><br></div><div>What do you think of?</div><div><br></div><div>Best regards,</div><div>Yusuke Suzuki</div></div>