Skip to content

perf: bound concurrent file work with a worker pool#58

Open
leno23 wants to merge 1 commit into
dolph:mainfrom
leno23:perf/bounded-workers-issue-7
Open

perf: bound concurrent file work with a worker pool#58
leno23 wants to merge 1 commit into
dolph:mainfrom
leno23:perf/bounded-workers-issue-7

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 17, 2026

Summary

  • Recurse into directories synchronously (depth-first, unchanged semantics).
  • Process regular files through a bounded worker pool (4–32 workers from GOMAXPROCS).
  • Avoid unbounded goroutine fan-out on large directories.

Test plan

  • go test ./...

Closes #7

Made with Cursor

Walk directories synchronously and run content rewrites plus renames
for regular files through a semaphore sized from GOMAXPROCS (4–32).

Closes dolph#7

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 68a5e9b616

ℹ️ 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".

Comment thread find_replace.go
}

func (fr *findReplace) acquireWorker() {
fr.workers <- struct{}{}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Guard against nil worker semaphore

Sending to fr.workers without initialization now blocks forever, so any findReplace created without workers (for example the existing BenchmarkNova initializer in find_replace_test.go) will hang when it reaches file processing. This regression was introduced by adding the semaphore field but relying on every call site to populate it; initializing lazily (or in a constructor) would avoid deadlocks for zero-value/legacy initializers.

Useful? React with 👍 / 👎.

Comment thread find_replace.go
var wg sync.WaitGroup
for _, entry := range files {
childFile := NewFile(filepath.Join(f.Path, entry.Name()))
if entry.IsDir() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Recurse using file info to include symlinked directories

Switching directory detection to entry.IsDir() changes traversal semantics for symlinked directories: those entries are now treated as regular files, so recursion never enters their targets and replacements are skipped in linked subtrees. The previous path (f.Info().IsDir()) followed symlinks via os.Stat, so this is a functional regression for repositories that include directory symlinks.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unbounded goroutine fan-out exhausts file descriptors and memory on large trees

1 participant