Skip to content

Build the installed package closure from the component's dependencies - #12641

Open
Lotion-3 wants to merge 1 commit into
haskell:masterfrom
Lotion-3:perf/installed-closure
Open

Lotion-3 wants to merge 1 commit into
haskell:masterfrom
Lotion-3:perf/installed-closure

Conversation

@Lotion-3

Copy link
Copy Markdown
Contributor

Addresses part of #12546.

toComponentLocalBuildInfos built a Graph of every installed package, unioned it with the component graph and took the closure. Only installed packages reachable from the components can be in that closure, so this looks them up by UnitId and builds the graph from those. Installed packages with the same UnitId as a component are skipped, since unionRight replaced them, and missing dependencies are still reported by Graph.broken.

The closure is the same, including its order, which PackageIndex.fromList depends on for instances of the same package. I compared the old and new code on 3,600 random installed-package graphs, with shared package names, shadowed keys and missing dependencies: the closure, the PackageIndex built from it and Graph.broken were identical in every case.

Time for this step, per component (synthetic package index, GHC 9.10.3, Windows 11):

Installed packages Closure size Before After
1,000 154 0.45 ms 0.10 ms
5,000 533 3.9 ms 0.75 ms
20,000 1,230 37 ms 3.4 ms

This doesn't touch the other costs in #12546: PackageIndex.fromList and dependencyInconsistencies still run on the closure for each component.

The Backpack, BuildDeps, InternalLibraries and ConfigureComponent tests pass, except Backpack/Includes2 and InternalLibraries/setup-gen-script, which fail the same way on master on my Windows machine.


Template B: This PR does not modify behaviour or interface

toComponentLocalBuildInfos built a graph of every installed package, unioned
it with the component graph and took the closure. Only installed packages
reachable from the components can be in that closure, so look those up by
UnitId and build the graph from them. The closure is unchanged.

Addresses haskell#12546.
@Lotion-3
Lotion-3 force-pushed the perf/installed-closure branch from a8bdcf2 to 1a3cba1 Compare November 21, 2026 06:15
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.

1 participant