Cost model mis-identifies the long pole: cost trivial/glue derivations ~0 #2

Open
opened 2026-07-07 20:12:56 +03:00 by oleks · 0 comments
Owner

Problem

In the emmett aarch64 trial the reported critical path was:

→ X-Restart-Triggers-dbus-broker
→ unit-dbus-broker.service
→ user-units
→ etc
→ activate
→ nixos-system-emmett-...

These are NixOS assembly glue derivations — writeText/runCommand/substituteAll builds that finish in milliseconds. But every one is costed at the flat DEFAULT = 1.0 min, so the chain sums to a fake ~165-min span and becomes the reported long pole. This distorts span (T∞), the recommendation, and the makespan floor.

It also makes the recommendation tagline self-contradictory: it printed "The long pole is one derivation, so cores/node sets the floor" while the actual long pole was a thin chain of cheap glue, not one heavy compile.

Fix

In costmodel.py, recognize trivial/glue derivations and cost them ~0 (a few seconds):

  • builder is bash and the derivation does no real compile (heuristic on builder + args, or absence of a configurePhase/buildPhase);
  • name patterns: unit-*, *.service, *-restart-triggers, etc, activate, user-units, system-units, system-path, dbus-*-conf, nixos-system-*, *-env, *.conf.

Add a TRIVIAL = (0.05, 0.0) tier checked before DEFAULT. Add a unit test with a synthetic glue chain asserting it does not dominate the span. Depends on the schema-agnostic drv fields already available (issue is independent of #1).

## Problem In the emmett aarch64 trial the reported critical path was: ``` → X-Restart-Triggers-dbus-broker → unit-dbus-broker.service → user-units → etc → activate → nixos-system-emmett-... ``` These are NixOS **assembly glue** derivations — `writeText`/`runCommand`/`substituteAll` builds that finish in milliseconds. But every one is costed at the flat `DEFAULT = 1.0 min`, so the chain sums to a fake ~165-min span and *becomes* the reported long pole. This distorts span (`T∞`), the recommendation, and the makespan floor. It also makes the recommendation tagline self-contradictory: it printed *"The long pole is one derivation, so cores/node sets the floor"* while the actual long pole was a thin chain of cheap glue, not one heavy compile. ## Fix In `costmodel.py`, recognize trivial/glue derivations and cost them ~0 (a few seconds): - builder is bash and the derivation does no real compile (heuristic on `builder` + args, or absence of a `configurePhase`/`buildPhase`); - name patterns: `unit-*`, `*.service`, `*-restart-triggers`, `etc`, `activate`, `user-units`, `system-units`, `system-path`, `dbus-*-conf`, `nixos-system-*`, `*-env`, `*.conf`. Add a `TRIVIAL = (0.05, 0.0)` tier checked before `DEFAULT`. Add a unit test with a synthetic glue chain asserting it does not dominate the span. Depends on the schema-agnostic drv fields already available (issue is independent of #1).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: oleks/nix-estimator#2