Skip to content

Commit

Permalink
fix: sync slow issue caused by unnecessary traversals
Browse files Browse the repository at this point in the history
  • Loading branch information
ericzzzzzzz committed Nov 8, 2023
1 parent 6071a3f commit 900d273
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/skaffold/docker/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ func getDependencies(ctx context.Context, workspace string, dockerfilePath strin
}

excludes, err := readDockerignore(workspace, absDockerfilePath)
fmt.Println("ignore....")
fmt.Println(excludes)
if err != nil {
return nil, fmt.Errorf("reading .dockerignore: %w", err)
}
Expand All @@ -144,6 +146,8 @@ func getDependencies(ctx context.Context, workspace string, dockerfilePath strin
}

files, err := WalkWorkspace(workspace, excludes, deps)
fmt.Println("monitored")
fmt.Println(files)
if err != nil {
return nil, fmt.Errorf("walking workspace: %w", err)
}
Expand Down Expand Up @@ -260,6 +264,10 @@ func WalkWorkspace(workspace string, excludes, deps []string) (map[string]bool,
if err != nil {
return false, err
}
// see the comment on walk.Do
if info.IsDir() && ignored {
return false, filepath.SkipDir
}
return !ignored, nil
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/skaffold/docker/syncmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ func walkWorkspaceWithDestinations(workspace string, excludes []string, fts []Fr
if err != nil {
return false, err
}
// see the comment on walk.Do
if ignored {
return false, filepath.SkipDir
}

return !ignored, nil
}
Expand Down

0 comments on commit 900d273

Please sign in to comment.