Repository navigation
refactor: use static LazyLock pool for copy operations - #1894
Merged
Merged
Conversation
Replace per-call thread pool creation in copy_dir_recursive with a shared static COPY_POOL (LazyLock<ThreadPool>), following the established pattern used by HEAVY_OPS_SEMAPHORE and LLM_SEMAPHORE. The previous EMFILE fix used two coordinating pieces: a current_thread_index() check in copy_dir_recursive plus caller-side pool creation in step_copy_ignored. A single shared pool is simpler — nested install() calls are no-ops in rayon, so copy_dir_recursive works correctly both standalone and when called from in_copy_pool(). Co-Authored-By: Claude <[email protected]>
Resolve conflicts: keep LazyLock pool approach over per-call pool creation. Also tighten MAX_COPY_THREADS comment — remove unsubstantiated "benchmarked on APFS and ext4" claim. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
approved these changes
Apr 3, 2026
The value was empirically chosen via thread scaling benchmarks in #1721; reference the issue instead of vague "benchmarked on APFS and ext4". Co-Authored-By: Claude <[email protected]>
The #1721 benchmarks measured single-directory copies, not the shared pool workload. Note the distinction while explaining why the value still applies. Co-Authored-By: Claude <[email protected]>
The hardcoded 4-thread cap was benchmarked for single-directory copies (#1721) but the shared pool workload is different. Use rayon's default (num cores) until we benchmark the shared pool specifically. Co-Authored-By: Claude <[email protected]>
| /// spawning their own pool and exhausting OS file-descriptor limits on large | ||
| /// trees (EMFILE / "too many open files"). | ||
| /// Uses the shared copy pool (capped at 4 threads) to avoid SSD I/O contention | ||
| /// from the larger global rayon pool. |
Collaborator
There was a problem hiding this comment.
The pool no longer uses MAX_COPY_THREADS (4) — it uses rayon's default (num cores). This doc comment still says "capped at 4 threads".
Suggested change
| /// from the larger global rayon pool. | |
| /// Uses the shared copy pool to avoid contention from the larger global rayon | |
| /// pool. |
worktrunk-bot
added a commit
that referenced
this pull request
Apr 3, 2026
The pool was changed to use rayon's default (num cores) in #1894, but the docstring on `copy_dir_recursive` still said "capped at 4 threads". Co-Authored-By: Claude Opus 4.6 <[email protected]>
This was referenced Apr 3, 2026
max-sixty
added a commit
that referenced
this pull request
Apr 3, 2026
The separate `COPY_POOL` (`LazyLock<rayon::ThreadPool>`) isolated copy I/O from the global rayon pool. In practice there's no concurrent rayon work during copies, so the isolation added complexity without benefit. This removes the pool, `in_copy_pool()`, and the `copy_dir_recursive_inner` indirection — copy operations now use the global rayon pool directly. Follows #1894 which introduced the static pool. > _This was written by Claude Code on behalf of @max-sixty_ Co-authored-by: Claude <[email protected]>
natustx
pushed a commit
to natustx/worktrunk
that referenced
this pull request
May 1, 2026
) ## Summary - Add `-c system_prompt=''` to the Codex example command to skip the default system prompt, reducing tokens and latency for commit message generation Follow-up from max-sixty#1295 — @max-sixty asked about using empty system prompts for speed. **opencode**: Does not currently support disabling the system prompt. The system prompt is always injected, and even the plugin system has a safety fallback that restores the original if emptied. There are open feature requests ([max-sixty#1242](anomalyco/opencode#1242), [max-sixty#1894](anomalyco/opencode#1894), [#5005](anomalyco/opencode#5005)) but nothing available yet. **Codex**: Has an undocumented `system_prompt` config key that can be overridden via `-c system_prompt=''`. There are feature requests for dedicated `--system-prompt` flags ([#6023](openai/codex#6023), [#11588](openai/codex#11588)) but not yet merged. Co-authored-by: worktrunk-bot <[email protected]> Co-authored-by: Claude Opus 4.6 <[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.
Replace per-call thread pool creation in
copy_dir_recursivewith a shared staticCOPY_POOL(LazyLock<ThreadPool>), following the established pattern used byHEAVY_OPS_SEMAPHOREandLLM_SEMAPHORE.The EMFILE fix in #1864 used two coordinating pieces: a
current_thread_index()check incopy_dir_recursiveto detect ambient pool context, plus caller-side pool creation instep_copy_ignored. A single shared pool is simpler — nestedinstall()calls are no-ops in rayon, socopy_dir_recursiveworks correctly both standalone and when called fromin_copy_pool().Also removes the hardcoded 4-thread cap (
MAX_COPY_THREADS) in favor of rayon's default (num cores). The original benchmarks (#1721) tuned thread count for single-directory per-call pools, which is a different workload than the shared pool. Left a TODO to benchmark the shared pool specifically.Follow-up to #1864.