perf: bound concurrent file work with a worker pool#89
Conversation
Limit in-flight HandleFile goroutines to GOMAXPROCS*2 (clamped 4–32) so large directories do not exhaust file descriptors or memory. Fixes dolph#7
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7eeb76163a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| fr.errs.add(err) | ||
| continue | ||
| } | ||
| fr.acquireWorker() |
There was a problem hiding this comment.
Avoid holding worker slots across recursive walks
When the tree contains a path deeper than workerLimit() (or a directory with workerLimit() sibling directories that each need to descend), every directory goroutine keeps its slot until HandleFile returns, then WalkDir tries to acquire another slot for the child before any ancestor can release. At that point all slots can be held by goroutines blocked in recursive WalkDir, so the traversal hangs indefinitely instead of finishing.
Useful? React with 👍 / 👎.
Fixes #7
Made with Cursor