Repository navigation
Deprecate the session-less optimize and keep constructors lazy - #11091
robert3005 wants to merge 3 commits into
Conversation
b724ab6 to
083a5b5
Compare
9d26236 to
45724a5
Compare
45724a5 to
f9f348f
Compare
f9f348f to
37c91a6
Compare
37c91a6 to
02090f0
Compare
With a session, the optimizer now works bottom up, and execution optimizes each node that it reaches. This prepares for lazy constructors in #11091. ## Changes - `optimize_ctx` optimizes the children of a node that were never optimized before it tries the rules of the node. It does the same for the nodes that each rewrite builds. It does not visit marked subtrees, and it marks every array that it returns. Thus inverse rules, such as `slice(get_item)` and `get_item(slice)`, cannot loop. - One optimize call rewrites a shared node only once, for example the struct below every field of a projection. - `optimize_recursive` is now the same as `optimize_ctx`. - The session-less `optimize` still rewrites only the root and does not mark the result. Thus a later `optimize_ctx` still tries the session kernels. - `execute_until` optimizes the root before it starts, each child that execution focuses, the result of each `Done` step, and the array that it returns. Single-step execution optimizes with the session, instead of trying only the static reduce and parent-reduce rules. - `Chunked::reduce` does not reduce an empty variant array, because `Variant` has no empty canonical form. --------- Signed-off-by: Robert Kruszewski <github@robertk.io>
02090f0 to
89bc44c
Compare
Merging this PR will degrade performance by 10.05%2 warnings
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
07e02b8 to
1d0f0bc
Compare
ArrayOptimizer::optimize uses only the static rules of the encodings, so it misses the kernels a session registers. It is now deprecated in favour of optimize_ctx, which takes the session or an ExecutionCtx created from it through the new AsOptimizerKernels trait. optimize_recursive takes the same argument. Constructors such as slice, filter, take, cast, fill_null, get_item and apply no longer optimize the arrays they build. Execution optimizes each node it reaches, and the callers that read an array's encoding directly optimize it with their session first: the scan tasks, the plan v2 operators, the dict layout writer, the FFI scan, and CUDA dispatch. The default append_to_builder optimizes the array first and appends through the encoding it reduces to, so a lazy slice of a constant appends as a constant. Signed-off-by: Robert Kruszewski <github@robertk.io>
A lazy array, such as a slice of a constant, now appends through the encoding that it reduces to. Callers such as case_when and zip no longer need to optimize the array before they append it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Robert Kruszewski <github@robertk.io>
Constructors such as slice, filter, take and the array builtins now return lazy arrays. Code that inspects the encoding of the result, stores it, or reads it row by row lost its fast paths or changed its output. Optimize the result at those sites, and add a Dict rule that keeps only the referenced value when the codes reduce to a constant. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Robert Kruszewski <github@robertk.io>
1d0f0bc to
8e61ec4
Compare
|
#11092 recovers majority of the regression, could merge them into one but this is a smaller change |
ArrayOptimizer::optimizeuses only the static rules of the encodings, so it misses the kernels that a session registers. This PR deprecates it, and array constructors no longer optimize the arrays they build.Changes
optimize_ctxandoptimize_recursivetake&impl AsOptimizerKernels, which is aVortexSessionor anExecutionCtxcreated from one. Existingoptimize_ctx(&session)callers compile without changes.slice,filter,take,cast,fill_null,get_itemandapplyreturn lazy arrays. Execution optimizes each node it reaches (Optimize arrays top down as execution reaches them, and retry a parent when its children change #11090). Callers that read the encoding of an array directly now optimize it with their session first: scan tasks, plan v2 operators, the dict layout writer, the FFI scan and CUDA dispatch.append_to_builderoptimizes the array first. It then appends through the encoding the array reduces to, so a lazy slice of a constant appends as a constant.optimize_ctx(&SESSION)instead ofoptimize().API Changes
ArrayOptimizer::optimizeis deprecated. Useoptimize_ctxwith the session or anExecutionCtx.ArrayOptimizer::optimize_ctxandoptimize_recursiveare generic overAsOptimizerKernels.ArrayRef::slice,filter,takeand theArrayBuiltinsmethods no longer return an optimized array.