Skip to content

Comments

Respect Page Size Limits in ArrowWriter (#2853)#2890

Merged
tustvold merged 5 commits intoapache:masterfrom
tustvold:page-size-limit
Oct 24, 2022
Merged

Respect Page Size Limits in ArrowWriter (#2853)#2890
tustvold merged 5 commits intoapache:masterfrom
tustvold:page-size-limit

Conversation

@tustvold
Copy link
Contributor

@tustvold tustvold commented Oct 18, 2022

Which issue does this PR close?

Closes #2853
Closes #2889

Rationale for this change

See tickets

What changes are included in this PR?

Fixes an issue where size estimation was broken for primitive columns and dictionary encoded pages, which prevented the page size limit from being respected. Similar to #2854

Also tweaks the RLE size estimation as it was overly pessimistic

Are there any user-facing changes?

No

@github-actions github-actions bot added the parquet Changes to the parquet crate label Oct 18, 2022
}

fn write_gather(&mut self, values: &Self::Values, indices: &[usize]) -> Result<()> {
self.num_values += indices.len();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the fix for #2853


fn num_values(&self) -> usize {
self.num_values
match &self.dict_encoder {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without this, we would only ever have a single dictionary encoded page per column chunk. This is the other half of the fix in #2854

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe it is worth a comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The confusion was that we tracked num_values in two places, that is now gone so I'm not sure what to write in a comment...

@alamb
Copy link
Contributor

alamb commented Oct 18, 2022

#2853 is already marked as closed -- it isn't clear to me if that ticket is really still open or if this PR just fixes another issue with a similar outward symptom?

@tustvold
Copy link
Contributor Author

tustvold commented Oct 18, 2022

it isn't clear to me if that ticket is really still open

It is really still open, #2854 only partially fixed it for the case of dictionary fallback pages

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.

I had a bunch of questions, but based on the tests alone I am approving this PR. Nice work @tustvold

I think we should get at least one more pair of eyes on this PR prior to merging it

cc @thinkharderdev and @Ted-Jiang @sunchao


fn num_values(&self) -> usize {
self.num_values
match &self.dict_encoder {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe it is worth a comment

let props = Arc::new(
WriterProperties::builder()
.set_data_pagesize_limit(15) // actually each page will have size 15-18 bytes
.set_data_pagesize_limit(10)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand this change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The RLE size estimation has changed, and so this test needed updating

// NOTE: The final size is almost the same because the dictionary entries are
// preserved after encoded values have been written.
run_test::<Int32Type>(Encoding::RLE_DICTIONARY, -1, &[123, 1024], 11, 68, 66);
run_test::<Int32Type>(Encoding::RLE_DICTIONARY, -1, &[123, 1024], 0, 2, 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

can you explain these changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The RLE size estimation was updated as part of #2889

Encoding::BIT_PACKED => {
ceil((num_buffered_values * bit_width as usize) as i64, 8) as usize
}
Encoding::RLE => RleEncoder::max_buffer_size(bit_width, num_buffered_values),
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this different than the other estimated sizes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What other estimated sizes, I think I updated them all?

@tustvold
Copy link
Contributor Author

I'm going to get this in so that I can base some changes off it, I'll address any further review comments in follow up PRs

@tustvold tustvold merged commit 7e5d4a1 into apache:master Oct 24, 2022
@ursabot
Copy link

ursabot commented Oct 25, 2022

Benchmark runs are scheduled for baseline = e859f30 and contender = 7e5d4a1. 7e5d4a1 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

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

Labels

parquet Changes to the parquet crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Overly Pessimistic RLE Size Estimation parquet::arrow::arrow_writer::ArrowWriter ignores page size properties

3 participants