Repository navigation
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## Jason8Ni/refresh-den-55-upstream #194 +/- ##
==================================================================
Coverage 81.26% 81.26%
==================================================================
Files 1110 1110
Lines 389819 389924 +105
Branches 389819 389924 +105
==================================================================
+ Hits 316791 316887 +96
- Misses 54446 54447 +1
- Partials 18582 18590 +8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Jason8Ni
changed the base branch from
den-55
to
Jason8Ni/refresh-den-55-upstream
October 30, 2026 18:55
Jason8Ni
force-pushed
the
Jason8Ni/literal-case-branch-routing
branch
from
October 30, 2026 18:55
c80faee to
bb39e8b
Compare
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.
Which issue does this PR close?
No linked issue; this is a performance improvement for the
den-55fork. This PR is stacked on #195; merge that maintenance update first, then retarget this PR toden-55.Rationale for this change
Simple
CASE key WHEN literal THEN expression ...expressions repeatedly compare keys and filter shrinking record batches. With many branches, copying the remaining rows can cost more than evaluating the selected results. This affects ordinary categorical SQL expressions as well as generated filters.What changes are included in this PR?
For more than eight supported literal WHEN branches, reuse
LiteralLookupTableto route remaining rows to their original branch indices. Keep the first two sequential comparisons so common leading matches retain their early exits; evaluate each remaining result only on its selected rows. Reuse the existing projection and result-merging logic, preserving first-match, NULL, cast, lazy-evaluation, and row-order semantics. Short CASE expressions and unsupported WHEN expressions retain the existing evaluator.Are these changes tested?
./dev/rust_lint.shpass on the refreshed base.Historical measurements on the earlier 55.1-based revision: a local interleaved comparison against the retained sequential evaluator used 8,192 rows, arithmetic results, 11 alternating rounds, and 60 evaluations per arm per round (
ciprofile, opt-level 1). Uniform 16/32/64/128-branch cases improved approximately 1.48/1.94/2.74/4.11×; the skewed 16-branch case improved about 1.17×. First/first-two-branch and short-case controls were approximately unchanged. These are expression-level measurements on a shared development machine, not end-to-end query latency claims or new measurements against the refreshed 55.2-based branch.Follow-up cutoff experiments
Optimized-build experiments on the refreshed revision found that the current eight-branch cutoff is too aggressive for some ordinary inputs. In two repeated sweeps, a nine-branch Int64 case with varied missing keys took about 3.6× as long as sequential evaluation; a skewed 12-branch case took about 1.7× as long. Uniform matching inputs still benefit. The earlier opt-level-1 measurements do not establish a generally safe crossover.
A local prototype preserves the zero-match/all-match fast paths before routing and accumulates routed results directly in the existing result builder, avoiding an extra merge. It removes the severe no-match regression. Skew-sensitive cases remain at 32–48 branches. A conservative follow-up would combine those changes with a minimum of 64 branches: 1,324 prototype scenario evaluations at 64/96/128 branches had no median slowdown above 5%; focused skewed 64-branch cases improved about 1.20–1.23× across three fresh processes. This sacrifices some smaller-expression wins and does not prove 64 universally optimal.
The investigation covered 10,448 timed scenario evaluations, with equality checked before every timing, varying branch count, leading comparisons, match distribution, batch size, key representation, and computed result type. All 45 CASE unit tests passed on the final prototype. These were shared Apple M4 Max expression microbenchmarks using
release-nonlto(opt-level 3), with lookup construction excluded. The prototype and proposed cutoff are not yet applied to this PR, and require full code validation plus production-hardware and end-to-end measurements before adoption.Are there any user-facing changes?
Eligible CASE expressions do less repeated filtering and copying. SQL semantics and public APIs are unchanged; no query-specific detection or configuration is added.