Skip to content

perf(config): parallel UserConfig + ProjectConfig load - #2543

Merged
max-sixty merged 1 commit into
mainfrom
parallel-config-loads
May 3, 2026
Merged

max-sixty merged 1 commit into
mainfrom
parallel-config-loads

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Summary

Adds LoadedConfigs::load(&repo) which loads user config and project config on scoped threads alongside a project_identifier cache warm-up. On a cold cache the wall-clock cost is the longest pole (~5ms) instead of the sum (~13ms sequential).

Cold-run trace on wt <alias> shows the three spans (user_config_load, project_config_load, project_identifier_warm) overlap on distinct thread ids; try_alias total drops from ~33ms to ~26ms.

Where it's used

LoadedConfigs::load(&repo) (need both configs):

  • try_alias / step_alias
  • wt config alias show / dry-run
  • wt hook show
  • resolve_copy_ignored_config
  • CommandEnv::for_action_branchless (downstream run_hook reads project from cache)
  • picker post-switch (downstream run_pre_switch_hooks reads project from cache)

UserConfig::load() (only user — unchanged):

  • wt step eval, for-each, prune, relocate
  • commit --show-prompt, show-squash-prompt
  • render_diagnostics

User-only sites deliberately skip the bundle so they don't read wt.toml or emit project-config deprecation/unknown-field warnings on commands that never consume project config.

Why a struct method, not a free helper

LoadedConfigs::load(&repo) mirrors the existing UserConfig::load() and ProjectConfig::load(&repo, ...) shape. The bundle (LoadedConfigs { user, project }) lives in the library crate (worktrunk::config) and is the canonical way to load both at once.

Trade-off (warning ordering)

Both UserConfig::load and ProjectConfig::load emit deprecation/unknown-field warnings to stderr inline. Running them on sibling threads makes warning order nondeterministic when both files have warnings. No existing test fixture exercises both at once; users with deprecated keys in both files may see varying order across runs. Acceptable trade-off for the parallel savings — buffer-and-replay is a separate refactor.

Test plan

  • cargo test --lib --bins (1682 pass)
  • cargo test --test integration (1589 pass)
  • pre-commit run --all-files (clean)
  • Cold-run trace verified: three spans overlap on distinct tids, load_aliases 37us (vs ~4.9ms before), try_alias ~29ms (vs ~33ms baseline)

🤖 Generated with Claude Code

Adds `LoadedConfigs::load(&repo)` which loads user config and project
config on scoped threads alongside a `project_identifier` cache warm-up.
On a cold cache the wall-clock cost is the longest pole (~5ms) instead
of the sum (~13ms sequential).

Wired into call sites that consume both configs: alias dispatch
(`try_alias`/`step_alias`), `wt config alias show`/`dry-run`,
`wt hook show`, `resolve_copy_ignored_config`,
`CommandEnv::for_action_branchless`, and the picker's post-switch path.
User-only sites (`wt step eval`, `for-each`, `prune`, `relocate`,
diagnostics) keep direct `UserConfig::load()` so they don't read
`wt.toml` or emit project-config warnings.

Cold-run trace on `wt <alias>` shows the three spans
(`user_config_load`, `project_config_load`, `project_identifier_warm`)
overlap on distinct thread ids; `try_alias` total drops from ~33ms to
~26ms.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@max-sixty
max-sixty merged commit 03f2045 into main May 3, 2026
26 checks passed
@max-sixty
max-sixty deleted the parallel-config-loads branch May 3, 2026 05:43
@max-sixty max-sixty mentioned this pull request May 3, 2026
max-sixty added a commit that referenced this pull request May 3, 2026
Cuts v0.47.0. Highlights:

- **Integration detection fix** across `wt list`, `wt remove`, `wt
merge`, `wt step prune` for the local/upstream-diverged case (#2507,
#2513, #2515).
- **Faster shell-command dispatch** (~10ms per invocation, 1.49× on
trivial aliases) via event-driven signal forwarding (#2537, #2538), plus
parallel config load (#2543) and merged cold-start prewarm rev-parse
(#2541).
- **`wt switch <number>` suggests `pr:N` / `mr:N`** instead of just
`--create` (#2516).
- **Library API breaking changes**: `RefSnapshot` cutover (#2528, #2530)
and the `for-each` direct-exec change (#2465). Full list in
`CHANGELOG.md`.

See `CHANGELOG.md` for the complete entry.

> _This was written by Claude Code on behalf of @max-sixty_

---------

Co-authored-by: Claude <noreply@anthropic.com>
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.

2 participants