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

vector deserialization is speeded up a little #1704

Merged
merged 2 commits into from Aug 6, 2015

Conversation

AntonBikineev
Copy link
Contributor

The speedup is palpable in cpp-serializers benchmark when serializing strings.

@@ -23,13 +23,11 @@ namespace hpx { namespace serialization
ar >> size; //-V128
if(size == 0) return;

vs.reserve(size);
vs.resize(size);
Copy link
Member

Choose a reason for hiding this comment

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

resize() causes the default c-tors of all objects in the vector to run, which can be costly. I don't see how this would lead to a speed-up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can see that for the old version there is already default construction of temporary object inside the loop value_type v; , which later is moved to vector by push_back. This commit is only about avoiding this extra moving by default construction of objects and their deserialization right inside the vector.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, got it. Totally makes sense. Thanks!

@hkaiser
Copy link
Member

hkaiser commented Aug 6, 2015

LGTM, nice catch! This is not only to avoid the move. Especially for non-movable types this saves us a copy operation.

@hkaiser
Copy link
Member

hkaiser commented Aug 6, 2015

@AntonBikineev BTW, nice job on the overall performance of the serialization code: https://github.com/STEllAR-GROUP/cpp-serializers! We should write a blog post about this, somewhere!

hkaiser added a commit that referenced this pull request Aug 6, 2015
…alization

vector deserialization is speeded up a little
@hkaiser hkaiser merged commit 6516a1b into master Aug 6, 2015
@hkaiser hkaiser deleted the speeding_up_vector_deserialization branch August 6, 2015 22:16
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.

None yet

3 participants