You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pynixd: trace each build and client session with OpenTelemetry, into VictoriaTraces #1570
pynixd needs real tracing to improve further. Today one build's life is spread over structlog lines in several processes: the client, dynhetz, the builder's pynixd and nix-daemon. The SQLite placement trace (#1070) explains the placement decision and nothing after it. build_observed gives totals only. Finding why a build sat 2195 s on sg1 (#1568) took ssh into nodes, cgroup files read by hand, and timestamps lined up across four logs.
Wanted: OpenTelemetry spans, exported over OTLP.
A client session and its ops.
Each build's life: enqueue, each wait with its reason (limit, no store, disk, memory), placement, input copy, build, pull, retry. The figures pynixd already has go on as attributes: placement terms, cores, expected and measured peak memory, OOM kills.
Across machines: the trace context goes to a pynixd builder in a wire feature, as the health stream does, so a build on sg1 is part of dynhetz's trace.
Backend: VictoriaTraces. sg1 runs one (solid-kubernetes components/vm/traces, OTLP at /insert/opentelemetry/v1/traces; in-cluster only behind a Cilium ingress policy today, so dynhetz needs a path to it). dynhetz and the sg1 nodes report there. Tests run nixpkgs' victoriatraces in a guest.
Constraints:
Off by default; an endpoint setting turns it on.
No export work on the event loop (loop-stall rule): the batch processor's own thread, bounded queue, drop on overflow.
Measure overhead before and after on the agreed end-to-end benchmark. A 2.9 s gen-2 GC stall on dynhetz (2026-11-22 14:21 UTC) shows allocation already matters.
The SQLite placement trace stays as it is; a span can carry its decision id.
First step: build-life spans on one instance with a VictoriaTraces guest test, overhead measured. The wire propagation follows.
Step 1 landed: dadb6f0 (locked at d69c8f8). Off unless tracing.endpoint is set.
One build is one trace: root build <name>, a wait span for each reason it waits, an attempt span for each store, and inputs, build, outputs under the attempt. A retry ends its attempt; an OOM kill is an event. Settings: endpoint, bearer_token_file, service_name, queue_size, schedule_delay, export_timeout, shutdown_timeout.
Tests: the unit tests use the SDK's in-memory exporter. tests/functional/test_build_trace_live.py builds through pynixd into nixpkgs' VictoriaTraces 0.13.0 and reads the trace back through the Jaeger API. Negative control: without the wait hook, the wait test fails (KeyError 'wait'). Full guest run: 16/16 phases passed.
Loop-thread cost, measured on dynhetz in the dev shell, 20,000 builds × 7 spans into a no-op exporter, three runs:
µs per build
off
6.7, 8.1, 9.7 (the fake build object; the trace calls are no-ops)
on
257, 310, 220
About 35 µs per span on the loop, with the export on the batch processor's thread. A 1 s build pays under 0.03%. The closure grows by at most 38 MB of 557 MB (mostly protobuf).
Not yet: client sessions and ops as spans, and the trace context sent to a pynixd builder (step 2; pynixd already reads and forwards Determinate's traceparent).
A build or transfer operation is a span from its start, with pynixd.session, .user, .role, .transport, .client_pid. Builds it enqueues and backend calls it makes are its children; on a pynixd builder, BuildDerivation nests under the controller's build phase.
Other operations become a span only when slower than tracing.slow_op_seconds (1 s) or failed, with the real start time.
A request that joins a queued build adds a span link.
Loop cost per operation: off 0.12 us; on, 0.33 us for a fast query, 28 us for a traced op, 26 us for a failed query.
Live probe on sg1 VictoriaTraces: BuildPathsWithResults 132 ms (user lillecarl, admin, unix, pid 712622) → build trace-probe-1795364417 128 ms → attempt 114 ms → inputs / build 77 ms / outputs 28 ms.
Activity
pynixd: trace each build's life as OpenTelemetry spans
Lillecarl commentedon Nov 22, 2026
Step 1 landed: dadb6f0 (locked at d69c8f8). Off unless
tracing.endpointis set.One build is one trace: root
build <name>, awaitspan for each reason it waits, anattemptspan for each store, andinputs,build,outputsunder the attempt. A retry ends its attempt; an OOM kill is an event. Settings:endpoint,bearer_token_file,service_name,queue_size,schedule_delay,export_timeout,shutdown_timeout.Tests: the unit tests use the SDK's in-memory exporter.
tests/functional/test_build_trace_live.pybuilds through pynixd into nixpkgs' VictoriaTraces 0.13.0 and reads the trace back through the Jaeger API. Negative control: without the wait hook, the wait test fails (KeyError 'wait'). Full guest run: 16/16 phases passed.Loop-thread cost, measured on dynhetz in the dev shell, 20,000 builds × 7 spans into a no-op exporter, three runs:
About 35 µs per span on the loop, with the export on the batch processor's thread. A 1 s build pays under 0.03%. The closure grows by at most 38 MB of 557 MB (mostly protobuf).
Not yet: client sessions and ops as spans, and the trace context sent to a pynixd builder (step 2; pynixd already reads and forwards Determinate's
traceparent).Assisted-By: Claude Opus 5.5
nixidae-pynixd: bump to d69c8f84
dynhetz: send pynixd's build traces to SG1's VictoriaTraces
pynixd: type the Jaeger query window of the trace test
pynixd: a build's trace goes on through the store that builds it
nixidae-pynixd: bump to 54fe482e
pynixd: trace each client operation with the session that sent it
Lillecarl commentedon Nov 22, 2026
Op spans landed (c03e02a) and run on dynhetz.
pynixd.session,.user,.role,.transport,.client_pid. Builds it enqueues and backend calls it makes are its children; on a pynixd builder,BuildDerivationnests under the controller's build phase.tracing.slow_op_seconds(1 s) or failed, with the real start time.Loop cost per operation: off 0.12 us; on, 0.33 us for a fast query, 28 us for a traced op, 26 us for a failed query.
Live probe on sg1 VictoriaTraces:
BuildPathsWithResults132 ms (user lillecarl, admin, unix, pid 712622) →build trace-probe-1795364417128 ms →attempt114 ms → inputs / build 77 ms / outputs 28 ms.Assisted-By: Claude Opus 5.5
pynixd: name the reverse builder's sessions "reverse"