Skip to content

perf(install): a fresh clone with a lockfile takes the full pipeline - #5414

Closed
Daniel Meppiel (danielmeppiel) wants to merge 5 commits into
mainfrom
danielmeppiel-perf-fresh-locked-full-run
Closed

Daniel Meppiel (danielmeppiel) wants to merge 5 commits into
mainfrom
danielmeppiel-perf-fresh-locked-full-run

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

A fresh clone that commits its apm.lock.yaml, installed on a machine with a warm cache, took the diff-apply fast path. That path staged, re-verified and committed the whole project (applied a verified diff (667 files) on tree-50). For a whole-project diff that costs more than the full pipeline.

This PR declines to the full pipeline when the checkout has no bound deployment receipts (no .apm-local/installation bound to a receipt file), right after _plan_files/_outcomes and before the policy/audit re-checks and _stage_all. Nothing has been written at that point, so the existing Decline hand-off applies. Converged, incremental and no-op installs keep the fast path because their receipts are present. The existing warm-locked parity cell still expects the diff decision.

This is routing only: the full pipeline is the reference path that every no-lockfile install already takes. What the fast path accepts and every check either path makes are unchanged. W3d design: OK with conditions FC1-FC3 (row w3d:ruling:fresh-locked), addressed below.

Measured upper bound (fast path deleted, plain stack, t50, 6 pairs, anon): install-locked-warm paired W 0.885 / L 0.919 (runs 45513481474 / 45513512058). Gate benches for this head vs main 1e4a208 are in the validation section.

Issue and approved scope

Issue: Refs #4939

Human scope-approval comment: none yet for this item. Ordered by the PERF lead chain under #4939 (locked-warm regression, VP-approved shape "no receipts -> full pipeline").

This does not complete #4939.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Local runs (macOS, host_guard, APM_BINARY_PATH=.venv/bin/apm):

  • pytest tests/lifecycle/scenarios/test_engine_parity.py::test_a_clone_without_bound_receipts_takes_the_full_pipeline: 2 passed (clone-with-lock, clone-copied-identity). These cells check twin parity of exit code, output and full state, plus decision FULL.
  • Same clone-with-lock cell with diff_apply.py reverted to main: FAILED with expected a full decision, got 'applied a verified diff (2 files)'. That proves the cell catches a regression. Twin state parity held before the decision assert, so on main the fast and full results are identical for this shape.
  • test_engine_parity_invariants.py::test_declined_fast_path_writes_nothing[clone-with-lock|clone-copied-identity]: passed. The engine decides FULL and writes nothing before the hand-off (W3d FC1, FC3).
  • test_engine_parity.py::test_warm_locked_install_applies_the_diff: passed, so the fast path is still used when receipts are present.
  • ruff check / ruff format --check (ruff 0.15.12) on changed files: clean.

W3d FC2 (byte-identical differential of lockfile, receipts and project, L + W): CI run in flight, result to be added below.

Changelog

  • One fragment per section, changelog.d/<pr>.<section>.md, holding
    one line: user-visible effect first, 25 words or fewer, ending with
    (#PR); breaking changes only under upgrade notes; no Highlights; no
    new lines under ## [Unreleased]. See changelog.d/README.md and
    .github/instructions/changelog.instructions.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • N/A -- this PR does not change OpenAPM-observable behaviour.

With no deployment receipts (a fresh checkout), the diff-apply fast path
stages, re-verifies and commits the whole project, which costs more than the
full pipeline (locked-warm t50 upper bound: W 0.885, L 0.919 paired). Decline
before staging; the full pipeline is the reference behavior. Converged,
incremental and no-op installs (receipts present) keep the fast path.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…peline, writing nothing first (W3d FC1, FC3)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…rmalize receipt names in twin output

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 25, 2026 00:36
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the fresh-clone installation routing change.

No open issues 🎉

What changed in this PR

This PR routes locked installs without bound deployment receipts through APM's full install pipeline, avoiding whole-project staging costs on fresh clones while preserving the fast path for existing installations.

Changes:

  • Decline the diff-apply path when receipts are absent and files or packages need deployment.
  • Add clone scenarios covering pipeline selection, parity, and write-free fallback.
  • Document the routing change and add a changelog entry.
File Description
tests/​lifecycle/​scenarios/​test_engine_parity.py Adds full-pipeline assertions for clones without bound receipts.
tests/​lifecycle/​scenarios/​_engine_parity.py Adds clone fixtures, decline cases, and receipt-path normalization.
src/​apm_cli/​install/​diff_apply.py Falls back before staging when deployment receipts are absent.
docs/​src/​content/​docs/​reference/​environment-variables.md Explains fresh-clone routing in the fast-path setting documentation.
changelog.d/​5414.fixed.md Records the fresh-clone install performance improvement.

Review effort: Balanced

@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

Closing: measured counterproductive on current main.

The motivating upper bound (fast path deleted: locked-warm W 0.885 / L 0.919) was measured on an older stack (e62f520). Since then, main's diff-apply engine has become far cheaper than the full pipeline for a whole-project diff, so routing fresh clones to the full pipeline is now a regression. The lifecycle cells and the differential (identical lockfile and project bytes for fast vs full) stay useful evidence for the v0.40 design doc. No re-scope is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants