feat: shorten thread names

The Linux kernel imposes a 15-byte limit on thread names[1]. This means
information that does not fit in this limit, e.g., the pipeline ID of
layout and script threads, is lost in a debugger and profiler (see the
first column of the table below).

This commit shortens the thread names used in Servo to maximize the
amount of information conveyed. It also rectifies some inconsistencies
in the names.

|       Before      |       After       |
|-------------------|-------------------|
| `BluetoothThread` | `Bluetooth`       |
| `CanvasThread`    | `Canvas`          |
| `display alert d` | `AlertDialog`     |
| `FontCacheThread` | `FontCache`       |
| `GLPlayerThread`  | `GLPlayer`        |
| `HTML Parser`     | `Parse:www.examp` |
| `LayoutThread Pi` | `Layout(1,1)`     |
| `Memory profiler` | `MemoryProfiler`  |
| `Memory profiler` | `MemoryProfTimer` |
| `OfflineAudioCon` | `OfflineACResolv` |
| `PullTimelineMar` | `PullTimelineDat` |
| `ScriptThread Pi` | `Script(1,1)`     |
| `WebWorker for h` | `WW:www.example.` |
| `ServiceWorker f` | `SW:www.example.` |
| `ServiceWorkerMa` | `SvcWorkerManage` |
| `Time profiler t` | `TimeProfTimer`   |
| `Time profiler`   | `TimeProfiler`    |
| `WebGL thread`    | `WebGL`           |
| `Choose a device` | `DevicePicker`    |
| `Pick a file`     | `FilePicker`      |
| `Pick files`      | `FilePicker`      |

[1]: https://stackoverflow.com/questions/5026531/thread-name-longer-than-15-chars
This commit is contained in:
yvt 2021-07-19 00:50:04 +09:00
parent e8cb9f56e3
commit 41b3726271
21 changed files with 59 additions and 29 deletions

View file

@ -328,7 +328,6 @@ impl DedicatedWorkerGlobalScope {
context_sender: Sender<ContextForRequestInterrupt>,
) -> JoinHandle<()> {
let serialized_worker_url = worker_url.to_string();
let name = format!("WebWorker for {}", serialized_worker_url);
let top_level_browsing_context_id = TopLevelBrowsingContextId::installed();
let current_global = GlobalScope::current().expect("No current global object");
let origin = current_global.origin().immutable().clone();
@ -337,7 +336,7 @@ impl DedicatedWorkerGlobalScope {
let current_global_https_state = current_global.get_https_state();
thread::Builder::new()
.name(name)
.name(format!("WW:{}", worker_url.debug_compact()))
.spawn(move || {
thread_state::initialize(ThreadState::SCRIPT | ThreadState::IN_WORKER);

View file

@ -153,7 +153,7 @@ impl OfflineAudioContextMethods for OfflineAudioContext {
.task_manager()
.dom_manipulation_task_source_with_canceller();
Builder::new()
.name("OfflineAudioContextResolver".to_owned())
.name("OfflineACResolver".to_owned())
.spawn(move || {
let _ = receiver.recv();
let _ = task_source.queue_with_canceller(

View file

@ -302,7 +302,7 @@ impl ServiceWorkerGlobalScope {
let serialized_worker_url = script_url.to_string();
let origin = scope_url.origin();
thread::Builder::new()
.name(format!("ServiceWorker for {}", serialized_worker_url))
.name(format!("SW:{}", script_url.debug_compact()))
.spawn(move || {
thread_state::initialize(ThreadState::SCRIPT | ThreadState::IN_WORKER);
let runtime = new_rt_and_cx(None);

View file

@ -256,7 +256,7 @@ impl Tokenizer {
// will be generated from the input provided. These parser actions are then passed
// onto the main thread to be executed.
thread::Builder::new()
.name(String::from("HTML Parser"))
.name(format!("Parse:{}", tokenizer.url.debug_compact()))
.spawn(move || {
run(
sink,

View file

@ -773,7 +773,7 @@ impl ScriptThreadFactory for ScriptThread {
let (sender, receiver) = unbounded();
let layout_chan = sender.clone();
thread::Builder::new()
.name(format!("ScriptThread {:?}", state.id))
.name(format!("Script{}", state.id))
.spawn(move || {
thread_state::initialize(ThreadState::SCRIPT);
PipelineNamespace::install(state.pipeline_namespace_id);

View file

@ -499,7 +499,7 @@ impl ServiceWorkerManagerFactory for ServiceWorkerManager {
let resource_port = ROUTER.route_ipc_receiver_to_new_crossbeam_receiver(resource_port);
let _ = resource_sender.send(CoreResourceMsg::NetworkMediator(resource_chan, origin));
if thread::Builder::new()
.name("ServiceWorkerManager".to_owned())
.name("SvcWorkerManager".to_owned())
.spawn(move || {
ServiceWorkerManager::new(
own_sender,