Skip to content

Commit eaf490a

Browse files
committed
Add separate cache for getPkgConfigDb
Querying pkg-config for the version of every module can be a very expensive operation on some systems. This change adds a separate, per-project, cache for pkgConfigDB; reducing the cost from "every plan change" to "every pkg-config-db change per project". No input key is required since getPkgConfigDb already specifies the directories to monitor for changes. These are obtained from pkg-config itself as `pkg-config --variable pc_path pkg-config` as documented in pkg-config(1). A notice is presented to the user when refreshing the packagedb.
1 parent 156d8b2 commit eaf490a

File tree

140 files changed

+159
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+159
-4
lines changed

cabal-install/src/Distribution/Client/ProjectPlanning.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,7 @@ rebuildInstallPlan
638638
fileMonitorSourceHashes = newFileMonitorInCacheDir "source-hashes"
639639
fileMonitorElaboratedPlan = newFileMonitorInCacheDir "elaborated-plan"
640640
fileMonitorImprovedPlan = newFileMonitorInCacheDir "improved-plan"
641+
fileMonitorPkgConfigDb = newFileMonitorInCacheDir "pkg-config-db"
641642

642643
newFileMonitorInCacheDir :: Eq a => FilePath -> FileMonitor a b
643644
newFileMonitorInCacheDir = newFileMonitor . distProjectCacheFile
@@ -725,7 +726,11 @@ rebuildInstallPlan
725726
withRepoCtx
726727
(solverSettingIndexState solverSettings)
727728
(solverSettingActiveRepos solverSettings)
728-
pkgConfigDB <- getPkgConfigDb verbosity progdb
729+
730+
pkgConfigDB <-
731+
rerunIfChanged verbosity fileMonitorPkgConfigDb () $ do
732+
liftIO $ notice verbosity "Querying pkg-config database..."
733+
getPkgConfigDb verbosity progdb
729734

730735
-- TODO: [code cleanup] it'd be better if the Compiler contained the
731736
-- ConfiguredPrograms that it needs, rather than relying on the progdb

cabal-testsuite/PackageTests/Backpack/Includes2/cabal-external-target.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# cabal v2-build
2+
Querying pkg-config database...
23
Resolving dependencies...
34
Build profile: -w ghc-<GHCVER> -O1
45
In order, the following will be built:

cabal-testsuite/PackageTests/Backpack/Includes2/cabal-external.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# cabal v2-build
2+
Querying pkg-config database...
23
Resolving dependencies...
34
Build profile: -w ghc-<GHCVER> -O1
45
In order, the following will be built:

cabal-testsuite/PackageTests/Backpack/Includes2/cabal-internal-target.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# cabal v2-build
2+
Querying pkg-config database...
23
Resolving dependencies...
34
Build profile: -w ghc-<GHCVER> -O1
45
In order, the following will be built:

cabal-testsuite/PackageTests/Backpack/Includes2/cabal-internal.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# cabal v2-build
2+
Querying pkg-config database...
23
Resolving dependencies...
34
Build profile: -w ghc-<GHCVER> -O1
45
In order, the following will be built:

cabal-testsuite/PackageTests/Backpack/Includes3/cabal-external.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# cabal v2-build
2+
Querying pkg-config database...
23
Resolving dependencies...
34
Build profile: -w ghc-<GHCVER> -O1
45
In order, the following will be built:

cabal-testsuite/PackageTests/Backpack/Includes3/cabal-internal.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# cabal v2-build
2+
Querying pkg-config database...
23
Resolving dependencies...
34
Build profile: -w ghc-<GHCVER> -O1
45
In order, the following will be built:
@@ -18,8 +19,7 @@ Configuring library 'indef' instantiated with
1819
Data.Map = containers-<VERSION>:Data.Map
1920
for Includes3-0.1.0.0...
2021
Preprocessing library 'indef' for Includes3-0.1.0.0...
21-
Building library 'indef' instantiated with
22-
Data.Map = containers-<VERSION>:Data.Map
22+
Building library 'indef' instantiated with Data.Map = containers-<VERSION>:Data.Map
2323
for Includes3-0.1.0.0...
2424
Configuring executable 'exe' for Includes3-0.1.0.0...
2525
Preprocessing executable 'exe' for Includes3-0.1.0.0...

cabal-testsuite/PackageTests/Backpack/Includes3/cabal-repo.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# cabal v2-update
22
Downloading the latest package list from test-local-repo
33
# cabal v2-build
4+
Querying pkg-config database...
45
Resolving dependencies...
56
Build profile: -w ghc-<GHCVER> -O1
67
In order, the following will be built:

cabal-testsuite/PackageTests/Backpack/Reexport2/cabal.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# cabal v2-build
2+
Querying pkg-config database...
23
Resolving dependencies...
34
Error:
45
Problem with module re-exports:

cabal-testsuite/PackageTests/Backpack/T6385/cabal.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# cabal v2-update
22
Downloading the latest package list from test-local-repo
33
# cabal v2-build
4+
Querying pkg-config database...
45
Resolving dependencies...
56
Build profile: -w ghc-<GHCVER> -O1
67
In order, the following will be built:

0 commit comments

Comments
 (0)