Skip to content

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.
@random-zebra random-zebra force-pushed the 202101_AkioNak_unserialize branch from a6eaa7a to b886a4c Compare January 19, 2021 16:31
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

@random-zebra random-zebra requested a review from furszy January 25, 2021 09:37
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