perf: populate walk cache in background (#2161)
Is there any reason to block waiting on this? We can most likely start
`visit()`ing directories in parallel while the cache population is done
async in the background...
Normally the cache population will always be a step (or many steps)
ahead of `visit()` and this change should only make the 2 traversals
overlap but introduce no change to who fills the cache or what order it
is filled. The only scenario I can think of where `populateCache()`
would no longer be the first to fill the cache would be if a language
callback invokes `GetDirInfo`?
**What type of PR is this?**
Other
**What package or component does this PR mostly affect?**
all
**What does this PR do? Why is it needed?**
**Which issues(s) does this PR fix?**
**Other notes for review**
diff --git a/walk/walk.go b/walk/walk.go
index fc3682f..4fd1bbb 100644
--- a/walk/walk.go
+++ b/walk/walk.go
@@ -379,7 +379,8 @@
relsToVisitSeen: make(map[string]struct{}),
}
- w.populateCache()
+ // Asynchronously populate the walker cache in the background.
+ go w.populateCache()
return w, nil
}