Add perfetto trace events for Rust #8744
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 207 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.319
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #8744"
general
weight: 0.35
bartlomieju
Code moving from C++ to Rust loses its perfetto trace events, because
Rust can't emit them. The Rust server already emits none of the C++
server's TRACE_EVENTs, and Rust code that runs inside a C++ span has
to keep that span in a C++ call, which stops working once the work
inside the span moves into Rust.
This adds a perfetto crate (src/workerd/util/perfetto) that writes
slices into the same session and "workerd" category as C++.
trace_event!("Name");opens a slice on the thread's track until theend of the block, like TRACE_EVENT.
trace_event_async!("Name");putsit on its own track, so it can span an .await: thread-track slices
nest as a stack, so one held across an .await would close another
future's slice. clippy.toml makes holding the thread-track guard
across an .await a lint error. As a first use, the Rust server's HTTP
listener gets its request() and connect() slices back.
#7528 does this with perfetto's Rust SDK, which needs a patch to
perfetto's build that every embedder has to carry through perfetto
updates, and takes a mutex per event. This instead calls a few C++
shims over the C++ SDK we already link: no patch, no new crates, and
the same cost as C++ TRACE_EVENT. It only supports slices with static
names, which is enough for the events being ported now. #7528's API
can replace it if we need arguments or flows later. When nothing is
tracing, a slice costs one relaxed atomic load.
The tests start an in-process PerfettoSession, decode the trace, and
check slice names, tracks and nesting, including slices that span
awaits or end on another thread. With perfetto compiled out, they check
that nothing is recorded.