-
Notifications
You must be signed in to change notification settings - Fork 184
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
[nix-cache] Prevent checking cache twice per package #2055
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why fetchNarInfoStatus
ended up calling twice. Did we end up getting different keys for the same installable?
internal/devpkg/narinfo_cache.go
Outdated
sysInfo, err := p.sysInfoIfExists() | ||
// let's be super safe to always avoid empty key. | ||
if err == nil && sysInfo != nil && len(sysInfo.DefaultOutputs()) > 0 { | ||
output = lo.Reduce( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do the default outputs needed to be sorted to make the key stable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation of DefaultOutputs
is pretty stable, but it doesn't hurt.
internal/devpkg/narinfo_cache.go
Outdated
output = lo.Reduce( | ||
sysInfo.DefaultOutputs(), | ||
func(acc string, o lock.Output, _ int) string { | ||
return acc + o.Name | ||
}, | ||
"", | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the lo.Reduce
be replaced by the following for easier-reading:
return strings.Join(sysInfo.DefaultOutputs(), ",")
?
It would also mean that the key matches the nix-installable-output format of <name>^<output>,<output>,...<output>
. It doesn't really need to do this but is ... aesthetically pleasing :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
outputs are not strings, but maybe if they have a String()
method this will work? will try
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it doesn't work.
yeah, we call it once per output and once for So for a given package with a single (default) output |
Summary
Fixes bug described here #2054
A better (but a bit more involved) solution is to parallelize by output. Currently we parallelize by meta-output (which includes
__default_output__
). This has two downsides:__default_output__
can be multiple outputs, in which case we don't parallelize them at all.__default_output__
is multiple outputs. (once as__default_output__
and once for each individual outout that forms part of defaults).How was it tested?