single packages.Load for NameForPackage #944
Closed
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.
This is one of the optimizations suggested in #918. The original suggestion was to load every package that needs to be loaded in a single packages.Load call. I ran into issues trying to implement that because packages.Load has flags that define how much data should be loaded. It turned out that if we load all data for all relevant packages, that actually slows things down. Instead, I batched the loads of packages for calls to NameForPackage.
I tested this change on top of all of #942 #941 #940.
This is what the timings looked like before this commit (in my private codebase):
After this commit:
build
andgenerate
time correspond to the two main parts of api/generate.go.load time
is the time spent in packages.Load for the purposes of NameForPackage. As you can see, the combined packages.Load call is moved from the Load phase into the Build phase but even though so many more packages are being loaded, it takes about as long as a single one of the later calls.I didn't see an improvement when this commit is applied without the others, but I didn't test it extensively by itself.
I need feeback on how NameForPackage is passed through the various structs and also on the name of the new struct.
Results when directly applied to master by itself:
before:
after:
I can't explain those results. There must be something weird with calling packages.Load multiple times on the same packages.
I have: