Skip to content

Prototype: split the crate into a core library and a Console/CLI binary, and measure edit-rebuild times #1889

Closed

Description

@JacobStephens2

This was generated by AI during triage.

Agent Brief

Category: enhancement
Summary: Prototype splitting the crate into a core library plus a Console/CLI binary, and measure what it does to edit-rebuild times. This is an experiment: production code stays unchanged.

Current behavior:
thirdshift is a single binary crate of about 156k lines. With LLD, an edit-rebuild takes about 4.3 s. That is the default linker on x86_64-unknown-linux-gnu since Rust 1.90, and the measurement was taken on aarch64 with -fuse-ld=lld. Running -Ztime-passes on that rebuild shows only 0.03 s of LLVM work and 0.5 s of linking. About 3.5 s is whole-crate work that grows with crate size: macro expansion (0.5 s), resolution and type checking (~0.6 s), monomorphization collection and partitioning (1.2 s), and incremental state serialization (~0.9 s). The Go prototype rebuilds in about 0.6 s (#1835). Background is in docs/research/rust-build-profile.md and #1868.

The Console is the most promising seam:

  • It is the second most-edited top-level module (811 file-touches in the 60 days to 2026-11-09, just behind the logs module at 825).
  • It is about 13.5k lines of Rust plus askama templates.
  • Almost nothing depends on it. Only the CLI argument module, the User config and the logs module import it.
  • Those last two imports come down to the Console Scope type and the Fleet pairing_address function.

Desired behavior:
A reproducible experiment, in the style of the Go (#1830) and TypeScript (#1831) prototypes:

  • The split: a reproducible way to turn a pinned Base branch commit into a Cargo workspace with two crates:

    • a core library holding everything except the Console;
    • the thirdshift binary holding the Console and the CLI entry point and argument parsing.

    Core must not depend on the binary crate. Move or invert the few core → Console references, such as Scope and the Fleet pairing address. Widening visibility (pub(crate) → pub) in core is acceptable for the prototype. Shared test helpers can be exposed through a cargo feature. Deliver the split as a patch or script under a new prototype directory beside the existing ones, pinned to the commit it applies to.

  • Faithfulness: on the split tree, cargo build --locked, cargo clippy --all-targets -- -D warnings and the full cargo test suite pass. Record the commands and results.

  • A benchmark runner that measures the Base commit and the split tree on the same host. Use fresh target directories, run sequentially, and take at least 3 samples per measurement. Record:

    • cold dev build of the binary;
    • cold cargo test --no-run;
    • edit-rebuild after appending a comment to: (a) a Console handler module, (b) the Ticket run module, (c) the logs module. The first build after any flag change is excluded;
    • the same edits with cargo check.

    Record host, CPU count, rustc version and linker.

  • A research report in docs/research/. It gives the measurements and per-sample data, explains where the time went (the per-crate -Ztime-passes breakdown on nightly is welcome, but not required), and states how much an edit in each location gains or loses. It lists what adopting the split for real would cost: visibility changes, test-helper sharing, CI and scripts/affected-tests changes, and release builds. It also names the next seams worth trying, for example Evals, Scoring and Experiments, which only four modules import. ADR-0001 and the production layout stay unchanged. Adopting a workspace is a later Day shift decision.

Key interfaces:

  • The core library's public surface is whatever the Console and CLI need. Keep it a mechanical widening, not a redesign.
  • The binary keeps its name thirdshift and its CLI behavior, so the existing integration tests run unchanged against it.

Acceptance criteria:

  • Applying the delivered patch or script to its pinned commit produces a two-crate workspace in which core does not depend on the binary crate.
  • On that tree, the build, clippy with -D warnings and the full test suite pass, and the report shows the commands and results.
  • The benchmark runner reproduces every number in the report on a new host with one command, and records the host details.
  • The report gives Base-vs-split numbers for: the cold build; the cold test compile; and edit-rebuild and check after edits in the Console, the Ticket run module and the logs module. Each has at least 3 samples.
  • The report says plainly whether Console edits got faster and whether core edits got slower, and by how much.
  • No production source, Cargo.toml, CI workflow or ADR changes on the Base branch. The PR adds only the prototype directory and the report.

Out of scope:

Activity

  1. added
    enhancement
    ready-for-agent
    in-progress
    and removed
    ready-for-agent
    on Nov 9, 2026
  2. removed
    in-progress
    on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions