Skip to content

bench(arrow): add sparse dictionary to view cast benchmarks - #10596

Merged
Jefffrey merged 2 commits into
apache:mainfrom
Abhisheklearn12:bench/dict-to-view-cast
Aug 9, 2026
Merged

bench(arrow): add sparse dictionary to view cast benchmarks#10596
Jefffrey merged 2 commits into
apache:mainfrom
Abhisheklearn12:bench/dict-to-view-cast

Conversation

@Abhisheklearn12

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

None. Split out of #10436 at review request, so these land on main first and the bot can measure that PR against them.

Rationale for this change

cast_kernels has one dictionary to view benchmark, at 10,000 rows over 3 values. Nothing covers the opposite shape, a dictionary much larger than the array, and nothing covers dict<binary> -> utf8view, which validates the values as UTF-8.

What changes are included in this PR?

Two benchmarks, both 1024 rows over 32,768 values:

Keys come from seedable_rng so they spread across the dictionary, and values exceed 12 bytes so the views reference the buffer rather than inlining.

Are these changes tested?

Benchmarks only, no library code touched. They build and run under cargo bench -p arrow --features test_utils --bench cast_kernels.

Are there any user-facing changes?

No.

@github-actions github-actions Bot added the arrow Changes to the arrow crate label Aug 9, 2026
@Jefffrey Jefffrey added the development-process Related to development process of arrow-rs label Aug 9, 2026
Comment thread arrow/benches/cast_kernels.rs Outdated
Comment on lines +213 to +214
// `Dictionary<UInt64, Utf8>` of `size` rows over `distinct` values, each longer than 12
// bytes so the resulting views reference the values buffer rather than inlining.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we have some mix of inline & long views to test more paths?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done this, values now alternate short and long so both view paths get exercised

Comment thread arrow/benches/cast_kernels.rs Outdated
Comment on lines +216 to +219
// The ratio of rows to distinct values is what matters when casting to a view: the cast
// can either build one view per dictionary value and gather those with `take`, or build
// one view per row directly against the values buffer. Which of the two is cheaper depends
// on that ratio, so both a dense and a sparse shape are benchmarked below.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont have too much detail on implementation here; just keep simple like "different implementation paths may be taken based on ratio of rows to distinct values"

Comment thread arrow/benches/cast_kernels.rs Outdated
// As `build_string_dict_array`, but with `Binary` values. Casting those to `Utf8View` has
// to validate the dictionary values as UTF-8, which a `Utf8` source does not.
fn build_binary_dict_array(size: usize, distinct: usize) -> ArrayRef {
let values = BinaryArray::from_iter_values(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could also get this by using output of build_string_dict_array() and casting to Dictionary(Binary)

@Jefffrey
Jefffrey merged commit bb82f3e into apache:main Aug 9, 2026
31 checks passed
@Jefffrey

Jefffrey commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

thanks @Abhisheklearn12

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 development-process Related to development process of arrow-rs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants