Commit 718c72b
committed
fix(#462): defer Hatch pyproject.toml/hatch.toml parsing out of configure()
Hatch::configure() previously parsed pyproject.toml and hatch.toml for every
workspace folder on every call. Combined with the configuration write lock,
this imposed Hatch's per-workspace TOML cost on every user — including the
majority who do not use Hatch.
Switch to the same lazy-parse pattern pet-poetry and pet-uv already use:
- configure() now records the workspace list and clears the parsed cache.
It performs no filesystem I/O and is O(workspace_count) PathBuf clones.
- Parsing happens lazily inside try_from()/find() on first access per
workspace, behind a single state mutex. Parses run outside the lock so
concurrent try_from() calls on other workspaces are not serialized by a
slow TOML read.
- Cache is invalidated on every configure() so TOML edits are picked up
on the next workspace/settings change (matching prior behaviour).
Result: non-Hatch workspaces never trigger a TOML read at all. Hatch
workspaces pay the parse cost once per workspace per process lifetime,
inside refresh — where the cost is amortized against the rest of
discovery and does not affect configure latency.
Tests:
- configure_does_no_toml_io_and_defers_parsing
- configure_clears_parsed_cache_so_toml_edits_are_picked_up
- try_from_lazily_populates_parsed_cache_on_first_call
- All existing Hatch tests continue to pass.1 parent 7f57b52 commit 718c72b
1 file changed
Lines changed: 226 additions & 84 deletions
0 commit comments