Skip to content

Reuse flat scope plans when assertions preserve local order - #1321

Merged
charliermarsh merged 1 commit into
mainfrom
charlie/codex-flat-scope-order-main-20261017
Oct 17, 2026
Merged

charliermarsh merged 1 commit into
mainfrom
charlie/codex-flat-scope-order-main-20261017

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

We reuse flat function inputs during optimized compilation when removing assertions cannot change local ordering. We record whether each name first occurs inside an assertion without growing the stored name entries, retaining the existing collector when bound-name order or private aliases need it.

Matched Python 3.15 O2 profiles use about 0.26% fewer instructions for Mypy and 3.57% fewer for SymPy. Mypy improves by 0.28% at Python 3.13 O1; the O0 controls increase by about 0.04%. All measured outputs are byte-identical.

The 177-case instruction geometric mean improves by 0.09%, with individual changes from -13.23% to +2.78%. The largest regression is the O2 annotation microbenchmark. Native peak RSS falls about 1.45% for Mypy and increases about 0.3 MiB for SymPy; timing is noisy, so we make no native speed claim.

CodSpeed reports about 13% higher efficiency on the O1 and O2 large-dataset benchmarks, with the other 175 measured cases unchanged. It flags significant system time in the O1 async microbenchmark.

Full compatibility validation passes for Python 3.12 through 3.15 at all optimization levels, with unchanged results.

@codspeed

codspeed Bot commented Oct 17, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 13.21%

⚠️ 1 benchmark spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

⚡ 2 improved benchmarks
✅ 175 untouched benchmarks
⏩ 7 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ large_dataset 14 ms 12.3 ms +13.24%
⚡ large_dataset 14 ms 12.4 ms +13.19%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing charlie/codex-flat-scope-order-main-20261017 (72ea685) with main (2ecbc63)

Open in CodSpeed

Footnotes

  1. 7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@charliermarsh
charliermarsh marked this pull request as ready for review October 17, 2026 21:50
@charliermarsh
charliermarsh merged commit 0762f52 into main Oct 17, 2026
14 checks passed
@charliermarsh
charliermarsh deleted the charlie/codex-flat-scope-order-main-20261017 branch October 17, 2026 21:51
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