← Back to Pull requests

Add perfetto trace events for Rust #8744

Closed
unknown closed this pull request without merging on Nov 25, 2026 08:23 UTC
View on GitHub
unknown unknown commented on Nov 20, 2026 16:10 UTC
Author

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 the
end of the block, like TRACE_EVENT. trace_event_async!("Name"); puts
it 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.

Diff: 207 lines (+155 / -52) across 2 files Reviewer: bartlomieju Review duration: 6733m
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
0.36
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 36.4% (MEDIUM) · Higher = larger blast radius
36.4%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 14.4% · Safe to merge
14.4%