Reduce constant mask for MaskedArray and Mask scalarfn - #9038
Conversation
Benchmarks: Clickbench on NVME 📖Verdict: No clear signal (low confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed (1.022x ➖, 1↑ 1↓)
datafusion / parquet (1.015x ➖, 1↑ 1↓)
duckdb / vortex-file-compressed (1.016x ➖, 0↑ 3↓)
duckdb / parquet (1.009x ➖, 0↑ 1↓)
File Size Changes (101 files changed, -39.2% overall, 0↑ 101↓)
Totals:
|
Benchmarks: FineWeb S3 📖Verdict: No clear signal (low confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed (1.087x ➖, 0↑ 0↓)
datafusion / parquet (0.964x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed (0.949x ➖, 0↑ 0↓)
duckdb / parquet (0.951x ➖, 0↑ 0↓)
|
Benchmarks: TPC-H SF=1 on S3 📖Verdict: No clear signal (low confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed (0.969x ➖, 1↑ 1↓)
datafusion / parquet (0.995x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed (1.003x ➖, 0↑ 0↓)
duckdb / parquet (0.953x ➖, 0↑ 0↓)
|
Benchmarks: TPC-H SF=1 on NVME 📖Verdict: No clear signal (environment too noisy confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed (0.979x ➖, 0↑ 0↓)
datafusion / parquet (1.014x ➖, 1↑ 3↓)
duckdb / vortex-file-compressed (0.995x ➖, 0↑ 0↓)
duckdb / parquet (0.995x ➖, 3↑ 3↓)
File Size Changes (10 files changed, -43.9% overall, 0↑ 10↓)
Totals:
|
Benchmarks: PolarSignals Profiling 📖Vortex (geomean): 1.060x ➖ How to read Verdict and Engines
datafusion / vortex-file-compressed (1.060x ➖, 0↑ 1↓)
No file size changes detected. |
Benchmarks: Clickbench Sorted on NVME 📖Verdict: No clear signal (low confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed (0.983x ➖, 0↑ 1↓)
datafusion / parquet (1.017x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed (1.060x ➖, 0↑ 2↓)
duckdb / parquet (1.002x ➖, 0↑ 0↓)
File Size Changes (201 files changed, -42.8% overall, 50↑ 151↓)
Totals:
|
Benchmarks: TPC-H SF=10 on NVME 📖Verdict: No clear signal (low confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed (0.951x ➖, 0↑ 0↓)
datafusion / parquet (0.954x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed (0.970x ➖, 0↑ 0↓)
duckdb / parquet (0.984x ➖, 0↑ 0↓)
File Size Changes (25 files changed, -44.0% overall, 0↑ 25↓)
Totals:
|
Benchmarks: FineWeb NVMe 📖Verdict: No clear signal (low confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed (1.113x ❌, 0↑ 3↓)
datafusion / parquet (1.061x ➖, 0↑ 1↓)
duckdb / vortex-file-compressed (1.105x ❌, 0↑ 2↓)
duckdb / parquet (1.065x ➖, 0↑ 2↓)
File Size Changes (2 files changed, -46.3% overall, 0↑ 2↓)
Totals:
|
Benchmarks: TPC-DS SF=1 on NVME 📖Verdict: No clear signal (low confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed (1.007x ➖, 1↑ 1↓)
datafusion / parquet (1.006x ➖, 1↑ 2↓)
duckdb / vortex-file-compressed (1.006x ➖, 2↑ 1↓)
duckdb / parquet (0.998x ➖, 1↑ 0↓)
File Size Changes (25 files changed, -43.5% overall, 0↑ 25↓)
Totals:
|
Benchmarks: Statistical and Population Genetics 📖Verdict: No clear signal (low confidence) How to read Verdict and Engines
duckdb / vortex-file-compressed (1.029x ➖, 0↑ 0↓)
duckdb / parquet (1.021x ➖, 0↑ 0↓)
File Size Changes (2 files changed, -32.3% overall, 0↑ 2↓)
Totals:
|
Merging this PR will regress 1 benchmark
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
81f5ac8 to
b23aea0
Compare
Polar Signals Profiling ResultsLatest Run
Previous Runs (30)
Powered by Polar Signals Cloud |
MaskedArray and Mask scalarfn
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
d9e5928 to
a1bb95a
Compare
| let Some(mask_child) = array.slots()[MaskedSlots::VALIDITY].as_ref() else { | ||
| return array.child().cast(array.dtype().clone()).map(Some); | ||
| }; |
There was a problem hiding this comment.
there is array.validity() method from the array_slots macro that is generated to get the validity, would be nice to use it
| Some(false) => Ok(Some( | ||
| ConstantArray::new(Scalar::null(array.dtype().clone()), array.len()).into_array(), | ||
| )), | ||
| None => Ok(None), |
There was a problem hiding this comment.
What do none mean here? This is not allowed. This scalar must be non-nullable!
There was a problem hiding this comment.
let child = PrimitiveArray::from_iter([1i32, 2, 3]).into_array();
let validity = Validity::Array(
ConstantArray::new(
Scalar::null(DType::Bool(Nullability::Nullable)),
child.len(),
)
.into_array(),
);
let masked = MaskedArray::try_new(child, validity)?.into_array();
This succeeds currently
| ctx: &dyn ReduceCtx, | ||
| ) -> VortexResult<Option<ReduceNodeRef>> { | ||
| let mask = node.child(1); | ||
| // Expression literals are handled by `simplify`; this path recognizes array metadata. | ||
| let Some(mask) = mask.as_any().downcast_ref::<ArrayRef>() else { | ||
| return Ok(None); | ||
| }; | ||
| let Some(constant) = mask.as_opt::<Constant>() else { | ||
| return Ok(None); | ||
| }; | ||
|
|
||
| match constant.scalar().as_bool().value() { | ||
| Some(true) => { | ||
| let input = node.child(0); | ||
| let output_dtype = node.node_dtype()?; | ||
| if input.node_dtype()? == output_dtype { | ||
| return Ok(Some(input)); | ||
| } | ||
|
|
||
| ctx.new_node(Cast.bind(output_dtype), &[input]).map(Some) | ||
| } | ||
| Some(false) => { | ||
| let output_dtype = node.node_dtype()?; | ||
| ctx.new_node(Literal.bind(Scalar::null(output_dtype)), &[]) | ||
| .map(Some) | ||
| } | ||
| None => Ok(None), | ||
| } | ||
| } |
There was a problem hiding this comment.
how does this happen?
There was a problem hiding this comment.
if we apply .mask and the encoding has no MaskReduce i believe. Also this runs before parent reduce kernels
A true constant mask should reduce to a nullability cast without changing any array data. A false constant mask should reduce array to a null constant.