Skip to content

Bind expressions before optimization - #9514

Draft
mhk197 wants to merge 3 commits into
developfrom
mk/bound-expression-optimize
Draft

Bind expressions before optimization#9514
mhk197 wants to merge 3 commits into
developfrom
mk/bound-expression-optimize

Conversation

@mhk197

@mhk197 mhk197 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Instead of optimizing expressions and then binding, first bind and then optimize.

There are many benefits to this, including:

  • We only optimize well-typed expression trees (we dont waste work on invalid trees that fail at execution time). Rewrites cannot obscure typing errors.
  • We no longer have multiple return_dtype walks that recurse through the entire expression tree, and we dont need an optimizer-owned dtype cache (SimplifyCache).
  • Few APIs and duplicate rules
  • Preparation for lambdas and variables. Variables must be typed before optimization. The optimizer can treat lambda scopes as opaque.
  • We can recursively optimize ONCE rather than incrementally calling expression.optimize on construction of every tree node.

@codspeed-hq

codspeed-hq Bot commented Aug 20, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 7.04%

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚡ 2 improved benchmarks
❌ 7 regressed benchmarks
✅ 1972 untouched benchmarks
⏩ 442 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation optimize_lookup_predicate[ids=1, shape=balanced_or] 47 µs 59.4 µs -20.91%
Simulation optimize_lookup_predicate[ids=64, shape=in_list] 45.2 µs 56.1 µs -19.5%
Simulation optimize_lookup_predicate[ids=128, shape=in_list] 45.4 µs 56.3 µs -19.44%
Simulation optimize_lookup_predicate[ids=256, shape=in_list] 46.5 µs 57.1 µs -18.57%
Simulation optimize_lookup_predicate[ids=192, shape=in_list] 46.2 µs 55.9 µs -17.36%
Simulation optimize_lookup_predicate[ids=16, shape=in_list] 45.5 µs 54.6 µs -16.74%
Simulation optimize_lookup_predicate[ids=16, shape=balanced_or] 88.1 µs 102.9 µs -14.35%
Simulation optimize_lookup_predicate[ids=1, shape=in_list] 151.3 µs 80.3 µs +88.42%
Simulation compress_fsst[(500, 64, 8)] 585.9 µs 524.3 µs +11.75%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing mk/bound-expression-optimize (c296e37) with develop (46a8d39)

Open in CodSpeed

Footnotes

  1. 442 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.

mhk197 added 2 commits August 20, 2026 21:39
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
@mhk197
mhk197 force-pushed the mk/bound-expression-optimize branch from b9734fa to 5e71312 Compare August 21, 2026 01:41
@mhk197 mhk197 added the changelog/chore A trivial change label Aug 21, 2026
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/chore A trivial change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant