Skip to content

Commit 6f9c422

Browse files
committed
feat: support custom Tokio worker thread names
Auto-discover worker threads when the default tokio-runtime-w prefix finds nothing by scanning /proc for the largest thread group matching {name}-{N} patterns. Add --workers flag as explicit override. On failure, log all thread names with a suggested prefix. Add THREAD_NAME env var to demo-server for testing custom names.
1 parent 95aaed1 commit 6f9c422

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ sudo hud my-app --threshold 1 # more sensitive
9292
# Rolling time window (only show last N seconds)
9393
sudo hud my-app --window 30 # metrics decay when load stops
9494

95-
# Custom Tokio thread names (auto-detected, or override explicitly)
95+
# Custom Tokio thread names are auto-detected. Override if needed:
9696
sudo hud my-app --workers my-io-worker
9797

9898
# Headless mode (CI/scripting) - run for 60 seconds then exit

docs/TROUBLESHOOTING.md

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
```bash
66
uname -r # Kernel 5.8+ required
7-
ps -T -p <PID> | grep tokio # Verify Tokio workers exist
7+
ps -T -p <PID> # List all threads (look for worker pool)
88
readlink -f /proc/<PID>/exe # Get actual binary path
99
```
1010

@@ -51,12 +51,42 @@ Then rebuild your application. The Debug % should rise to 80-100%.
5151
sudo ./hud my-app
5252
```
5353

54+
## Workers: 0
55+
56+
If hud prints `workers: 0`, it couldn't find Tokio worker threads. No events will be captured.
57+
58+
**Step 1: Check what threads exist**
59+
```bash
60+
ps -T -p <PID>
61+
```
62+
63+
Default Tokio threads are named `tokio-runtime-w`. Custom runtimes using `thread_name("my-pool")` produce `my-pool-0`, `my-pool-1`, etc.
64+
65+
**Step 2: hud auto-detects custom names**
66+
67+
In most cases, hud finds the right threads automatically — it looks for the largest group of threads matching `{name}-{N}` patterns. If the output shows `workers: 0` despite threads being visible in `ps`, auto-detection may have picked the wrong group.
68+
69+
**Step 3: Override with --workers**
70+
```bash
71+
sudo hud my-app --workers my-pool
72+
```
73+
74+
Pass the prefix that matches your worker threads (everything before the `-N` suffix).
75+
76+
**Step 4: Debug with RUST_LOG**
77+
```bash
78+
RUST_LOG=warn sudo hud my-app
79+
```
80+
81+
This shows which threads were found and suggests the right `--workers` prefix.
82+
5483
## No Events Captured
5584

56-
1. **Not Tokio:** Check for workers: `ps -T -p <PID> | grep tokio-runtime-w`
57-
2. **Custom thread names:** Worker threads are auto-detected, but if detection fails, pass `--workers <prefix>` explicitly (e.g. `--workers my-worker`). Run with `RUST_LOG=warn` to see which threads were found and what prefix to use
58-
3. **Idle app:** Generate load
59-
4. **Multiple matches:** Use explicit PID: `hud --pid <PID>`
85+
If `workers: N` looks correct but you still see zero events:
86+
87+
1. **Idle app:** Generate load — hud only captures events when workers are active
88+
2. **Multiple matches:** Use explicit PID: `hud --pid <PID>`
89+
3. **Threshold too high:** Try `--threshold 1` to catch shorter blocks
6090

6191
## eBPF Build Failures
6292

0 commit comments

Comments
 (0)