Visitar URL original
Drop elabConfiguredPrograms from the elaborated plan by PaleRoses · Pull Request #12500 · haskell/cabal · GitHub
Skip to content

Drop elabConfiguredPrograms from the elaborated plan - #12500

Open
PaleRoses wants to merge 6 commits into
haskell:masterfrom
PaleRoses:program-cache-fingerprints
Open

PaleRoses wants to merge 6 commits into
haskell:masterfrom
PaleRoses:program-cache-fingerprints

Conversation

@PaleRoses

@PaleRoses PaleRoses commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

This removes elabConfiguredPrograms from each elaborated component. Nothing read it; it was part of the configure cache key. Each component now keeps one hash of the list, computed once per project, and the records themselves stay in the shared ProgramDb.

On #12463, Andrea traced the extra copies to #11768 and suggested stripping the field as programDbSignature does. I hashed the complete records instead: #10817 added the field for #2015 so that a PATH change reconfigures, and programDbSignature drops PATH.

Follow-up to #12464; applies with or without it.

On HLS at bc2bbb8e, using the method from #12464, the second dry run of ten order-balanced rounds:

Version improved-plan Median second dry-run Min–max
3.16.1.0 22.44 MB 0.556 s 0.541–0.596 s
PR base 538d465eb 59.85 MB 1.245 s 1.153–1.492 s
#12464 00d86feb5 32.21 MB 0.998 s 0.890–1.156 s
This PR eb9d0af60 50.68 MB 0.852 s 0.820–0.898 s
#12464 + this PR 23.04 MB 0.483 s 0.445–0.545 s

With #12464 the plan is within 3% of 3.16.

AI disclosure: written by Codex and Claude Code with Opus 5.5, following the review on #12464.


QA Notes

Build a package twice; the second build is up to date. Point --with-haddock at a script that prints a version, then edit cabal.project; the next build is still up to date. Change the version the script prints and edit cabal.project again; the next build reconfigures. Changing only the version leaves the build up to date, at the base too, because nothing monitors the tool. ConfiguredProgramCache covers this.

PaleRoses and others added 3 commits November 3, 2026 21:20
Keep the configured program database shared and fingerprint its complete
records once per project for per-component cache invalidation.

Cover PATH/REPL changes and a tool version change at a fixed path.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PathRecomp already checks that a PATH change reaches the REPL. Keep the
checks the fingerprint adds: a tool version change at a fixed path
reconfigures, and elaborating again with the same programs does not.
Use a checked-in package instead of writing it from the script.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PaleRoses
PaleRoses force-pushed the program-cache-fingerprints branch from 0fdb3c2 to eb9d0af Compare November 4, 2026 05:35
@PaleRoses
PaleRoses marked this pull request as ready for review November 4, 2026 07:38
The haddock names the shared program database the fingerprint stands for
and why it lives in the component: that record is the configure cache key.
The test's comments say what it checks and what PathRecomp covers, and why
editing cabal.project is what makes the plan elaborate again.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@ulysses4ever ulysses4ever left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, this looks right to me. One comment inline on the test, and two on the description.

What I checked:

  • The field had one job: cf4083b (#2015) added it so that the cache/config key changes when PATH does, which PathRecomp tests. Nothing reads it, and the key is compared with == (normaliseConfiguredPackage only touches elabProgramArgs), so a hash of the Binary encoding notices the same changes. It is computed once, in the where of elaborateInstallPlan.

  • The complete records are needed. Hashing programDbSignature compilerProgDb instead makes PathRecomp fail, and clearing every programVersion makes ConfiguredProgramCache fail; each test passes when only the other one's part is broken, so the new test isn't redundant. It also passes at the base, as it should for a change that keeps the behaviour.

  • It merges cleanly with #12464, and the merge passes ConfiguredProgramCache, PathRecomp and T12463.

  • On the #12463 repro (40 public sublibraries, 16 flags; GHC 9.10.3 on Linux, in a nix shell whose PATH has 43 entries), a no-op cabal build all, five runs each:

    improved-plan cache/config (42 files) no-op
    base 0687f8d2f 32.6 MB 16.4 MB 0.82–0.84 s
    this PR 30.2 MB 15.2 MB 0.56–0.57 s
    #12464 + this PR 2.8 MB 1.4 MB 0.14 s

On the description:

  • It could say why PATH has to stay in the key: #2015 added the field so that a PATH change reconfigures, and programDbSignature drops PATH (it keeps the versions, so "keeping PATH and tool versions" reads as if it didn't).
  • The QA notes say that changing only the version the script prints makes the next build reconfigure. It doesn't, at the base or with this PR: nothing monitors the tool, so the next build is up to date until cabal.project changes too, as in the test.

The later commits fix up the first, whose message still mentions the PATH/REPL test that the third one removed, so I'd merge with squash (squash+merge me).

Comment on lines +23 to +24
-- The script is the monitored file, not the version file it reads, so
-- editing cabal.project is what makes cabal elaborate the plan again.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nothing monitors the script either: editing only the script, so that it prints a new version, leaves the next build up to date (at the base and with this PR). cabal probes the version when it elaborates the plan, and nothing monitors the programs that phaseElaboratePlan configures with configureAllKnownPrograms. That gap is older than this PR. Maybe:

Suggested change
-- The script is the monitored file, not the version file it reads, so
-- editing cabal.project is what makes cabal elaborate the plan again.
-- Nothing monitors the tool, so cabal probes its version again only when
-- it elaborates the plan again, which editing cabal.project makes it do.

The script is not monitored either; cabal probes the tool's version only
when it elaborates the plan again, which the cabal.project edit forces.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@PaleRoses

Copy link
Copy Markdown
Contributor Author

Thanks for checking all of that.

I applied your comment on the test in 26cfc11. The description now says why PATH stays in the key, and the QA notes say that the version change only reconfigures together with a cabal.project edit.

Squash sounds right to me.

, elabConfiguredProgramsHash :: HashValue
-- ^ Fingerprint of the configured programs in 'pkgConfigCompilerProgs'.
-- This record is the configure cache key, so the fingerprint keeps every
-- program's location, version, arguments and environment, @PATH@ included,

@sheaf sheaf Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The fact that PATH is copied into programs is a complete misdesign in my opinion (see #12481). So we should absolutely not enshrine that into a comment as if it was desired behaviour.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree; now the comment is more minimal.

@mergify mergify Bot added the 1️⃣ more approval needed Set by Mergify: has one of the two required approvals label Nov 10, 2026
The haddock listed what a configured program holds, PATH included, which
read as if copying PATH into the records were intended (see haskell#12481). It
now says only what the field is: a hash of the configured programs that
changes the configure cache key when one of them changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@PaleRoses PaleRoses mentioned this pull request Nov 11, 2026
5 of 6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-assisted 1️⃣ more approval needed Set by Mergify: has one of the two required approvals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants