-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-12165: [Rust] inline append functions of builders #9860
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
Conversation
nevi-me
left a comment
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.
This makes sense, there's lots of appending going on here 😵
|
@ritchie46 did you have some perf results on this? |
rust/arrow/src/array/builder.rs
Outdated
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.
This seems a large function to inline? Maybe we need to be conservative here and not mark it as inline
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.
Ok, I will remove that one.
There are quite some functions, but for met the most important one is the primitive builder. Running this benchmark: fn create_primitive_array(n: usize) -> PrimitiveArray<Int64Type> {
let mut builder = PrimitiveBuilder::new(n);
for i in 0..n {
builder.append_value(i as i64).unwrap();
}
builder.finish()
}
fn add_benchmark(c: &mut Criterion) {
c.bench_function("512", |b| b.iter(|| create_primitive_array(512)));
c.bench_function("4096", |b| b.iter(|| create_primitive_array(4096)));
}Gave the following improvement: PrimitiveBuilderStringBuilderFor a |
fcd2dee to
1cb93ee
Compare
Is there a reason not to remove this? Backwards incompatibility changes are already happened, so maybe we can remove this? |
|
@ritchie46 quite nice micro benchmark results 👍
I don't think there is any reason. I tried to do it some time ago, but it requires a lot of work as it is used in quite some code as you can imagine. |
Codecov Report
@@ Coverage Diff @@
## master #9860 +/- ##
==========================================
- Coverage 82.61% 82.60% -0.01%
==========================================
Files 254 255 +1
Lines 59583 59588 +5
==========================================
Hits 49225 49225
- Misses 10358 10363 +5
Continue to review full report at Codecov.
|
Yeah I agree it would make the API easier to work with if the builders didn't return |
alamb
left a comment
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.
Thanks @ritchie46 -- this looks great to me
The
appendfunctions in theBuilderstructs are often used in "hot" code. This PR tags them with#[inline], making it possible to inline the function calls across crate boundaries.