-
Notifications
You must be signed in to change notification settings - Fork 842
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
Avoid unnecessarily loading the hackage index #1892
Comments
Hmm, eventually we got to steal
The smaller cache mentioned above can help with this and also for $ stack show latest-version base
4.8.2.0 Also as another enhancement we can fork reading the cache as soon as we hit a command that might need it + using an MVar for |
Currently working on a fast serialization library - this is one of the applications we have in mind! https://www.fpcomplete.com/blog/2016/03/efficient-binary-serialization
True! In general we might be able to make things a little faster by running such blocking fetches in parallel. |
Excellent! |
No promises, but should be released soon particularly if it improves performance a bunch for the stack usecase. |
I have realized that one of the most frequent uses of the package caches is for lookups where we want to get the existing versions of a given package. That's an operation that isn't well supported by the current representation of the package caches which uses So I'd suggest changing that representation to |
stack could depend on |
@phadej: That's good to know! Thanks for a useful library! 👍 |
#2062 fixes that case. |
Note that we plan to switch away from using |
Sounds like that would be a good occasion to change the type of the caches too. Moving from |
Yes, and if so extend it to include preferred-versions from the index or should it be kept as a separate cache since not every package has preferred-versions? #1839 (will get back to this on the weekend) type PreferredVersions = VersionRange
Map PackageName
(Map Version PackageCache
,PreferredVersions -- with default to `AnyVersion` if prefered versions is absent
) -- from index for a package
-- or just use `Maybe VersionRange` depending which one serializes better
|
@luigy: I think the type you propose looks fine, except I'd strongly prefer a Regenerating the hackage index cache takes only 7 seconds on my rather slow computer so I don't think we should worry about that. |
Sounds good to me! Definitely a good thing to address after the upcoming release, as that's when usage of the new serialization library is going to be merged. Earlier I mentioned invalidating caches, but we will probably keep around some of the binary serialization code for the caches that we'd rather not invalidate. It'll re-encode them when reading an old cache file.
I think there's still more to do here - only loading it from the file if need be ( |
So, just to back up my impression that the call to The (chronologically) first call (actually the second in the file) is at line 6957 in the context of The second call (the one in So, I believe that if there's any way to avoid loading the package caches at all (at least for benign cases), we should look at |
Good point! I hadn't noticed that |
Cool! That cleared things up for me quite a bit! I did another profile run and now it's the |
True :) at the time I didn't want to think about it too hard. |
Moving over a note from the discussion in #2077 - we should make sure the plan construction code doesn't demand this in the case that extra-deps are already installed. (even if they are local packages) |
Loading the hackage is expensive, because the encoded index cache is 18Mb. On my fairly fast computer, it takes 0.3 seconds to decode it. Search
getPackageCaches
to find the spots it's used.There are two cases where loading the hackage currently happens unnecessarily:
In
loadSourceMap
, because the user might have specified a package target on the commandline which is not in the resolver. In this case, it uses the latest from hackage.In
constructPlan
, because plan construction errors get annotated with "latest applicable" versions.For both of these, loading the hackage index is only necessary under specific and abormal circumstances. However, currently this expensive operation is being done regardless of need.
It's also used in
resolveBuildPlan
, but that only seems to be used by the tests.The text was updated successfully, but these errors were encountered: