-
Notifications
You must be signed in to change notification settings - Fork 12
Feature/cache miss reason #520
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
base: main
Are you sure you want to change the base?
Changes from all commits
e97f400
485296e
acff21a
12d6f9e
a175614
69dff83
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,4 @@ | |
| .tmp-earth-out* | ||
| .DS_Store | ||
| **/node_modules | ||
| dataflow.md | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -98,6 +98,11 @@ func (s *solver) buildMainMulti( | |||||||||||||||||||||
| return err | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| saveErr := s.logbusSM.SaveState(ctx) | ||||||||||||||||||||||
| if saveErr != nil { | ||||||||||||||||||||||
| console.Warnf("failed to save vertex state: %v", saveErr) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+101
to
+104
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| return nil | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -613,7 +613,7 @@ func (c *Converter) CopyArtifactLocal( | |
| return errors.Wrapf(err, "parse artifact name %s", artifactName) | ||
| } | ||
|
|
||
| prefix, cmdID, err := c.newVertexMeta(ctx, false, false, false, nil) | ||
| prefix, cmdID, err := c.newVertexMetaWithCopiedPaths(ctx, false, false, false, nil, []string{artifact.String()}) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -687,7 +687,7 @@ func (c *Converter) CopyArtifact( | |
| return errors.Wrapf(err, "parse artifact name %s", artifactName) | ||
| } | ||
|
|
||
| prefix, cmdID, err := c.newVertexMeta(ctx, false, false, false, nil) | ||
| prefix, cmdID, err := c.newVertexMetaWithCopiedPaths(ctx, false, false, false, nil, []string{artifact.String()}) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -755,7 +755,7 @@ func (c *Converter) CopyClassical( | |
|
|
||
| c.nonSaveCommand() | ||
|
|
||
| prefix, _, err := c.newVertexMeta(ctx, false, false, false, nil) | ||
| prefix, _, err := c.newVertexMetaWithCopiedPaths(ctx, false, false, false, nil, srcs) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -2333,7 +2333,7 @@ func (c *Converter) checkAutoSkip( | |
| return false, nil, err | ||
| } | ||
|
|
||
| targetHash, _, err := inputgraph.HashTarget(ctx, inputgraph.HashOpt{ | ||
| targetHash, hashStats, err := inputgraph.HashTarget(ctx, inputgraph.HashOpt{ | ||
| Target: target, | ||
| Console: c.opt.Console, | ||
| CI: c.opt.IsCI, | ||
|
|
@@ -2357,6 +2357,16 @@ func (c *Converter) checkAutoSkip( | |
| return true, nil, nil | ||
| } | ||
|
|
||
| // Cache miss: log the inputs that were hashed so the user can understand | ||
| // what will cause this target to be rebuilt. | ||
| if len(hashStats.HashLog) > 0 { | ||
| console.VerbosePrintf("cache miss for %s — hashed inputs:", target.String()) | ||
|
|
||
| for _, entry := range hashStats.HashLog { | ||
| console.VerbosePrintf(" %-16s %s", entry.Label, entry.Detail) | ||
| } | ||
| } | ||
|
|
||
| return exists, func() { | ||
| err := c.opt.BuildkitSkipper.Add(ctx, target.StringCanonical(), targetHash) | ||
| if err != nil { | ||
|
|
@@ -3237,6 +3247,26 @@ func (c *Converter) newVertexMeta( | |
| } | ||
| } | ||
|
|
||
| // Collect all active (non-builtin) args for cache-miss diagnostics. | ||
| // Builtins (prefixed with EARTH_ or EARTHLY_) are excluded to keep the | ||
| // vertex name compact and focused on user-controlled values. | ||
| activeArgs := make(map[string]string) | ||
|
|
||
| for _, arg := range c.varCollection.SortedVariables(variables.WithActive()) { | ||
| if strings.HasPrefix(arg, "EARTH_") || strings.HasPrefix(arg, "EARTHLY_") { | ||
| continue | ||
| } | ||
|
|
||
| v, ok := c.varCollection.Get(arg, variables.WithActive()) | ||
| if ok { | ||
| activeArgs[arg] = v | ||
| } | ||
| } | ||
|
|
||
| if len(activeArgs) == 0 { | ||
| activeArgs = nil | ||
| } | ||
|
|
||
| platform := c.platr.Materialize(c.platr.Current()) | ||
| platformStr := platform.String() | ||
| isNativePlatform := c.platr.PlatformEquals(platform, platutil.NativePlatform) | ||
|
|
@@ -3289,8 +3319,30 @@ func (c *Converter) newVertexMeta( | |
| Secrets: secrets, | ||
| Internal: internal, | ||
| Runner: c.opt.Runner, | ||
| ActiveArgs: activeArgs, | ||
| } | ||
|
|
||
| return vm.ToVertexPrefix(), cmdID, nil | ||
| } | ||
|
|
||
| // newVertexMetaWithCopiedPaths is like newVertexMeta but also records the | ||
| // source paths of a COPY operation for cache-miss diagnostics. | ||
| func (c *Converter) newVertexMetaWithCopiedPaths( | ||
| ctx context.Context, local, interactive, internal bool, secrets []string, copiedPaths []string, | ||
| ) (string, string, error) { | ||
| prefix, cmdID, err := c.newVertexMeta(ctx, local, interactive, internal, secrets) | ||
| if err != nil { | ||
| return "", "", err | ||
| } | ||
|
|
||
| if len(copiedPaths) == 0 { | ||
| return prefix, cmdID, nil | ||
| } | ||
|
|
||
| // Re-parse the encoded prefix, add CopiedPaths, re-encode. | ||
| vm, _ := vertexmeta.ParseFromVertexPrefix(prefix + " _") | ||
| vm.CopiedPaths = copiedPaths | ||
|
Comment on lines
+3342
to
+3344
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Performing a base64/JSON serialization and immediate deserialization round-trip via |
||
|
|
||
| return vm.ToVertexPrefix(), cmdID, nil | ||
| } | ||
|
|
||
|
|
||
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.
These lines appear to be leftover debug code and should be removed before merging.