Skip to content

Implement native interleave for ListView#9558

Open
vegarsti wants to merge 2 commits intoapache:mainfrom
vegarsti:list-view-interleave-native
Open

Implement native interleave for ListView#9558
vegarsti wants to merge 2 commits intoapache:mainfrom
vegarsti:list-view-interleave-native

Conversation

@vegarsti
Copy link
Contributor

@vegarsti vegarsti commented Mar 15, 2026

Closes #9342.

This PR adds a native implementation of interleave for the ListView type. Also adds a benchmark. Unfortunately this uncovered that the fallback implementation is broken, see the test_list_view_interleave_fallback_is_broken test, which panics if we comment out the native implementation:

---- interleave::tests::test_list_view_interleave_fallback_is_broken stdout ----

thread 'interleave::tests::test_list_view_interleave_fallback_is_broken' (17537938) panicked at arrow-data/src/equal/utils.rs:102:59:
range start index 16 out of range for slice of length 0

But with the native implementation, the benchmark results are comparable to those for list. I have not been able to make them faster than list for this benchmark.

 ┌───────────────────────────┬────────┬──────────┐
 │ Benchmark                 │ List   │ ListView │
 ├───────────────────────────┼────────┼──────────┤
 │ (0.1,0.1,20) 100          │ 2.88µs │ 3.04µs   │
 ├───────────────────────────┼────────┼──────────┤
 │ (0.1,0.1,20) 400          │ 10.1µs │ 10.7µs   │
 ├───────────────────────────┼────────┼──────────┤
 │ (0.1,0.1,20) 1024 3-slice │ 33.7µs │ 34.1µs   │
 ├───────────────────────────┼────────┼──────────┤
 │ (0.1,0.1,20) 1024 4-slice │ 30.1µs │ 33.9µs   │
 ├───────────────────────────┼────────┼──────────┤
 │ (0.0,0.0,20) 100          │ 1.41µs │ 1.58µs   │
 ├───────────────────────────┼────────┼──────────┤
 │ (0.0,0.0,20) 400          │ 9.51µs │ 11.7µs   │
 ├───────────────────────────┼────────┼──────────┤
 │ (0.0,0.0,20) 1024 3-slice │ 20.1µs │ 23.3µs   │
 ├───────────────────────────┼────────┼──────────┤
 │ (0.0,0.0,20) 1024 4-slice │ 21.7µs │ 24.0µs   │
 └───────────────────────────┴────────┴──────────┘

With a cherry pick of the fix in #9562, we get

 ┌────────────────────────────┬───────┬──────┬────────┬───────────────┬─────────────┬───────────┐
 │ Benchmark                  │ Nulls │ Rows │ Arrays │ Fallback (µs) │ Native (µs) │ Change    │
 ├────────────────────────────┼───────┼──────┼────────┼───────────────┼─────────────┼───────────┤
 │ list_view<i64>(0.1,0.1,20) │ 10%   │ 100  │ 3      │ 4.19          │ 2.93        │ -30.1%    │
 ├────────────────────────────┼───────┼──────┼────────┼───────────────┼─────────────┼───────────┤
 │ list_view<i64>(0.1,0.1,20) │ 10%   │ 400  │ 3      │ 10.85         │ 10.04       │ -9.4%     │
 ├────────────────────────────┼───────┼──────┼────────┼───────────────┼─────────────┼───────────┤
 │ list_view<i64>(0.1,0.1,20) │ 10%   │ 1024 │ 3      │ 27.80         │ 26.67       │ -5.2%     │
 ├────────────────────────────┼───────┼──────┼────────┼───────────────┼─────────────┼───────────┤
 │ list_view<i64>(0.1,0.1,20) │ 10%   │ 1024 │ 4      │ 28.06         │ 25.06       │ -9.7%     │
 ├────────────────────────────┼───────┼──────┼────────┼───────────────┼─────────────┼───────────┤
 │ list_view<i64>(0.0,0.0,20) │ 0%    │ 100  │ 3      │ 2.57          │ 1.42        │ -45.0%    │
 ├────────────────────────────┼───────┼──────┼────────┼───────────────┼─────────────┼───────────┤
 │ list_view<i64>(0.0,0.0,20) │ 0%    │ 400  │ 3      │ 5.78          │ 7.17        │ +22.3%    │
 ├────────────────────────────┼───────┼──────┼────────┼───────────────┼─────────────┼───────────┤
 │ list_view<i64>(0.0,0.0,20) │ 0%    │ 1024 │ 3      │ 13.34         │ 18.96       │ +22.2%    │
 ├────────────────────────────┼───────┼──────┼────────┼───────────────┼─────────────┼───────────┤
 │ list_view<i64>(0.0,0.0,20) │ 0%    │ 1024 │ 4      │ 13.85         │ 17.93       │ +13.5%    │
 └────────────────────────────┴───────┴──────┴────────┴───────────────┴─────────────┴───────────┘

@github-actions github-actions bot added the arrow Changes to the arrow crate label Mar 15, 2026
@vegarsti vegarsti force-pushed the list-view-interleave-native branch from a1131f2 to 16f2287 Compare March 15, 2026 15:42
@brancz
Copy link
Contributor

brancz commented Mar 16, 2026

Do you mind comparing this to the fallthrough performance of #9562 ?

@vegarsti
Copy link
Contributor Author

Do you mind comparing this to the fallthrough performance of #9562 ?

Oh for sure, thanks for reminding me!

@vegarsti
Copy link
Contributor Author

vegarsti commented Mar 16, 2026

Updated the description with results now. It's not looking like a win..!

@brancz
Copy link
Contributor

brancz commented Mar 16, 2026

I would say let's merge the fallthrough and iterate on this version. I'm sure there are several possibilities for optimizations.

@asubiotto
Copy link
Contributor

FWIW I pushed up the branch I've had marinating locally for a month or two in case it's helpful: main...polarsignals:arrow-rs:asubiotto/lvinterleave. I believe the benchmarks showed a slight regression for interleaves of small lists, but overall the perf was an improvement. I'm not able to take a closer look right now, but sharing in case it's helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add native ListView support for interleave kernel

3 participants