Skip to content

perf: reuse configuration alias traversal results#124

Merged
dylan-isaac merged 1 commit into
mainfrom
gobbler-loop-shared-override-traversal
Jul 24, 2026
Merged

perf: reuse configuration alias traversal results#124
dylan-isaac merged 1 commit into
mainfrom
gobbler-loop-shared-override-traversal

Conversation

@dylan-isaac

Copy link
Copy Markdown
Contributor

Summary

  • cache replacement-closure results per active merge stack frame
  • preserve the parent frame's alias cache across completed sibling mapping merges
  • add scaling regressions for adjacent and interleaved aliases
  • release the bounded optimization as 0.2.32

Closes #123

Reproduction and root cause

A size-N non-empty acyclic payload shared by N override keys was traversed once per alias before the clone memo was consulted. The original probe recorded 130, 460, 1,720, and 6,640 element visits for N=10, 20, 40, and 80.

The first candidate cached scans only until a nested mapping merge changed the active projection map. Adversarial review reproduced the same quadratic work when payload aliases were interleaved with sibling mapping merges. The corrected implementation owns the cache per stack frame: a child receives a fresh cache, while its parent resumes with the cache valid for the restored parent projection.

The bounded after probe records 40, 80, 160, and 320 visits for N=10, 20, 40, and 80. The interleaved sibling-merge regression remains linear as well.

Scope and non-goals

This changes only deep-merge replacement-closure reuse for non-empty acyclic shared payloads. Existing identity, source isolation, recursive/path-local projection, tuple/list cycle, compact mapping DAG, and deep iterative semantics remain covered. It does not redesign the graph cloner or add a new performance guarantee for cyclic root-backreference graphs.

Verification

  • fresh uv sync --extra dev --extra docs
  • uv run gobbler --version → 0.2.32
  • uv run pytest tests/unit/test_config.py -q → 58 passed
  • uv run pytest tests/unit/ -q --tb=short → 768 passed
  • uv run pytest tests/integration/ -q -m integration --tb=short → 2 passed
  • uv run ruff format --check src/ tests/
  • uv run ruff check src/ tests/
  • uv run --extra docs mkdocs build --strict
  • git diff --check

Review

Round one primary and CI/release reviews passed. Graph review found the interleaved-sibling invalidation case; the single corrective edit added per-frame cache ownership and a regression. Round two primary and CI/release reviews passed. Round two graph review raised cyclic root-backreference complexity; independent adjudication classified it out of scope because #123's performance contract is explicitly acyclic while cyclic semantics remain preserved.

Risk and documentation

Risk is limited to cache lifetime in the iterative configuration merge. Each cache is scoped to exactly one stack frame and therefore one stable active-projection set. Both changelogs, package/CLI/queue versions, browser-extension metadata, and static version assertions are synchronized to 0.2.32.

@dylan-isaac

Copy link
Copy Markdown
Contributor Author

@codex review

Please review exact head 2ccea68f1963f4d64e9902cf43bd7cb489050574, including per-stack-frame cache validity, the interleaved alias/mapping regression, and the explicit acyclic performance scope from issue #123.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Unknown error
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dylan-isaac

Copy link
Copy Markdown
Contributor Author

@codex review

Retry after the connector returned an unknown error. Please review exact head 2ccea68f1963f4d64e9902cf43bd7cb489050574, including per-stack-frame cache validity, the interleaved alias/mapping regression, and issue #123's explicit acyclic performance scope.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Unknown error
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 2ccea68f19

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dylan-isaac
dylan-isaac merged commit 7976dc5 into main Jul 24, 2026
6 checks passed
@dylan-isaac
dylan-isaac deleted the gobbler-loop-shared-override-traversal branch July 24, 2026 16:42
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.

Optimize shared override alias traversal in deep merge

1 participant