Skip to content

Conversation

@rluvaton
Copy link
Member

@rluvaton rluvaton commented Jan 25, 2025

Which issue does this PR close?

N/A

Rationale for this change

So we can see the improvement in

What changes are included in this PR?

added benchmark for array_agg merge_batch function

Are these changes tested?

N/A

Are there any user-facing changes?

Nope

@github-actions github-actions bot added the functions Changes to functions implementation label Jan 25, 2025
@rluvaton rluvaton marked this pull request as ready for review January 25, 2025 22:19
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thanks @rluvaton -- i had some very minor questions about the description of the tests, but otherwise looks good.

let values = Arc::new(create_list_array::<Int64Type>(8192, 1.0, 0.1)) as ArrayRef;
merge_batch_bench(
c,
"array_agg i64 merge_batch all nulls, 90% of nulls point to a zero length array",
Copy link
Contributor

Choose a reason for hiding this comment

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

this comment says 90 but the function call is create_list_array::<Int64Type>(8192, 1.0, 0.1) (which is 100 right?)

Copy link
Contributor

Choose a reason for hiding this comment

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

Or is the idea that 10% nulls point at a non zero length array 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

all null because null density (2nd arg) is 1.0, and 90% of nulls point to a zero length array, because the 3rd argument is the probability for non-zero length so it's 10% and 100 - 10 is 90% hence the 90% of nulls

I'll rename the argument in the function to be probability for zero length array

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks -- that makes a lot more sense to me and I found it easier to understand. 🙏

b.iter(|| {
#[allow(clippy::unit_arg)]
black_box(
ArrayAggAccumulator::try_new(&list_item_data_type)
Copy link
Contributor

Choose a reason for hiding this comment

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

As written this will create a new ArrayAggAccumulator on each iteration -- it might be more representative if the creation wasn't part of the measurement (aka create the accumulator outside b.iter() 🤔 )

Copy link
Member Author

@rluvaton rluvaton Jan 26, 2025

Choose a reason for hiding this comment

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

I know, but the otherwise this will add to the same local state and is not what is being tested, also creating is almost 0 cost

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @rluvaton

let values = Arc::new(create_list_array::<Int64Type>(8192, 1.0, 0.1)) as ArrayRef;
merge_batch_bench(
c,
"array_agg i64 merge_batch all nulls, 90% of nulls point to a zero length array",
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks -- that makes a lot more sense to me and I found it easier to understand. 🙏

@rluvaton
Copy link
Member Author

@alamb can you please merge this and run the benchmark on my performance improvement PR?

@alamb alamb merged commit 4dc97b2 into apache:main Jan 26, 2025
27 checks passed
@alamb
Copy link
Contributor

alamb commented Jan 26, 2025

Done @rluvaton -- thanks!

BTW this is the script I use for benchmarking: https://github.com/alamb/datafusion-benchmarking/blob/main/compare_branch.sh

I'll run it on your branch now

@rluvaton rluvaton deleted the add-benchmark-for-array-agg-merge-batch branch January 26, 2025 13:28
@rluvaton
Copy link
Member Author

Thank you, don't you have dedicated machines in the CI for running benchmarks? how would you otherwise 1. verify it's not only locally, 2. can reproduce 3. have somehow consistent results

@alamb
Copy link
Contributor

alamb commented Jan 26, 2025

Thank you, don't you have dedicated machines in the CI for running benchmarks? how would you otherwise 1. verify it's not only locally, 2. can reproduce 3. have somehow consistent results

I run it on a gcp VM

I would love to get the process more automated. See

@rluvaton
Copy link
Member Author

rluvaton commented Jan 26, 2025

I'll see if I can help later this week.

if you ran the benchmark I would appreciate positing it on the improvement PR and not here of course

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

Labels

functions Changes to functions implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants