Make partition expression evaluation stateless#4
Draft
dossett wants to merge 3 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Partition pruning currently rebuilds and binds the same expression for every data file because
_ExpressionEvaluatorstores the current record on itself and cannot safely be shared across manifest worker threads. Even for a single equality predicate, repeated binding costs more than the actual partition evaluation work.This change separates immutable expression preparation from call-local evaluation state. That makes one prepared evaluator safe to share for every manifest using a partition spec, without locks or thread-local state. It is a fresh alternative to apache#3656, rooted directly at Apache
mainrather than stacked on that branch.Summary
_ExpressionEvaluatorand move each record into a short-lived visitor.Performance
The focused benchmark evaluates 1,000 files against
x == 5using a two-field partition spec. Each result is the mean of five runs, with each run averaging 100 iterations.mainCompared with
main, stateless per-spec sharing is about 6.6x faster for a dense manifest and 5.6x faster for fragmented manifests. Compared with task-local reuse, constructing a call-local visitor is about 13% slower in the dense case, but avoiding one bind per manifest is about 5.7x faster in the fragmented case.This is a focused evaluator benchmark, not an end-to-end query-runtime claim. It excludes catalog access, manifest Avro I/O and decompression, metrics evaluation, residual planning, and downstream data reads.
Testing
.venv/bin/python -m pytest tests/expressions/test_visitors.py -q.venv/bin/python -m pytest tests/expressions/test_evaluator.py -q.venv/bin/python -m pytest tests/table/test_init.py -q.venv/bin/python -m pytest tests/table/test_partition_evaluator_planning.py -q.venv/bin/python -m pytest tests/benchmark/test_partition_evaluator_benchmark.py -v -s -m benchmarkUV_NO_CONFIG=1 .venv/bin/prek run -a