perfr, from Orbit · Post 26

Where Everything Lives

For two months the repository was two profilers sharing one tree: eighty-two C++ directories under src/, twenty-four vendored libraries, a Bazel graph that stitched the Rust in as static archives, and the Rust itself tucked into rust/ as if it were the guest. The C++ is gone and the Rust is at the root. This post is the map: one workspace, thirty-one crates, four directories, and the paths between them.

−549klines removed: 2,533 files, one commit
31crates, all in one crates/
1Cargo workspace and lockfile, down from six and seven
16C and C++ files kept, every one on purpose

A repository's layout is a claim about what the project is. Until this week the claim was "a C++ profiler with a Rust port growing inside it": src/ held the Qt application and the C++ service, third_party/ held LLVM, Qt and libunwindstack, MODULE.bazel was 1.9 MB of lockfile, and the Rust lived in a side directory whose crates were linked into OrbitService through a row of -ffi adapters. Post 13 measured the moment the Rust service overtook the C++ one; posts 14 through 25 never touched a C++ file again. The tree just had not caught up.

The cleanup is simple to describe and tedious to do: delete everything the C++ build owned, move the Rust from its side directory to the root, merge its six Cargo workspaces into one, and follow every path. What follows is the result, drawn.

The top level

A Cargo workspace root, and four directories beside it. The files are what any Rust repository has, Cargo.toml, Cargo.lock and the toolchain pin, plus run.sh, which builds the service and opens the viewer, and the usual README, LICENSE and .gitignore. The directories are where the counting starts.

The repository's top level: the workspace files, crates, tools, docs, .github and integrations, with file counts. ORBIT / · A WORKSPACE ROOT, FOUR DIRECTORIES, 643 TRACKED FILES Cargo.toml · Cargo.lock · rust-toolchain.toml · .cargo/config.toml · run.sh · README.md · LICENSE · .gitignore crates/ · 31 crates, 284 files the product, one directory per crate 24 service-side crates orbit-service and what it is built from: capture sources, symbols and stacks, the instrumentation API and its pip packages, the Frida agent and helper 7 orbit-live-* crates the eframe WASM viewer, its server, the trace importers, and the built pack in orbit-live-viewer/viewer-dist/, made by build_wasm.sh beside it crates/README.md describes each one tools/ · 138 files everything that drives, builds or ships it e2e/ · 27 browser scenarios test-programs/ · C, C++, Python targets build/ · musl, macOS, Windows packaging hook_test/ · one function at a time site/ + media-kit/ · the web site frida/ install/ sudo/ windows/ release/ docs/ · 192 files manual/ · 12 pages, the user's reference blog/ · 26 posts, 68 metrics snapshots design/ · the plans behind the code building_*.md, releasing.md, the essays .github/ · 11 workflows Linux, macOS, Windows builds and tests, the viewer, wheels, releases, the site integrations/ · 8 files unreal/ · an Unreal Engine plugin wrapping orbit.h, plus an engine patch not in the tree target/ · every Cargo build /site · the built web site dist/ · packaged services and wheels frida devkits · fetched into target/
Four directories and a workspace root. crates/ is the product, tools/ is how it is tested, built and shipped, docs/ is how it is explained. contrib/, which once held Docker images, IWYU configs and a Jupyter notebook for the C++ build, is gone: its two license-header scripts live in .github/scripts, its two logos with the site's media. Build output never enters the tree.

crates/: the service, in layers

Twenty-four crates on the service side, and the number is the port's history rather than a design: each phase of the port produced the crate that replaced one C++ library, and the crates kept their boundaries after the C++ left. That turns out to be a reasonable layering. Read from the bottom, each row depends only on rows below it.

The service crates arranged in dependency layers, from the zero-dependency leaves up to orbit-service. CRATES/ · THE SERVICE SIDE · ARROWS POINT AT WHAT A ROW USES orbit-service · 18,400 lines · the binary Linux, macOS and Windows entry point. Depends on fifteen crates below and on the viewer's server. Also here: python/orbit_profiler, the pip package that carries this binary. SOURCES · WHERE EVENTS COME FROM orbit-perf-ringperf_event_open, mmap rings unsafe in one module orbit-collectorthe event loop: round-robin rings, ordered output orbit-etwWindows: the kernel logger as scheduler and sampler orbit-gpu-helpera separate binary polling NVML, writes pod events STACKS AND SYMBOLS orbit-objectELF, PE, PDB, DWARF lines: what six LLVM libraries did orbit-unwindframehop over a stack copy, modules from /proc/pid/maps orbit-thread-statesthe per-thread state machine over sched tracepoints orbit-tracing-statethe bookkeeping LinuxTracing kept: uprobes returns, leaves INSTRUMENTATION · DYNAMIC AND MANUAL orbit-ptraceattach, read, write, inject syscalls into a tracee orbit-trampolineplacement, relocation, codegen, byte-identical with the C++ orbit-apiinclude/orbit.h, the C ABI, python/orbit_api; a cdylib orbit-frida-*agent: Gum inside the target; helper: Core, in its own process LEAVES · NO DEPENDENCIES ON EACH OTHER orbit-maps orbit-perf-records orbit-wire orbit-scope-ring orbit-perf-merge orbit-capture
Four rows and a cap. Not drawn, to keep the picture readable: orbit-test-rust (the Rust example program, on orbit-api), orbit-pod-dump (prints a capture, on orbit-wire), orbit-frida-transport (the capture lease, on orbit-scope-ring) and orbit-frida-build (the build-script helper that links the Frida devkits). orbit-capture is the Arrow-and-Parquet capture on disk and sits with the leaves because its only in-repo dependencies are the viewer's event crates. Every arrow in the real graph points downward; there are no cycles and no crate reaches up.

Two crates are worth singling out because they produce more than a library. orbit-api builds as an rlib, a static library and a shared library at once: liborbit_api.so is what orbit.h loads at run time, and the Python package beside it talks to the same shared object through ctypes. orbit-service is the binary, and its python/ directory is the orbit-profiler wheel that wraps it. Two files that used to sit loose at the root of rust/, included by #[path] from the two Frida crates, now have crates to live in: the devkit link logic is orbit-frida-build, a build-dependency of the agent and the helper, and the setup-only timing is a module of orbit-frida-transport.

crates/orbit-live-*: the web stuff

The viewer used to be src/OrbitLiveViewer, a PascalCase name under the C++ tree because it was born as the C++ service's web front end and linked into it through orbit-live-ffi. That crate is gone, and the seven that remain sit in crates/ with everything else, the pack beside the viewer crate in crates/orbit-live-viewer/viewer-dist. It is the one part of the tree with a build step that is not cargo build, and the diagram is mostly about that step.

The viewer crates, the build of the WASM pack, and how the pack ends up inside the service binary. CRATES/ORBIT-LIVE-* · FROM SOURCE TO A TAB what both sides share orbit-live-event orbit-live-protocol orbit-live-render orbit-live-ring 32-byte events, their framing, the rasterizer, the ring orbit-live-viewer · 26,100 lines eframe + wgpu, compiled to wasm32. The largest crate in the repository. Imports Chrome and Perfetto traces through orbit-live-chrome. cargo test runs it natively, no window build_wasm.sh nightly-2025-11-15, build-std, atomics for the worker pool, --profile wasm, wasm-bindgen 0.2.100 viewer-dist/ index.html, the .js and 8.9 MB of .wasm, checked in so no clone needs nightly orbit-live-server axum + WebSocket. Its build.rs reads the sibling viewer-dist/ and include_bytes! every file into the library. orbit-service links it
The pack travels as bytes. The viewer is compiled by a script, with the workspace's nightly-only settings: build-std, because the renderer's worker threads need a standard library built with atomics, and --profile wasm, a plain release build with no DWARF, since line tables and thin LTO buy a browser nothing. Its output is committed. The server crate embeds whatever is in viewer-dist/ at build time, and the service links the server, which is why a stale pack shows a stale page until the service is rebuilt. rust.sh warns when the pack is older than the viewer's sources.

The server has a main.rs of its own, which serves the viewer with a demo producer and no capture stack; that is the fastest way to work on the front end. The real thing is the service: it installs orbit_api::scope into the server's Instrument hook at start-up, which is how the viewer's own WebSocket sends show up as scopes in a capture of the service.

One workspace, where there were six

A canonical Rust repository has one Cargo.toml at its root, one crates/, one lockfile and one target/. Until this week this one had six workspaces and seven lockfiles, and every manifest explained why in the same words: Bazel's crate_universe spliced rust/ into a temporary directory to generate its dependency graph, and a path dependency that left rust/ broke every Bazel build. So orbit-service, which depends on the viewer's server, had to be its own workspace. So did orbit-capture. So did the viewer, three times over. The other reason given, keeping eframe out of the service's lockfile, was never one Cargo needed: feature resolution is per build graph, so cargo build -p orbit-service never compiles eframe whether or not the viewer shares its workspace.

The one Cargo workspace, with the service build graph and the viewer build graph sharing five crates. ONE CARGO.TOML, 31 MEMBERS, ONE CARGO.LOCK, ONE TARGET/ Cargo.toml · the workspace root cargo build -p orbit-service the service graph, 20 crates of this tree capture sources · symbols and stacks instrumentation: ptrace, trampoline, api, frida wire, capture, the viewer's server tokio, axum, arrow, object, framehop shared live-event live-protocol live-render live-ring build_wasm.sh · --profile wasm the viewer graph: orbit-live-viewer, orbit-live-chrome eframe + egui + wgpu, compiled to wasm32 ~200 crates nothing else in the tree depends on a service build never compiles them cargo test -p orbit-live-viewer runs natively
Two build graphs, one workspace. The merge kept every dependency at a version one of the old workspaces already used; the one that mattered, wasm-bindgen, stays at the 0.2.100 the viewer's CLI expects. Shared crates are compiled once per profile instead of once per workspace, CI caches one target/ per job, and cargo test --workspace finally means the whole tree.

What the merge took: one [workspace] listing the 31 crates, one lockfile built from the seven, one toolchain pin, a [profile.wasm] so the pack keeps the plain release settings it had in its own workspace, and every --manifest-path in a script or a workflow turned into a -p. The per-crate target/ directories went with it; everything builds into the one at the root, including the Frida devkits that tools/frida/devkits.sh fetches into it.

tools/: driving it and shipping it

DirectoryWhat it isWho runs it
e2e/One Python script, 27 scenarios: builds the service, starts it, drives the viewer in headless Chrome over CDP, clicks by label, reads the state the viewer exposes on window.__orbit_ui, and writes docs/e2e/report.md and the 47 screenshots. Three C targets live here for the hooking, crash and Frida scenarios, with the privileged uprobe test runner and the hooked-scope checker.Developers, after a change; the documentation, for its pictures
build/The packaging scripts: the static musl service for Linux, the universal macOS build, the Windows build with the static CRT.run.sh --static, the release workflow, anyone shipping a binary
test-programs/OrbitTestC, OrbitTestCpp, OrbitTestPython: the same scenario in three languages, every manual-instrumentation call once. Their Rust sibling is the crate orbit-test-rust. Moved here from src/.The api-* e2e scenarios; the macOS and Windows CI smoke tests
hook_test/The one-function-at-a-time hooking testbench: a C workload with named targets, hooked one by one, with a crash report that names the culprit.Anyone changing the trampolines or the Frida path
site/, media-kit/build_site.py renders the manual, the blog and a captured demo into /site (ignored). media-kit/ regenerates the landing page's clips from the running viewer.pages.yml, on every push to main
frida/Downloads the Frida Core and Gum devkits for a platform, checks them against devkits.sha256, builds the agent and helper beside the service.rust.sh; frida-rust.yml
install/, sudo/, windows/, release/The curl-able installers, the CAP_PERFMON wrapper, the MSVC environment and elevated-test runner, and build_wheels.sh for the two pip packages.Users; release-rust.yml and python-wheels.yml
sharing/The S3 stack that serves a capture bundle to a viewer on another origin.Whoever deploys sharing

docs/: the manual, the log, and the site they become

docs/manual/ is the user-facing reference, twelve Markdown pages from capture.md to troubleshooting.md. docs/blog/ is this log: twenty-six self-contained HTML posts, the metrics/ directory of sixty-eight committed snapshots that every number in them comes from, and two captured streams the front page replays. Four longer essays sit at the top of docs/ next to the build and release notes. The plans, briefs and reviews written while the work was open, the Windows handoff brief, the cross-platform plan, the sampling-viewer plan, the uprobe and instrumentation analyses, live in docs/design/, where the code comments that cite them still find them and where a reader of the manual does not have to step over them.

How docs and the viewer pack become the published site. THE SITE · .GITHUB/WORKFLOWS/PAGES.YML ON EVERY PUSH TO MAIN docs/manual, docs/blogMarkdown and HTML as written viewer-dist/rebuilt by build_wasm.sh in CI tools/site/build_site.py renders the Markdown, copies the essays and the blog, embeds the viewer with a saved capture --stream <saved capture> /site → GitHub Pagesignored locally, deployed from CI
The site is a build product, not a source. /site is in .gitignore; what is committed is the Markdown, the posts, and the viewer pack that the front page's live demo runs on. The same script with --service builds the copy the service serves at /site, which is how orbit-service carries its own manual.

.github/: what each workflow owns

WorkflowRunsCovers
frida-rustPRs, pushesThe Frida agent, transport and helper crates against the pinned devkits
live-viewerPRs touching crates/orbit-live-*/Native tests of all seven viewer crates, the stable wasm32 compile, the renderer's complexity test in release
macos-rust, windows-rustPRs, pushesThe service and the API on those platforms, the C/C++ test programs, a smoke capture
release-rustorbit-v* tagsThe static musl service, the macOS universal build, the Windows package, with the viewer pack checked for presence
python-wheelsTags, manualThe orbit-api and orbit-profiler wheels
pagesPushes to mainThe viewer pack and the site
checks, report-checksPRsLicense headers on the Rust, C, shell, PowerShell, JS and Python files a PR touches
codeql, scorecardsSchedulesPython scanning and the OSSF scorecard. CodeQL used to run a Bazel build for C++.

Notice what none of them run: cargo test --workspace in rust/. The crates CI tests are the ones a platform job needs, and the rest are run by hand. That gap showed itself during this cleanup, when the full workspace test suite turned out to include a self-sampling unwinder test with no bound on the records it kept; on this machine it reached 70 GB before the OOM killer stepped in. It is bounded now, 4,000 records or five seconds, and runs in under a second. A workspace-wide test job is the obvious next addition.

Where to go for what

To changeGo to
What the viewer draws or how it respondscrates/orbit-live-viewer/src/app.rs and its neighbours; then build_wasm.sh, then rebuild the service
What the service captures on Linuxcrates/orbit-service/src/ for the loop; orbit-perf-ring and orbit-collector for the kernel side
Windows captureorbit-etw, and windows.rs in the service
Function hookingorbit-frida-agent for what runs in the target, orbit-frida-helper for the controller, orbit-trampoline and orbit-ptrace for the native path
The manual-instrumentation APIorbit.h in orbit-api/include, the Rust behind it, python/orbit_api, then all four test programs
Symbol loading, unwindingorbit-object, orbit-unwind; fixtures in orbit-object/testdata
The capture fileorbit-wire for the pod stream, orbit-capture for the Parquet bundle
How a scenario is verifiedtools/e2e/orbit_e2e.py; run one scenario, not the suite
What users readdocs/manual/; the site rebuilds itself

What is not in the tree, and where it went

The C++ application, its Bazel build, third_party/, the Qt icons, the distro-matrix CI and the differential tools that held the two implementations against each other are on the cpp branch, at the last commit before the first Rust one. Every pointer in the docs that used to name a C++ file as "the specification this test mirrors" now says so with the branch beside it. The sixteen C and C++ files that stayed are the public header and its Unreal copy, three thin shims over the Frida devkits, the C targets the tests profile, the two example programs, six fixture sources and one blog experiment. None of them is Orbit's old code; all of them are the Rust profiler's.

Not in the tree either, by design: target/ directories, the built /site, the wheels' staged binaries, and the Frida devkits, which tools/frida fetches and verifies rather than vendors.

The short version. One Cargo workspace at the root. crates/ holds the service in layers and the seven viewer crates with the committed pack the service embeds; tools/ tests, builds and ships it; docs/ explains it and becomes the site, with the working notes in docs/design/. Nothing of the previous life is left in the tree but the blog that tells it.