Bug 1431184 - Register DOM Worker threads with the profiler for their entire lifetime, not just for the ranges during which they're running a worker script. r=froydnj
Our Web Worker code uses a thread pool where a single OS thread can be reused for different worker scripts during its lifetime. Before this patch, we only registered these threads with the profiler for the duration that they're running a worker script. So the same OS thread could be registered with the profiler during multiple disjoint time ranges, and we would expect the profiler to treat those different registrations as different conceptual threads. This had multiple advantages: - The "thread name" of the conceptual thread can include the script URL: "DOM Worker <scriptURL>". This allowed you to create thread filter which match a part of the URL, so you had the option of profiling just the worker threads you were interested in. - We wouldn't waste time sampling a worker thread while it's idle and has no script. But it also had disadvantages: - The profiler platform doesn't actually know how to deal with different "conceptual threads" that share the same OS thread. This lead to surprising breakage in different places. For example, the contents in the profiler buffer are marked with ThreadId entries which use the OS thread id. - What we show in the profiler UI didn't not match reality, and might be confusing to some people. I don't think the advantages are large enough to warrant teaching the rest of the profiler platform to deal with conceptual threads. So this change makes us stop doing the special thing and just register the OS threads for their entire duration. MozReview-Commit-ID: 82RtlRlwy3Y
This commit is contained in:
@@ -2836,17 +2836,11 @@ NS_IMPL_ISUPPORTS_INHERITED0(WorkerThreadPrimaryRunnable, Runnable)
|
||||
NS_IMETHODIMP
|
||||
WorkerThreadPrimaryRunnable::Run()
|
||||
{
|
||||
AUTO_PROFILER_LABEL_DYNAMIC_LOSSY_NSSTRING(
|
||||
"WorkerThreadPrimaryRunnable::Run", OTHER, mWorkerPrivate->ScriptURL());
|
||||
|
||||
using mozilla::ipc::BackgroundChild;
|
||||
|
||||
NS_SetCurrentThreadName("DOM Worker");
|
||||
|
||||
nsAutoCString threadName;
|
||||
threadName.AssignLiteral("DOM Worker '");
|
||||
threadName.Append(NS_LossyConvertUTF16toASCII(mWorkerPrivate->ScriptURL()));
|
||||
threadName.Append('\'');
|
||||
|
||||
AUTO_PROFILER_REGISTER_THREAD(threadName.get());
|
||||
|
||||
// Note: GetOrCreateForCurrentThread() must be called prior to
|
||||
// mWorkerPrivate->SetThread() in order to avoid accidentally consuming
|
||||
// worker messages here.
|
||||
|
||||
Reference in New Issue
Block a user