[perf] FillNarInfoCache during nix profile's pendingPackagesForInstallation #1528
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.
Summary
@Lagoja has a healthy number of
devbox global
packages. This exposed thatdevbox add <package>
had a perf regression for him:See the
syncPackagesToProfile
taking 31 seconds!After re-running with
--trace
, he got thetrace.out
file at: https://gist.github.com/savil/f6abd6a3adc8e7c92d1d3fd9ecbb93d7Opening with

go tool trace -http=localhost:6060 trace.out
shows:This reveals that we're doing 15 seconds of http requests.
The new codepath does a HEAD request to verify that the binary is still cached in the nix binary cache. The problem is that it does it serially in a for-loop for each package.
Fix
We have a function
FillNarInfoCache
that spawns goroutines to do it concurrently. This should speed up the time.How was it tested?
I was able to do
devbox global add procs
as a sanity check.