Push down some expressions to Dict layout reader's cached values#8341
Push down some expressions to Dict layout reader's cached values#8341myrrc wants to merge 1 commit into
Conversation
Merging this PR will degrade performance by 10.39%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | encode_varbin[(1000, 8)] |
143.6 µs | 160.6 µs | -10.59% |
| ❌ | Simulation | encode_varbin[(1000, 4)] |
142.9 µs | 159.7 µs | -10.53% |
| ❌ | Simulation | encode_varbin[(1000, 32)] |
148.5 µs | 165.1 µs | -10.06% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing myrrc/pushdown-dict (e70ceab) with develop (c6a0b7b)
Footnotes
-
10 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. ↩
Polar Signals Profiling ResultsLatest Run
Powered by Polar Signals Cloud |
Benchmarks: PolarSignals ProfilingVortex (geomean): 1.065x ➖ How to read Verdict and Engines
datafusion / vortex-file-compressed (1.065x ➖, 0↑ 3↓)
No file size changes detected. |
Benchmarks: FineWeb NVMeVerdict: No clear signal (low confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed (1.019x ➖, 0↑ 1↓)
datafusion / vortex-compact (1.013x ➖, 0↑ 1↓)
datafusion / parquet (1.003x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed (1.026x ➖, 0↑ 0↓)
duckdb / vortex-compact (0.992x ➖, 1↑ 0↓)
duckdb / parquet (1.011x ➖, 0↑ 0↓)
File Size Changes (1 files changed, +0.0% overall, 1↑ 0↓)
Totals:
|
Benchmarks: TPC-H SF=1 on NVMEVerdict: No clear signal (low confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed (0.972x ➖, 0↑ 0↓)
datafusion / vortex-compact (0.875x ✅, 11↑ 0↓)
datafusion / parquet (0.970x ➖, 1↑ 1↓)
datafusion / arrow (0.802x ✅, 19↑ 0↓)
duckdb / vortex-file-compressed (0.919x ➖, 7↑ 0↓)
duckdb / vortex-compact (0.923x ➖, 5↑ 0↓)
duckdb / parquet (0.952x ➖, 1↑ 1↓)
duckdb / duckdb (0.952x ➖, 1↑ 0↓)
File Size Changes (9 files changed, +0.0% overall, 5↑ 4↓)
Totals:
|
Benchmarks: TPC-DS SF=1 on NVMEVerdict: No clear signal (low confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed (0.997x ➖, 2↑ 0↓)
datafusion / vortex-compact (1.003x ➖, 1↑ 1↓)
datafusion / parquet (1.005x ➖, 3↑ 1↓)
duckdb / vortex-file-compressed (0.988x ➖, 5↑ 1↓)
duckdb / vortex-compact (1.002x ➖, 0↑ 1↓)
duckdb / parquet (0.996x ➖, 1↑ 1↓)
duckdb / duckdb (1.007x ➖, 0↑ 3↓)
File Size Changes (7 files changed, +0.0% overall, 4↑ 3↓)
Totals:
|
Benchmarks: FineWeb S3Verdict: No clear signal (environment too noisy confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed (0.996x ➖, 0↑ 1↓)
datafusion / vortex-compact (1.038x ➖, 1↑ 2↓)
datafusion / parquet (0.846x ➖, 2↑ 0↓)
duckdb / vortex-file-compressed (0.959x ➖, 0↑ 0↓)
duckdb / vortex-compact (0.901x ➖, 0↑ 0↓)
duckdb / parquet (0.978x ➖, 0↑ 0↓)
|
Benchmarks: Statistical and Population GeneticsVerdict: No clear signal (low confidence) How to read Verdict and Engines
duckdb / vortex-file-compressed (1.022x ➖, 0↑ 0↓)
duckdb / vortex-compact (1.027x ➖, 0↑ 0↓)
duckdb / parquet (1.028x ➖, 0↑ 0↓)
File Size Changes (1 files changed, -0.0% overall, 0↑ 1↓)
Totals:
|
Benchmarks: Random AccessVortex (geomean): 0.959x ➖ How to read Verdict and Engines
unknown / unknown (1.012x ➖, 1↑ 1↓)
|
Benchmarks: TPC-H SF=10 on NVMEVerdict: No clear signal (low confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed (1.065x ➖, 0↑ 0↓)
datafusion / vortex-compact (1.066x ➖, 0↑ 0↓)
datafusion / parquet (1.046x ➖, 0↑ 0↓)
datafusion / arrow (1.005x ➖, 2↑ 0↓)
duckdb / vortex-file-compressed (1.057x ➖, 0↑ 1↓)
duckdb / vortex-compact (1.043x ➖, 0↑ 0↓)
duckdb / parquet (1.031x ➖, 0↑ 0↓)
duckdb / duckdb (1.032x ➖, 0↑ 0↓)
File Size Changes (26 files changed, -0.0% overall, 14↑ 12↓)
Totals:
|
Benchmarks: Clickbench on NVMEVerdict: No clear signal (low confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed (0.891x ✅, 21↑ 0↓)
datafusion / parquet (0.866x ✅, 32↑ 0↓)
duckdb / vortex-file-compressed (0.980x ➖, 2↑ 0↓)
duckdb / parquet (0.975x ➖, 0↑ 0↓)
duckdb / duckdb (0.989x ➖, 1↑ 0↓)
File Size Changes (106 files changed, +0.0% overall, 51↑ 55↓)
Totals:
|
Benchmarks: TPC-H SF=1 on S3Verdict: No clear signal (environment too noisy confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed (0.828x ➖, 4↑ 1↓)
datafusion / vortex-compact (0.958x ➖, 6↑ 5↓)
datafusion / parquet (1.014x ➖, 2↑ 2↓)
duckdb / vortex-file-compressed (0.918x ➖, 0↑ 0↓)
duckdb / vortex-compact (0.995x ➖, 1↑ 0↓)
duckdb / parquet (0.952x ➖, 0↑ 0↓)
|
Benchmarks: Appian on NVMEVerdict: No clear signal (low confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed (1.004x ➖, 0↑ 0↓)
datafusion / parquet (0.991x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed (1.006x ➖, 0↑ 0↓)
duckdb / parquet (0.998x ➖, 0↑ 0↓)
duckdb / duckdb (1.010x ➖, 0↑ 0↓)
File Size Changes (3 files changed, -0.0% overall, 1↑ 2↓)
Totals:
|
Benchmarks: CompressionVortex (geomean): 1.001x ➖ How to read Verdict and Engines
unknown / unknown (0.986x ➖, 9↑ 2↓)
|
Benchmarks: TPC-H SF=10 on S3Verdict: No clear signal (environment too noisy confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed (0.944x ➖, 2↑ 2↓)
datafusion / vortex-compact (0.983x ➖, 1↑ 1↓)
datafusion / parquet (0.956x ➖, 1↑ 2↓)
duckdb / vortex-file-compressed (0.864x ➖, 1↑ 0↓)
duckdb / vortex-compact (0.961x ➖, 0↑ 0↓)
duckdb / parquet (0.917x ➖, 0↑ 0↓)
|
| fn split_expression_for_pushdown(expr: Expression) -> (Option<Expression>, Option<Expression>) { | ||
| let labelled_expr = expr.clone(); | ||
| let fallible = label_is_fallible(&labelled_expr); | ||
| let null_sensitive = label_null_sensitive(&labelled_expr); | ||
| let mut inner: Option<Expression> = None; | ||
|
|
||
| let outer = expr | ||
| .transform_down(|node| { | ||
| if is_negative_cost(node.id()) | ||
| && references_root(&node) | ||
| && !fallible.get(&node).copied().unwrap_or(true) | ||
| && !null_sensitive.get(&node).copied().unwrap_or(true) | ||
| { | ||
| inner = Some(node); | ||
| Ok(Transformed { | ||
| value: root(), | ||
| changed: true, | ||
| order: TraversalOrder::Skip, |
There was a problem hiding this comment.
we have a partition function for exactly this!
There was a problem hiding this comment.
You can't implement this using partition<> because it pushes children annotations up to the parents. This breaks on
let expr = cast(byte_length(root()), dtype);
// expect inner = byte_length(root), outer = cast(root, dtype)
But instead we get
inner = cast(...)
because cast inherits the annotation from a child. This is also an implementation that's harder to reason about. Let's leave this one.
There was a problem hiding this comment.
Do you know which part incorrect with this method?
Signed-off-by: Mikhail Kot <mikhail@spiraldb.com>
e64f2a2 to
e70ceab
Compare
When we access values of Dict layout reader, it canonicalizes them and stores
them in a SharedArray. This means we always pay the cost of canonicalization
which in turn means we can't do #8310 .
In order to solve this issue, we need to apply some expressions to the values
array before canonicalizing it. However, we can't push down arbitrary
expressions as it may be beneficial to apply them over canonicalized array.
One example of such expressions is LIKE over a Dict array with few codes used.
Applying LIKE to whole values array is not beneficial.
This PR adds a hardcoded internal is_negative_cost estimation for expressions
that we want to push before canonicalization. A hint for these are expressions
which don't depend on individual input size. As an example, for every string,
len(string) doesn't read the string itself but reads the metadata and thus is
O(1) on individual input.
We don't push down fallible (like cast) or null sensitive (like IS NULL)
expressions as well because we want to propagate the errors at call site
rather than upfront.