-
-
Notifications
You must be signed in to change notification settings - Fork 54
Improve finding cabal files #586
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
Conversation
In an unlikely event of several Cabal file in the same folder Stan currently chooses to return the first of them, but inadverently forgets to prepend a directory name. Merging (x : _xs) case with [cabalFile] has a nice side effect of making the search a bit faster: previous version of the code would necessarily scan the entire folder looking for the second Cabal file (because if it is to be found, outcomes will be different), but now we shall stop after finding the first one. Related to haskell/haskell-language-server#4515
.git folder can contain a maze of thousands of subfolders, this is definitely not a place to look for Cabal files. Related to haskell/haskell-language-server#4515
Use "directory-ospath-streaming: Stream directory entries in constant memory in vanilla IO", for searching files. Should have a lower memory usage than both the other implementations (original with OsPath/FilePath)
|
Seems like CI can't find the right version of a dependency. EDIT: It looks like it works only on 9.6 and above. |
|
Regarding the heap profiles, looks like the streaming version is quicker but uses the same amount of memory. Is that right? |
The problem seems to be that versions lower 9.6 use @tomjaguarpaw would it be fine to add CPP for <9.6 with the original
More or less the same, yes, the Detailed view doesn't show much information for the original OsPath version, but from the Heap Profile, the maximum allocation seems to be 10MB smaller with the streaming version. |
|
I think you can use the same strategy as here to use |
Maybe I'm missing something, but I don't think that it will be a very good solution (or even possible): If we implement (48f98ad) for ghc<9.6, we need:
I also did a quick look into supporting
|
Given that HLS is dropping GHC < 9.6 soon (haskell/haskell-language-server#4567), this might be not that bad?..
Yeah, this is unlikely to be a realistic goal. |
9d27258 to
5c689a2
Compare
5c689a2 to
dc502bf
Compare
stan.cabal
Outdated
| , trial ^>= 0.0.0.0 | ||
| , trial-optparse-applicative ^>= 0.0.0.0 | ||
| , trial-tomland ^>= 0.0.0.0 | ||
| if impl(ghc >= 9.6) |
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.
It's more flexible to introduce an automatic Cabal flag, True by default. When building with GHC < 9.6 (or when available versions of filepath are constrained by other components of build plan) Cabal solver will automatically flip it. Also easier to coerce Stack to build by simply flipping the flag in stack.yaml.
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.
I've updated the branch, Is the new version what you had in mind?
baf7c23 to
0ef1041
Compare
|
Please let me know when you've got something you're happy with and I'll take a look. |
dde851e to
defc920
Compare
Bodigrim
left a comment
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.
LGTM
defc920 to
dd78450
Compare
|
@tomjaguarpaw I think its fine to check now! |
|
Thanks for this. The implementation looks fine to me, so let's merge. I'm still confused about the graph in #586 (comment) though. Is this the heap profile for all of HLS? Or just for finding cabal files? (I hope the former because if the latter then it seems bizarre we're using 380 MB to find some cabal files.) |
Oh, sorry for the confusion. All the graphs I've posted are from HLS. In the original profiling (haskell/haskell-language-server#4515 (comment)) the leaked FilePath memory seemed to amount to about ~200MB. |
|
Thanks, makes sense. I thought that's what it had to be from the context. |
|
I'll need to do a release that incorporates this. Feel free to poke me if it doesn't appear soon. |
|
@tomjaguarpaw just a gentle ping ;) |
|
Thanks for the ping, let's track the release at #588 |
|
OK, released as: https://hackage.haskell.org/package/stan-0.2.1.0 |
Fixed by: kowainik/stan#586 Released in stan-0.2.1.0
Fixed by: kowainik/stan#586 Released in stan-0.2.1.0
- Fixed by: kowainik/stan#586 - Released in stan-0.2.1.0
- Fixed by: kowainik/stan#586 - Released in stan-0.2.1.0
- Fixed by: kowainik/stan#586 - Released in stan-0.2.1.0
- Fixed by: kowainik/stan#586 - Released in stan-0.2.1.0
- Fixed by: kowainik/stan#586 - Released in stan-0.2.1.0
- Fixed by: kowainik/stan#586 - Released in stan-0.2.1.0
Should fix haskell/haskell-language-server#4515 (comment)
I did a quick benchmark to try out the suggestion to use directory-ospath-streaming, with this results:
and this code:
`bench/Main.hs`
{-# LANGUAGE QuasiQuotes #-} module Main (main) where import Criterion.Main import Stan.Cabal (findCabalFiles, findCabalFilesStreaming, findCabalFilesFilePath) import System.Directory.OsPath (setCurrentDirectory) import System.OsPath (osp) main :: IO () main = do setCurrentDirectory [osp|../haskell-language-server/|] -- here i have the extra 100,000 files + hls defaultMain [ bgroup "findCabalFiles" [ bench "streaming" $ nfIO findCabalFilesStreaming, bench "original ospath" $ nfIO findCabalFiles, bench "original filepath" $ nfIO findCabalFilesFilePath ] ]`src/Stan/Cabal.hs`
And here is a comparison of the memory usage of the streaming implementation (right) vs. the ospath implementation (left) I posted on the other issue.