Skip to content

Cache StackConfig loads keyed on file identity#17

Open
nicoloesch wants to merge 1 commit into
mainfrom
16-cache-config
Open

Cache StackConfig loads keyed on file identity#17
nicoloesch wants to merge 1 commit into
mainfrom
16-cache-config

Conversation

@nicoloesch

Copy link
Copy Markdown
Collaborator

Summary

load_stack_config() re-read and re-parsed the config TOML from disk on every call, uncached, including from PackageConfigBase.get_config() and .get_engine(), which every consuming package goes through. Adds a process-local cache, keyed on (resolved_path, mtime_ns, size, $OA_ACTIVE_PROFILE, $OA_CONFIG_PATH), so any
file edit or relevant env var change invalidates automatically. No caller needs to invalidate anything for a normal read. Reuses the stat() call already made for the permission-mode check, so this costs zero extra I/O.

Every read, cached or not, still returns a fresh model_copy(deep=True), so the public contract is unchanged: callers get an independent, freely-mutable StackConfig exactly as before (verified against groundworkers, which
mutates the returned object directly). save_stack_config() and patch_active_profile() (the only two functions that write the file) clear the cache immediately after writing.

Checklist

  • Applied exactly one label (feature)
  • Tests pass locally (uv run pytest -q)
  • Lint passes (uv run ruff check .)

@nicoloesch nicoloesch added the feature New backwards-compatible functionality. MINOR: x.y+1.z label Jul 22, 2026
@nicoloesch
nicoloesch requested a review from gkennos July 22, 2026 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New backwards-compatible functionality. MINOR: x.y+1.z

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cache StackConfig loads to cut redundant disk reads

1 participant