Skip to content

Refactor Expression Optimizer - #9627

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

Refactor Expression Optimizer #9627
mhk197 wants to merge 3 commits into
developfrom
mk/bound-expression-optimizer

Conversation

@mhk197

@mhk197 mhk197 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a deterministic bottom-up optimizer for bound expressions
  • preserve expression dtypes across rewrites and reject invalid or unchanged replacements
  • organize built-in rewrites by binary, cast, structural, null, and conditional families

Changes

  • add a reusable BoundExpressionOptimizer with ordered rule registration and a rewrite-cycle budget
  • use a per-invocation OptimizationRun with small inline task and result stacks
  • rebuild parent nodes only when an optimized child changed
  • mirror the existing scalar-function simplify and reduce behaviors with bound-expression rules
  • document the optimizer state machine and every built-in rewrite with original and rewritten examples

Testing

  • cargo test -p vortex-array expr::optimizer
  • cargo test --doc -p vortex-array
  • cargo clippy --all-targets --all-features
  • cargo +nightly fmt --all -- --check
  • git diff --check

Signed-off-by: Matt Katz <mhkatz97@gmail.com>
@codspeed-hq

codspeed-hq Bot commented Aug 25, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 27.15%

⚠️ 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.

⚡ 3 improved benchmarks
✅ 490 untouched benchmarks
⏩ 1725 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime arrow_checked_add_u32_neon[16384] 20.4 µs 13.6 µs +49.86%
WallTime arrow_checked_add_u32_avx512[16384] 21.2 µs 17.7 µs +20.35%
WallTime words_gather_scalar_avx2[65536] 9.5 µs 8.3 µs +13.98%

Tip

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


Comparing mk/bound-expression-optimizer (314fb23) with develop (34a6912)2

Open in CodSpeed

Footnotes

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

  2. No successful run was found on develop (b240a50) during the generation of this report, so 34a6912 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Signed-off-by: Matt Katz <mhkatz97@gmail.com>
@mhk197 mhk197 changed the title Add bound expression rewrite optimizer Refactor Expression Optimizer Aug 26, 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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant