apache / apache/arrow-rs

Improve performance of CachedArrayreader filter+concat

Open
#10,774 4 comments 2 reactions 0 assignees View on GitHub
enhancement parquet performance
Dominant language
Rust
Stars
3.6k
Forks
1.3k
Avg merge
2d 14h
Merged PRs (30d)
167

Description

### Is your feature request related to a problem or challenge?

While working on https://github.com/apache/datafusion/pull/24426#issuecomment-5342167688

I am profiling ClickBench Q25 (the one query that is going slower for this setup)

```sql
SET datafusion.execution.parquet.binary_as_string = true;
CREATE EXTERNAL TABLE hits_raw STORED AS PARQUET LOCATION '/Users/andrewlamb/Software/datafusion/benchmarks/data/hits_partitioned/';
CREATE VIEW hits AS SELECT * EXCEPT ("EventDate"), CAST(CAST("EventDate" AS INTEGER) AS DATE) AS "EventDate" FROM hits_raw;
SET datafusion.execution.parquet.pushdown_filters = true;
SELECT "SearchPhrase" FROM hits WHERE "SearchPhrase" <> '' ORDER BY "SearchPhrase" LIMIT 10;
```

About 5% of the overall time is going to reassembling the correct rows in the cached array reader

Image

### Describe the solution you'd like

Make it faster

### Describe alternatives you've considered

It looks like the CachedArrayreader is currently using the classic "filter + concat" operation

https://github.com/apache/arrow-rs/blob/03b940e1c7e3e7af9b636940fb9f1ee195891a1f/parquet/src/arrow/array_reader/cached_array_reader.rs#L315-L316

https://github.com/apache/arrow-rs/blob/03b940e1c7e3e7af9b636940fb9f1ee195891a1f/parquet/src/arrow/array_reader/cached_array_reader.rs#L335-L336

Which is what the `coalesce` kernel is designed to improve (avoids a copy)(: https://docs.rs/arrow/latest/arrow/compute/kernels/coalesce/index.html

So I think we could switch the CachedArrayReader to use coalesce to improve the performance

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start in parquet/src/arrow/array_reader/cached_array_reader.rs at the filter and concat paths linked in the issue, then read the Arrow coalesce kernel documentation. Compare the current reassembly with coalesce and validate the change against the ClickBench Q25 query; done means the cached array reader is measurably faster without changing its results.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
data, performance
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.