Skip to content
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

[Core] Prevector Optimizations 2 #2148

Merged
merged 3 commits into from
Jan 25, 2021

Conversation

random-zebra
Copy link

Backports bitcoin#12324.
The DeserializeAndCheckBlock benchmark (introduced in #2146) shows a speedup of about 4% (not as much as the upstream PR, due to the optimizations already included in #2083).

Cherry-picks also

JeremyRubin and others added 3 commits January 19, 2021 17:30
The unserializer for prevector uses resize() for reserve the area,
but it's prefer to use reserve() because resize() have overhead
to call its constructor many times.

However, reserve() does not change the value of "_size"
(a private member of prevector).

This PR introduce resize_uninitialized() to prevector that similar to
resize() but does not call constructor, and added elements are
explicitly initialized in Unserialize_imple().

The changes are as follows:
1. prevector.h
Add a public member function named 'resize_uninitialized'.
This function processes like as resize() but does not call constructors.
So added elemensts needs explicitly initialized after this returns.

2. serialize.h
In the following two function:
 Unserialize_impl(Stream& is, prevector<N, T>& v, const unsigned char&)
 Unserialize_impl(Stream& is, prevector<N, T>& v, const V&)
Calls resize_uninitialized() instead of resize()

3. test/prevector_tests.cpp
Add a test for resize_uninitialized().
Identifiers beginning with an underscore followed immediately by an uppercase letter are reserved.
Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a comment

Choose a reason for hiding this comment

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

utACK b886a4c

Copy link

@furszy furszy left a comment

Choose a reason for hiding this comment

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

utACK b886a4c and merging..

@furszy furszy merged commit 07b88da into PIVX-Project:master Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants