You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The internals of cabal-install should allow project planning without writing things to file system.
This is high-level goal, and I don't think that it could be solved with single PR. But internal changes moving us closer to it will improve state of the codebase, which is very welcome!
We could modify the Rebuild monad. Currently it's the one that creates all the caches and triggers rebuilding in case any input changed. By providing configuration or a different interpreter we could just make it not cache things and rebuild all the time.
Pair that with allowing an empty, implicit project and we might be golden.
@alexbiehl yes, that what I have tried. Yet Rebuild monad is used very little, here and there. One clear subgoal is to make project planning contained completely in Rebuild monad.
One clear subgoal is to make project planning contained completely in Rebuild monad
Yes. Though a less invasive change might be to pass down the configuration/interpreter to the runRebuild calls. They are not too many. Maybe it even makes sense to tie the runRebuild to DistDirLayout; we are passing that around everywhere and usually the call looks like runRebuild distDirProjectRoot $ do ....
This is very interesting. I never liked the whole fake-package chicanery, and I think I still understand how that part of Cabal works pretty well, even if I haven't been up to my arms in it recently.
I had a few thinks about how this could be done, actually. Let me try to find my old notes!
It seems the slowness caused by writing to the filesystem makes cabal repl unusable to some users (e.g., haskell/cabal-userguide#1 (comment)). Therefore, given that we'd love to get rid of v1-, which they use as a substitute for cabal repl, I'd declare this set of tasks as high priority. Another solution to the slowness is cabal env, but would it not benefit from this change as well?
This change won't make cabal repl / script faster per se, it just means that instead of writing a dummy package on the file system and performing dep resolution etc on it, it should be possible to do that on the fly, without depending on a project. For it to be fast, we'd also need some way to consistently cache those build plans
I don't think running Cabal on a package is strictly necessary here. For repl at least, it should be enough to use an in-memory empty project, though maybe this needs a working extra-packages. Nevermind, I didn't know Cabal handled repl too
I think caching of fake-pkg and etc resulting from cabal repl invocations with basically no other changes could in itself probably eliminate most of the start-up time?
@gbaz well, yes, but I think it would be a good time to remove the fake-package as the script feature would also benefit from that.
Additionally, if cabal repl script.hs works (which I would hope would start to work once the fake-package trick isn't used anymore), then we can even have HLS support for it, which is my personal motivation :)
I've been investigating this and there seem to be two separate issues.
Removing the fake-project.cabal files used by global repl and scripts. This requires calling Cabal directly from cabal-install, but it's morally defensible because the build type is always Simple. A minor downside is that since we would no longer store the meta block in the fake-project.cabal file, we'd have to assume that all script changes could effect the meta block. A major upside is we'll be able to use the current directory as the project directory.
Don't write cache files during project planning for non-local targets. These are written to a temp dir and never read before being deleted, so it should be straight forward to simply pass a flag to not write them.
Activity
fendor commentedon Jul 20, 2020
Where is this fake-package used?
I know of:
phadej commentedon Jul 20, 2020
@fendor,
install,run,reploutside of project directories. About everywhere where we "solve", but don't have a local project.phadej commentedon Jul 20, 2020
#6885 is another (upcoming) example, where planning without relying (selectively!) on "real world" / "filesystem" inputs is desired.
alexbiehl commentedon Jul 20, 2020
We could modify the
Rebuildmonad. Currently it's the one that creates all the caches and triggers rebuilding in case any input changed. By providing configuration or a different interpreter we could just make it not cache things and rebuild all the time.Pair that with allowing an empty, implicit project and we might be golden.
phadej commentedon Jul 20, 2020
@alexbiehl yes, that what I have tried. Yet
Rebuildmonad is used very little, here and there. One clear subgoal is to make project planning contained completely inRebuildmonad.alexbiehl commentedon Jul 20, 2020
Yes. Though a less invasive change might be to pass down the configuration/interpreter to the runRebuild calls. They are not too many. Maybe it even makes sense to tie the runRebuild to DistDirLayout; we are passing that around everywhere and usually the call looks like
runRebuild distDirProjectRoot $ do ....phadej commentedon Jul 20, 2020
... except the very first
runRebuildisrunRebuild "".I also don't understand why we work with relative paths at all. That's another yak to shave. #6667 might help.
EDIT: I emphasize, this shouldn't be fixed in a "smallest possible diff" way, but in the "cleanest end result" way.
typedrat commentedon Jul 24, 2020
This is very interesting. I never liked the whole
fake-packagechicanery, and I think I still understand how that part of Cabal works pretty well, even if I haven't been up to my arms in it recently.I had a few thinks about how this could be done, actually. Let me try to find my old notes!
fgaz commentedon Jul 30, 2020
#6999 is a specific bug caused by fake-package
Mikolaj commentedon Jun 22, 2021
It seems the slowness caused by writing to the filesystem makes
cabal replunusable to some users (e.g., haskell/cabal-userguide#1 (comment)). Therefore, given that we'd love to get rid of v1-, which they use as a substitute forcabal repl, I'd declare this set of tasks as high priority. Another solution to the slowness iscabal env, but would it not benefit from this change as well?fgaz commentedon Jun 22, 2021
This change won't make
cabal repl/ script faster per se, it just means that instead of writing a dummy package on the file system and performing dep resolution etc on it, it should be possible to do that on the fly, without depending on a project. For it to be fast, we'd also need some way to consistently cache those build plansMikolaj commentedon Jun 22, 2021
Noted. Is there a ticket for the caching?
2 remaining items
Mikolaj commentedon Jun 22, 2021
Noted. There go my hopes. :)
fgaz commentedon Jun 22, 2021
I don't think running Cabal on a package is strictly necessary here. For repl at least, it should be enough to use an in-memory empty project, though maybe this needs a workingNevermind, I didn't knowextra-packages.Cabalhandledrepltoogbaz commentedon Jun 22, 2021
I think caching of fake-pkg and etc resulting from
cabal replinvocations with basically no other changes could in itself probably eliminate most of the start-up time?fendor commentedon Jun 22, 2021
@gbaz well, yes, but I think it would be a good time to remove the fake-package as the script feature would also benefit from that.
Additionally, if
cabal repl script.hsworks (which I would hope would start to work once the fake-package trick isn't used anymore), then we can even have HLS support for it, which is my personal motivation :)bacchanalia commentedon Feb 17, 2022
I've been investigating this and there seem to be two separate issues.
fake-project.cabalfiles used by global repl and scripts. This requires calling Cabal directly from cabal-install, but it's morally defensible because the build type is always Simple. A minor downside is that since we would no longer store the meta block in the fake-project.cabal file, we'd have to assume that all script changes could effect the meta block. A major upside is we'll be able to use the current directory as the project directory.If I missed anything please let me know.