codeperf.io

Performance tools

Workspace tracing.

We use several workspaces and subagents for a single task. To find out where the time goes, we need to see who was doing what, when they were doing it, and which work ran in parallel.

Trace viewer

Example run

OTLP JSON or JSON Lines. Files are read in this browser.

Elapsed
48 s
Workspaces
3
Spans
8

Time by workspace and agent

  • coordinator / lead 48 s
  • bench / benchmark agent 39 s
  • profiles / profiling agent 24 s

Span timeline

Bars share the same clock, starting at 0. Select a span for its timing and parent.

Investigate parser regression

coordinator / lead

Start offset
0 s
Duration
48 s
Self time
0 s
Parent span
Root span

# Reading a run

In the example, the lead agent hands a benchmark to one workspace and a CPU profile to another. The benchmark agent takes 39 seconds and the profiling agent takes 24. They start two seconds apart. Adding their durations would give 63 seconds, even though the entire run finishes in 48. The benchmark run itself takes 25 seconds. I’d investigate that span first if the goal were to get the final result sooner.

Elapsed time runs from the first recorded start to the last recorded finish. The workspace breakdown counts overlapping spans once for each workspace and agent pair. Select a span to see its parent and its self time. Self time is the part of its duration outside its recorded direct children. It can include waiting, I/O, or work the tracer didn’t capture. To investigate CPU usage within a span, I use topdown-profiler.

# Which tool is slowing the machine down?

A long span tells us which operation took time. A tool in a different workspace may be consuming the CPU or disk bandwidth it needs. I’m proposing a lightweight Linux collector that would connect per-tool resource use to the timeline, with an optional eBPF profile for the calls worth investigating. Read the tool profiler proposal.

The Rust profiler and Orca panel rank recorded tools across worktrees. Start with the tool taking the largest share of elapsed time, then open its example trace and the Linux worker’s CPU profile.

To capture a real Claude Code or Codex CLI session from an Orca worktree, follow the Jaeger and eBPF walkthrough. It includes a command wrapper, a two-span smoke test and a Linux CPU profile.

# Capture your own run

  1. Start a root OpenTelemetry span for the task. Pass its trace context when dispatching a subagent, including across workspace boundaries. Start a child span around each operation you want to measure, such as a tool call, build, benchmark or wait.
  2. Set the string attribute workspace.name on each workspace’s resource or span and gen_ai.agent.name on the agent’s operations. These are the labels the viewer groups by. It falls back to service.name and gen_ai.agent.id respectively. Use synchronized clocks when comparing different hosts.
  3. Export the finished spans as OTLP JSON and open the file above. The viewer accepts a single export, an array of exports, or one export per line from a Collector file exporter. If a file contains several trace IDs, choose the run you want to inspect.

Download the example trace · OpenTelemetry context propagation (opens new window) · Collector file exporter (opens new window)

# Write a local trace file

For an instrumented agent runner that exports OTLP over HTTP, this minimal OpenTelemetry Collector Contrib configuration listens on loopback and writes trace batches to the current directory. Start it with otelcol-contrib --config collector.yaml, then point the runner’s OTLP/HTTP trace exporter at http://127.0.0.1:4318/v1/traces. After the run has flushed, open workspace-traces.jsonl in the viewer. Each machine can run its own collector. Concatenate their JSON Lines files to inspect a run that spans hosts.

receivers:
  otlp:
    protocols:
      http:
        endpoint: 127.0.0.1:4318
exporters:
  file:
    path: ./workspace-traces.jsonl
    format: json
service:
  pipelines:
    traces:
      receivers: [otlp]
      exporters: [file]