History miner: extract real per-derivation build times from nix logs #12

Closed
opened 2026-07-08 16:14:42 +03:00 by issuer-agent · 2 comments

The biggest accuracy win (per README roadmap). Add a nix-estimate mine subcommand producing the --history JSON ({name: minutes}) from real data.

Implementation:

  • Parse nix log <drv> timestamps where available.
  • Tail the daemon's build activity via nix build --log-format internal-json during a real build and record start/stop per drv.
  • Accept a nom JSON stream.
  • Normalize store names via existing store_name(), merge multiple runs (median), write/update the history file.
The biggest accuracy win (per README roadmap). Add a `nix-estimate mine` subcommand producing the `--history` JSON (`{name: minutes}`) from real data. **Implementation**: - Parse `nix log <drv>` timestamps where available. - Tail the daemon's build activity via `nix build --log-format internal-json` during a real build and record start/stop per drv. - Accept a nom JSON stream. - Normalize store names via existing `store_name()`, merge multiple runs (median), write/update the history file.
Owner

Fixed and merged to main (commit 837b885). Internal JSON parsing implementation complete; may need reconciliation with real nix log output and builder-arbitrage CRD schema.

Fixed and merged to main (commit 837b885). Internal JSON parsing implementation complete; may need reconciliation with real nix log output and builder-arbitrage CRD schema.
oleks closed this issue 2026-07-08 17:51:12 +03:00
Owner

Validated parse_internal_json against a real 427-line nix build --log-format internal-json capture (a remote nixbuild.net build). Confirmed correct: the @nix line prefix is stripped, only type==105 (actBuild) start/stop pairs are timed (store-copies type 0 and downloads excluded), .drv read from fields[0], 64-bit activity ids handled, and mine_history correctly reads STDERR with --log-format internal-json. Documented a real gotcha: result events reuse the number 105 from a different enum (resProgress) — guarded by the action=="start" check. Added regression tests with real captured fixtures. No logic change needed; parser was already correct.

Validated `parse_internal_json` against a real 427-line `nix build --log-format internal-json` capture (a remote nixbuild.net build). Confirmed correct: the `@nix ` line prefix is stripped, only `type==105` (actBuild) start/stop pairs are timed (store-copies type 0 and downloads excluded), `.drv` read from `fields[0]`, 64-bit activity ids handled, and mine_history correctly reads STDERR with `--log-format internal-json`. Documented a real gotcha: `result` events reuse the number 105 from a different enum (resProgress) — guarded by the `action=="start"` check. Added regression tests with real captured fixtures. No logic change needed; parser was already correct.
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: oleks/nix-estimator#12