Skip to content

Commit 6beda4a

Browse files
committed
f
1 parent 7f84f5b commit 6beda4a

File tree

8 files changed

+214
-107
lines changed

8 files changed

+214
-107
lines changed

CHANGELOG

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ Unreleased:
1515
SDK:
1616
*
1717
Tools:
18-
* tracebox: Added `tracebox ctl` applet for explicit daemon lifecycle
19-
management (start/stop/status). Default behavior now requires daemons
20-
to be running on Linux/macOS. Use `tracebox ctl start` to manage
21-
persistent daemons or `--autodaemonize` for legacy self-contained mode.
18+
* Breaking change for tracebox users: `tracebox` no longer automatically
19+
starts daemons by default. Daemons must be running before capturing a
20+
trace. We recommend using the new `tracebox ctl` applet (e.g. `tracebox
21+
ctl start`) to manage persistent daemons. To restore the previous
22+
self-contained behavior, use the `--legacy` flag.
2223

2324
v53.0 - 2025-11-12:
2425
SDK:

docs/getting-started/cpu-profiling.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ echo -1 | sudo tee /proc/sys/kernel/perf_event_paranoid
163163
Assuming the example config above is saved as `/tmp/config.txtpb`, start the
164164
recording.
165165
```bash
166+
./tracebox ctl start
166167
./tracebox -c /tmp/config.txtpb --txt -o /tmp/trace.pb
167168
```
168169

@@ -333,6 +334,7 @@ Assuming the example config above is saved as `/tmp/config.txtpb` (with the
333334
target\_cmdline option changed to a process on your machine), start the
334335
recording.
335336
```bash
337+
./tracebox ctl start
336338
./tracebox -c /tmp/config.txtpb --txt -o /tmp/trace.pb
337339
```
338340

docs/getting-started/ftrace.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,15 @@ See the [system tracing page](/docs/getting-started/system-tracing.md) in order
285285
to get set up with tracebox. For this example we are going to record a trace
286286
from the command line using the config file we just created:
287287
```bash
288+
./tracebox ctl start
288289
./tracebox -c ticker.cfg --txt -o ticker.pftrace
289290
```
290291

292+
Alternatively using legacy mode:
293+
```bash
294+
./tracebox --legacy -c ticker.cfg --txt -o ticker.pftrace
295+
```
296+
291297
Note: tracebox will take care of enabling tracing and our ticker events (as we
292298
did manually in the preceding step).
293299

docs/getting-started/memory-profiling.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,20 @@ chmod +x tracebox heap_profile
174174

175175
Start the tracing service
176176
```bash
177-
./tracebox traced &
177+
./tracebox ctl start
178178
```
179179

180180
Generate the heapprofd config and start the tracing session.
181181
```bash
182182
# Replace trace_processor_shell with with the name of the process you want to
183183
# profile.
184184
./heap_profile -n trace_processor_shell --print-config | \
185-
./tracebox perfetto --txt -c - -o ~/trace_processor_memory.pftrace
185+
./tracebox -c - --txt -o ~/trace_processor_memory.pftrace
186+
```
187+
Alternatively, use the legacy self-contained mode (no `ctl start` required):
188+
```bash
189+
./heap_profile -n trace_processor_shell --print-config | \
190+
./tracebox --legacy -c - --txt -o ~/trace_processor_memory.pftrace
186191
```
187192

188193
Open another terminal (or tab), start the process you want to profile,
@@ -213,10 +218,9 @@ In either case: press Ctrl-C on the `tracebox perfetto` command of the previous
213218
step. That will write the trace file (e.g. `~/trace_processor_memory.pftrace`)
214219
which you can then open with the Perfetto UI.
215220

216-
Remember also to kill the `tracebox traced` service once you are done.
221+
Remember also to kill the `tracebox` services once you are done.
217222
```bash
218-
fg
219-
# Ctrl-C
223+
./tracebox ctl stop
220224
```
221225
</tabs?>
222226

docs/getting-started/system-tracing.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,13 @@ chmod +x tracebox
153153

154154
## Capturing a trace
155155

156-
To capture a trace you need to pass the config file to the downloaded `tracebox`
156+
First, start the tracing daemons in background:
157+
158+
```bash
159+
./tracebox ctl start
160+
```
161+
162+
Then, to capture a trace you need to pass the config file to the downloaded `tracebox`
157163
binary. We have some sample config files in the [/test/configs/](/test/configs/)
158164
directory.
159165
Lets say you want to capture a trace with the scheduling information. You can
@@ -166,7 +172,12 @@ and running the following command:
166172
./tracebox -o trace_file.perfetto-trace --txt -c scheduling.cfg
167173
```
168174
The scheduling information is captured using ftrace, so you may need to start
169-
the `tracebox` with root privileges.
175+
the `tracebox` daemons with root privileges (e.g. `sudo ./tracebox ctl start`).
176+
177+
If you prefer the old behavior where tracebox starts temporary daemons for the duration of the trace, you can use the `--legacy` flag:
178+
```bash
179+
./tracebox --legacy -o trace_file.perfetto-trace --txt -c scheduling.cfg
180+
```
170181

171182
</tabs?>
172183

docs/learning-more/tracing-in-background.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ that no data is lost at the beginning of the trace.
2323
Start recording a trace using `tracebox` or `perfetto`.
2424

2525
```bash
26+
# If using tracebox, ensure daemons are started first:
27+
# tracebox ctl start
2628
perfetto -c config.cfg --txt -o trace.pftrace --background-wait
2729
```
2830

docs/reference/tracebox.md

Lines changed: 76 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ tracebox -t 10s -o trace.pftrace sched freq
1313
tracebox ctl stop
1414

1515
# Self-contained mode (legacy)
16-
tracebox --autodaemonize -t 10s -o trace.pftrace sched
16+
tracebox --legacy -t 10s -o trace.pftrace sched
1717

1818
# Invoke bundled applets
1919
tracebox [applet_name] [args ...]
@@ -25,9 +25,15 @@ tracebox [applet_name] [args ...]
2525
(`traced_probes`), and the `perfetto` command-line client into a single binary.
2626

2727
**Behavior change (2025):** `tracebox` now requires daemons to be running before
28-
capturing traces. Use `tracebox ctl` to manage daemons, or `--autodaemonize` for
28+
capturing traces. Use `tracebox ctl` to manage daemons, or `--legacy` for
2929
the legacy self-contained mode.
3030

31+
If you are a user of `tracebox` in its default mode (i.e., you don't use
32+
`--legacy`), you should read the migration guide below. The new default
33+
behavior provides a more robust and predictable experience, especially for
34+
processes instrumented with the Perfetto SDK, but it requires a small change to
35+
your workflow.
36+
3137
## DAEMON MANAGEMENT
3238

3339
### tracebox ctl start [--log]
@@ -68,18 +74,29 @@ If systemd service files are detected:
6874
- As root: `ctl start` uses `systemctl start traced traced-probes`
6975
- As user: Instructs to use `sudo systemctl start traced traced-probes`
7076

71-
## SELF-CONTAINED MODE
77+
## LEGACY SELF-CONTAINED MODE
78+
79+
The `--legacy` flag preserves the legacy behavior of `tracebox` where it
80+
spawns temporary daemons for the duration of a single trace session. This mode
81+
uses private, temporary sockets and is fully self-contained.
7282

73-
The `--autodaemonize` flag spawns temporary daemons for a single trace session.
83+
**When to use:**
84+
- For quick one-off traces where you don't want to manage daemons.
85+
- If you cannot or do not want to run persistent background daemons.
86+
- For scripts that rely on the old behavior and haven't been migrated yet.
7487

7588
**Limitations:**
76-
- SDK-instrumented apps won't connect (uses private sockets)
77-
- Inefficient for multiple traces
78-
- Not recommended for regular use
89+
- **SDK Incompatibility:** Processes instrumented with the Perfetto SDK (e.g.
90+
using `track_event`) will generally fail to connect to these temporary daemons
91+
because they listen on private, unpredictable socket addresses.
92+
- **Inefficiency:** Spawns and kills daemons for every trace, which is slower
93+
for repeated tracing.
94+
- **Concurrency:** Running multiple instances of `tracebox --legacy`
95+
concurrently can lead to resource conflicts (e.g. with ftrace).
7996

8097
**Example:**
8198
```bash
82-
tracebox --autodaemonize -t 10s -o trace.pftrace sched freq
99+
tracebox --legacy -t 10s -o trace.pftrace sched freq
83100
```
84101

85102
## APPLET MODE
@@ -113,7 +130,7 @@ tracebox ctl status # Check daemon status
113130

114131
If daemons aren't running:
115132
- Use `tracebox ctl start` to start them
116-
- Or use `--autodaemonize` for self-contained mode
133+
- Or use `--legacy` for self-contained mode
117134

118135
### Permission denied
119136

@@ -141,23 +158,56 @@ sudo systemctl stop traced traced-probes
141158
tracebox ctl start
142159
```
143160

144-
## MIGRATION
145-
146-
**Old (before 2025):**
147-
```bash
148-
tracebox -t 10s -o trace.pftrace sched
149-
```
150-
151-
**New (recommended):**
152-
```bash
153-
tracebox ctl start
154-
tracebox -t 10s -o trace.pftrace sched
155-
```
156-
157-
**New (backward compatible):**
158-
```bash
159-
tracebox --autodaemonize -t 10s -o trace.pftrace sched
160-
```
161+
## MIGRATION GUIDE (2025)
162+
163+
The default behavior of `tracebox` has changed to require explicit daemon
164+
management. This change resolves long-standing issues with SDK connectivity and
165+
provides a more consistent experience.
166+
167+
### Why the change?
168+
In the old model, `tracebox` would silently spawn "ephemeral" daemons on private
169+
sockets. This often confused users because apps instrumented with the Perfetto
170+
SDK (e.g., Chrome, or your own apps) would fail to connect to these hidden
171+
daemons, resulting in traces missing all userspace data. The new model ensures
172+
daemons run on standard system sockets where SDK apps can find them.
173+
174+
### Migration Steps
175+
176+
**Scenario 1: You run interactive traces manually**
177+
178+
* **Old way:**
179+
```bash
180+
tracebox -t 10s -o trace.pftrace sched
181+
```
182+
* **New way (Recommended):**
183+
Run this once per boot (or when needed):
184+
```bash
185+
tracebox ctl start
186+
```
187+
Then run your traces as usual:
188+
```bash
189+
tracebox -t 10s -o trace.pftrace sched
190+
```
191+
When done (optional):
192+
```bash
193+
tracebox ctl stop
194+
```
195+
196+
**Scenario 2: You have scripts that wrap tracebox**
197+
198+
* **Option A (Better):** Update your scripts to ensure daemons are running
199+
using `tracebox ctl start` before tracing.
200+
* **Option B (Faster fix):** Update your scripts to use the `--legacy`
201+
flag to restore the old behavior.
202+
```bash
203+
tracebox --legacy -t 10s -o trace.pftrace sched
204+
```
205+
206+
**Scenario 3: You are tracing SDK-instrumented apps**
207+
208+
You **must** use the new explicit daemon mode. The legacy `--legacy` mode
209+
will likely not work because your app won't be able to discover the temporary
210+
sockets.
161211
162212
## SEE ALSO
163213

0 commit comments

Comments
 (0)