don't repeatedly resolve common usage paths #6123
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For some large packages in our project
getPackageFiles
has always quite a long time to complete, but it seems much worse in 9.4.x. (~7.5 seconds on my machine with stack 2.11 and ghc 9.4.5). Profiling showed it spent most of its time checking the the files fromusages
in.hi
files existed.When I checked what paths it was checking and how often I found that every
.hi
file mentioned many.so
files (~150) and each of these files was being checked it existed for each.hi
file.This change attempts to collect up known resolution mappings whilst walking the
.hi
files so the resolution effort doesn't get repeated.This takes our slowest
getPackageFiles
call down to ~3.6 seconds with the profile now showing the cost is mostly parsing the.hi
files.I've included before and after profile results where this was basically
stack test --file-watch --watch-all
on an already build project to get to the point where it's ready to build new changes.before: note the wide sections calling forgivingResolveFile
after: those wide sections are now gone
the profiles also show stack does all the
getPackageFiles
work twice which isn't ideal but i haven't looked into yet 👀