forked from haskell/cabal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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". The cache key is composed by the pkg-config configured program and the list of directories reported by pkg-config's pc_path variable.
- Loading branch information
1 parent
1c00507
commit ad13fcf
Showing
11 changed files
with
128 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module P where |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# cabal v2-build | ||
# cabal v2-build | ||
# cabal v2-build | ||
# cabal v2-build | ||
# cabal v2-build | ||
# cabal v2-build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
packages: . |
35 changes: 35 additions & 0 deletions
35
cabal-testsuite/PackageTests/MonitorPkgConfig/cabal.test.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import Distribution.Compat.Environment (setEnv) | ||
import System.Directory (copyFile, createDirectoryIfMissing, removeDirectoryRecursive) | ||
import Test.Cabal.Prelude | ||
|
||
main = cabalTest $ do | ||
env <- getTestEnv | ||
|
||
cabal' "v2-build" ["--dry-run", "p", "-v2"] | ||
>>= assertOutputContains "Querying pkg-config database..." | ||
|
||
cabal' "v2-build" ["--dry-run", "p", "-v2"] | ||
>>= assertOutputDoesNotContain "Querying pkg-config database..." | ||
|
||
-- Check that changing PKG_CONFIG_PATH invalidates the cache | ||
|
||
let pkgConfigPath = testWorkDir env </> "pkgconfig" | ||
liftIO $ do | ||
createDirectoryIfMissing True pkgConfigPath | ||
setEnv "PKG_CONFIG_PATH" pkgConfigPath | ||
|
||
cabal' "v2-build" ["--dry-run", "p", "-v2"] | ||
>>= assertOutputContains "Querying pkg-config database..." | ||
|
||
cabal' "v2-build" ["--dry-run", "p", "-v2"] | ||
>>= assertOutputDoesNotContain "Querying pkg-config database..." | ||
|
||
-- Check that changing a file in PKG_CONFIG_PATH invalidates the cache | ||
|
||
liftIO $ copyFile (testCurrentDir env </> "test.pc") (pkgConfigPath </> "test.pc") | ||
|
||
cabal' "v2-build" ["--dry-run", "p", "-v2"] | ||
>>= assertOutputContains "Querying pkg-config database..." | ||
|
||
cabal' "v2-build" ["--dry-run", "p", "-v2"] | ||
>>= assertOutputDoesNotContain "Querying pkg-config database..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: p | ||
version: 1.0 | ||
license: BSD3 | ||
author: Somebody | ||
maintainer: [email protected] | ||
build-type: Simple | ||
cabal-version: >=1.10 | ||
|
||
library | ||
exposed-modules: P | ||
build-depends: base | ||
default-language: Haskell2010 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Name: test | ||
Version: 0 | ||
Description: a test .pc file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
synopsis: Add separate cache for getPkgConfigDb | ||
packages: cabal-install | ||
prs: #9422 | ||
issues: #8930 | ||
|
||
description: { | ||
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". A notice is also presented to the user when refreshing the | ||
packagedb. | ||
} |