perf: Cache remapped expression in DynamicFilterPhysicalExpr::current()#20353
perf: Cache remapped expression in DynamicFilterPhysicalExpr::current()#20353adriangb wants to merge 2 commits into
Conversation
|
run benchmark tpcds |
|
🤖 |
|
🤖: Benchmark completed Details
|
|
run benchmark tpcds |
|
🤖 |
|
🤖: Benchmark completed Details
|
|
run benchmark tpcds |
|
🤖 |
|
🤖: Benchmark completed Details
|
`current()` calls `remap_children()` which does a full `transform_up()` tree walk on every invocation. This is called per-batch in `evaluate()`, `snapshot()`, etc. When the inner expression hasn't changed (the common case — updates are infrequent relative to evaluations), this tree walk is pure redundant work. Cache the remapped result per-instance using `Arc::ptr_eq` on the source expression for invalidation. When `update()` replaces `inner.expr` with a new `Arc`, the pointer naturally changes and the cache invalidates. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use a named CachedCurrent struct instead of a tuple to satisfy clippy::type_complexity, and collapse nested if into a single let-chain to satisfy clippy::collapsible_if. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
d50740f to
5150ff9
Compare
|
Thank you for your contribution. Unfortunately, this pull request is stale because it has been open 60 days with no activity. Please remove the stale label or comment or this will be closed in 7 days. |
Summary
remap_children()inDynamicFilterPhysicalExpr::current()to avoid redundanttransform_up()tree walks on every per-batch call (evaluate(),snapshot(), etc.)Arc::ptr_eqon the source expression for cache invalidation — whenupdate()replaces the inner expression, the pointer naturally changesremapped_childrenisNone(no overhead on the producer path)Test plan
cargo test -p datafusion-physical-expr --lib expressions::dynamic_filters(9/9 pass)test_remap_childrenexercises update + evaluate on two consumers with different remapped children, verifying correctness after cache invalidation🤖 Generated with Claude Code