-
Notifications
You must be signed in to change notification settings - Fork 794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: Faster decimal precision overflow checks #6419
Merged
andygrove
merged 11 commits into
apache:master
from
andygrove:faster-decimal-overflow-check
Sep 21, 2024
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1c0a8ee
add benchmark
andygrove 0f6266c
add optimization
andygrove c68432e
fix
andygrove 5fcd17a
fix
andygrove e4b22ce
cargo fmt
andygrove 5de6e14
clippy
andygrove aebad61
Update arrow-data/src/decimal.rs
andygrove 34cce0c
optimize to avoid allocating an idx variable
andygrove 1a5262d
Merge branch 'faster-decimal-overflow-check' of github.com:andygrove/…
andygrove c995213
revert change to public api
andygrove e8d24ab
fix error in rustdoc
andygrove File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
use arrow_array::builder::{Decimal128Builder, Decimal256Builder}; | ||
use arrow_buffer::i256; | ||
use criterion::*; | ||
|
||
fn criterion_benchmark(c: &mut Criterion) { | ||
let len = 8192; | ||
let mut builder_128 = Decimal128Builder::with_capacity(len); | ||
let mut builder_256 = Decimal256Builder::with_capacity(len); | ||
for i in 0..len { | ||
if i % 10 == 0 { | ||
builder_128.append_value(i128::MAX); | ||
builder_256.append_value(i256::from_i128(i128::MAX)); | ||
} else { | ||
builder_128.append_value(i as i128); | ||
builder_256.append_value(i256::from_i128(i as i128)); | ||
} | ||
} | ||
let array_128 = builder_128.finish(); | ||
let array_256 = builder_256.finish(); | ||
|
||
c.bench_function("validate_decimal_precision_128", |b| { | ||
b.iter(|| black_box(array_128.validate_decimal_precision(8))); | ||
}); | ||
c.bench_function("null_if_overflow_precision_128", |b| { | ||
b.iter(|| black_box(array_128.null_if_overflow_precision(8))); | ||
}); | ||
c.bench_function("validate_decimal_precision_256", |b| { | ||
b.iter(|| black_box(array_256.validate_decimal_precision(8))); | ||
}); | ||
c.bench_function("null_if_overflow_precision_256", |b| { | ||
b.iter(|| black_box(array_256.null_if_overflow_precision(8))); | ||
}); | ||
} | ||
|
||
criterion_group!(benches, criterion_benchmark); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this used to avoid creating
ArrowError
and the error string for the cases that we don't need the error?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes