Skip to content

Reduce repeated memo frame discovery cost - #35

Draft
acecchini wants to merge 3 commits into
mainfrom
codex/memo-discovery-performance
Draft

Reduce repeated memo frame discovery cost#35
acecchini wants to merge 3 commits into
mainfrom
codex/memo-discovery-performance

Conversation

@acecchini

@acecchini acecchini commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Repeated shape checks currently read the local-variable mapping of every frame while searching for the live beartype checking scope. Reject impossible candidates using code-variable names first, then retain the existing live-value checks for decorated functions and DOOR checkers. This preserves memo ownership and lifetime without adding a cache.

On published beartype rc0, matched strict parameter/return calls improved from 19.546 to 16.955 microseconds on Python 3.10 and from 18.262 to 13.358 on 3.14 (about 13% and 27%). These are host measurements from 14 samples of 20,000 calls, with scenario order reversed; there is no timing gate or portable latency promise. The change is independent of the proposed upstream protocol in PR #34.

Validation: 1,094 CPU runtime tests, all eight four-checker harness cases, real commit/pre-push hooks, and a focused regression proving unrelated-frame locals are never accessed. Its combination with PR #34 passed 1,125 tests from normally installed archive consumers on both Python endpoints, plus minimal import checks. Five existing CPU skip records remain; no new CUDA evidence is claimed. The ExecPlan records source and artifact identities and matched comparison details.

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.

1 participant