-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Improve performance of DataPage statistics extraction using StringBuilder #11281
Comments
take |
Ok... after profiling and reading the codes again, I got it about the The Strange results got from my poc... let iter = iter.into_iter();
let mut builder = GenericByteBuilder::with_capacity(iter.size_hint().0, 1024);
builder.extend(iter);
builder.finish() It seems that In theory, However the bench results are:
The difference I found now is that the |
Yes - the primary (initial) problem is that the collection needs to be built so that it owns the references to the items but we want to do that without creating any intermediate values. I would also have naively expected that The choice depends on lifetimes, so perhaps the other one is being invoked and it's not pre-allocating capacity in as efficient a way? In general, I think you're right that we should be able to eliminate all intermediate vectors. |
😂 Sorry, it seems my statement made some misunderstandings? But still somethings confused me now... When using the builder directly, looping in
I can understand some costs exist when using flatten, but it may should not be so obvious? |
Maybe the compiler is not smart enough to avoid bounds checks or something when using |
Maybe it is actually due to compiler...
|
Originally posted by @efredine in #10922 (comment)
The StringBuilder pattern you suggested in #11136 (comment) does seem to materially improve performance:
So seems like a worthwhile thing to go ahead with? I think there are several places where we can do something similar.
The text was updated successfully, but these errors were encountered: