Repository navigation
fix: restore dedicated copy thread pool to avoid CPU saturation - #1905
Merged
Merged
Conversation
The global rayon pool (2× CPU cores, tuned for network I/O in `wt list`) was being used for copy-ignored operations after #1901 removed the dedicated pool. This caused ~1000% CPU usage on copy-heavy operations that should be background work. Restores a 4-thread `LazyLock` pool internal to `copy_dir_recursive`. The public API is unchanged — no `in_copy_pool` wrapper needed since the pool entry happens inside `copy_dir_recursive` itself. Co-authored-by: Claude <[email protected]>
worktrunk-bot
approved these changes
Apr 4, 2026
This was referenced Apr 4, 2026
max-sixty
pushed a commit
that referenced
this pull request
Apr 4, 2026
## Problem CI on `main` failed on Windows with a stack overflow in `test_copy_ignored_many_directories_no_emfile`: ``` thread '<unknown>' (2316) has overflowed its stack ``` The rayon worker in the copy thread pool inherits the platform default stack size. On Linux/macOS this is ~8 MiB, but on Windows it is only ~2 MiB, which is not enough for concurrent `reflink_or_copy` work over 200 directories of ignored files. The failing run (23987711021) sits on a commit (#1910) that doesn't touch the copy path — this is a latent Windows-specific issue in the dedicated copy pool introduced in #1905. ## Solution Set an explicit 8 MiB `stack_size` on `COPY_POOL` so behaviour is consistent across platforms. This matches the Unix default and is a narrow, targeted fix at the place the problem is — the rayon pool used exclusively for `copy_dir_recursive`. ## Testing - `cargo test --test integration test_copy_ignored_many_directories_no_emfile` passes locally (Linux). - Full Windows CI re-run will exercise the large-scale concurrent copy path. --- Automated fix for [failed run](https://github.com/max-sixty/worktrunk/actions/runs/23987711021) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: worktrunk-bot <[email protected]> Co-authored-by: Claude <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#1901 removed the dedicated copy pool, so
copy_dir_recursivestarted using the global rayon pool (2× CPU cores, tuned for network I/O). This caused ~1000% CPU on copy-heavy operations likewt step copy-ignoredwith largetarget/directories.Restores a 4-thread
LazyLockpool internal tocopy_dir_recursive— no public API change needed. The pool is the same approach benchmarked in #1721 (performance peaks at 2–4 threads for disk I/O).