Skip to content

Drop the fallible dtype lookup from stats rewrites - #9652

Closed
robert3005 wants to merge 1 commit into
developfrom
perf/skip-recursive-predicate-revalidation
Closed

Drop the fallible dtype lookup from stats rewrites#9652
robert3005 wants to merge 1 commit into
developfrom
perf/skip-recursive-predicate-revalidation

Conversation

@robert3005

Copy link
Copy Markdown
Contributor

What

The tracked work item asked to replace a recursive tree-walking validation in the stats
rewrite with the dtype stored on each BoundExpression node. That walk is already gone:
#9192 replaced expr.return_dtype(scope) with the field lookup, and it is on develop.

What survived is the wrapper around it. StatsRewriteCtx::return_dtype dates from when the
context held a scope and the lookup walked the subtree. Today it clones the dtype and wraps
an infallible field read in a VortexResult, which hides from rule authors that reading a
type is free.

This removes it. Call sites read BoundExpression::dtype directly.

With the last fallible dtype lookup gone, two helpers simplify:

  • geometry_and_constant no longer needs the rewrite context or the VortexResult wrapper,
    so it returns a plain Option.
  • non_nan_check no longer needs the context at all.

Guarantees

Acceptance and rejection of predicates are unchanged:

  • ensure_predicate matches DType::Bool(_) on the same value it did before.
  • The .ok()? in stat_expr guarded an error the lookup could not produce.

Checks

  • cargo nextest run -p vortex-array -p vortex-spatial -p vortex-layout -p vortex-file
    4041 passed, 1 skipped
  • cargo test --doc -p vortex-array — pass
  • cargo clippy --all-targets --all-features — clean
  • cargo +nightly fmt --all

🤖 Generated with Claude Code

`BoundExpression` carries a dtype on every node, so a rewrite rule that
needs a type does a field read. `StatsRewriteCtx::return_dtype` stayed
behind from when the context held a scope and the lookup walked the
subtree. It now clones the dtype and wraps an infallible read in a
`VortexResult`, which hides that fact from rule authors.

Remove it and read `BoundExpression::dtype` at the call sites. With the
last fallible lookup gone, `geometry_and_constant` no longer needs the
rewrite context or a result wrapper, and `non_nan_check` no longer needs
the context at all.

Acceptance and rejection of predicates are unchanged: `ensure_predicate`
matches the same dtype, and the `.ok()?` in `stat_expr` guarded an error
that could not occur.

Signed-off-by: "Robert Kruszewski" <robert@spiraldb.com>
@codspeed-hq

codspeed-hq Bot commented Aug 27, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 10.78%

⚠️ 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 regressed benchmarks
✅ 2127 untouched benchmarks
⏩ 106 skipped benchmarks1
🗄️ 4 archived benchmarks run2

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation compact[(1024, 90)] 1.3 µs 1.5 µs -11.14%
Simulation compact[(2048, 90)] 1.4 µs 1.5 µs -10.72%
WallTime mul_u32_nonnull_avx512 5.6 µs 6.2 µs -10.48%

Tip

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


Comparing perf/skip-recursive-predicate-revalidation (84c71a5) with develop (59a056d)

Open in CodSpeed

Footnotes

  1. 106 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. 4 benchmarks were run, but are now archived. If they were deleted in another branch, consider rebasing to remove them from the report. Instead if they were added back, click here to restore them.

@robert3005

Copy link
Copy Markdown
Contributor Author

Closing: keeping changes local per robert

@robert3005 robert3005 closed this Aug 27, 2026
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