-
Notifications
You must be signed in to change notification settings - Fork 698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add separate cache for getPkgConfigDb #9422
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be worth adding a test that ran cabal twice and verified that the cached pkg-config
output is used the second time?
I think it would be, I am not sure whether we have anything similar already. I'll check. |
Not for caching, but there's a test that verifies that a package reinstall causes a warning IIRC. |
this looks excellent, thanks! |
6170fe3
to
eaf490a
Compare
Can you describe the cache invalidation strategy? Does the cache get invalidated when It would be good to add some tests testing the different invalidation mechanisms. |
Yes, I am relying on what
It obtains PKG_CONFIG_PATH and for monitors each directory for changes. As the comment says, it does not monitor each individual files. Perhaps it could be worth monitoring the result of
I agree, I am planning to write some. |
eaf490a
to
20acde7
Compare
I did some rework and added tests but one of the tests ( |
03e8346
to
89d3ee1
Compare
89d3ee1
to
0f81808
Compare
cabal-testsuite/PackageTests/Backpack/Includes2/cabal-external-target.out
Outdated
Show resolved
Hide resolved
74e96f0
to
9cf9a17
Compare
@mpickering do you think the tests are sufficient? I am checking the search path (for the pkg-config executable) and PKG_CONFIG_PATH. I don't think it is a perfect solution but it seems to be the approach taken elsewhere. |
9cf9a17
to
f97fb81
Compare
So from a Nix perspective, the thing that should force cache invalidation is that we have a different |
I did include the resolved pkg-config location in the key for a bit but eventually removed it because
The options I had were
@fgaz do you mean pkgconfig-depends? zlib (the haskell package) does not use pkg-config by default. Edit: well well, the program path would also be useless:
I don't think there is any cache to detect this. ( What's happening in @fgaz case is that while a success is cached, a failure is not; cabal cannot tell anything has changed so it keeps the previous result (and the rest of the build did not change either). |
Give the analysis above, I think this PR is complete. Nevertheless I would like to be sure there is a workaround for the situation that @fgaz describes above. |
I realised I didn't need any refactor after all! @fgaz could you give it another go? |
30e0252
to
725f3a3
Compare
@jasagredo does 3ae0488 look alright to you? I tried to follow what you did in #9527 |
🧐 |
the pkg-config executable is the same in all my shells. What changes is the non-standard variable I think there's nothing we can do here unfortunately. @andreabedini I tried again and the result is identical |
oh, in my tests the path to the wrapper was changing :-/ |
Right, and in the nix world this is all detectable because the derivation that produces the Some ideas:
EDIT: since it's per-project the damage seems less bad, but it maybe forces Nix users to |
I don't have much time to dedicate to this so I would appreciate if anybody could help pushing this over the line. It's complete but I had issues with the tests. |
547f70c
to
5b71c97
Compare
So I tried to run this on Windows again. Some remarks:
|
I got this error on my machine:
|
^ This was fixed in #9915. Needs a rebase |
All tests pass in my machine if using:
|
FTR: I'm using this to undo-redo the symlinks on Windows |
5b71c97
to
331f3cd
Compare
I did the rebase but I some tests failed locally. Perhaps the code has bit-rotted a bit. |
You will have to add a step somewhere to install pkg-config on Windows:
|
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.
ac9fab2
to
5749297
Compare
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.
Closes #8930 and subsumes #9360.
changelog entry to follow