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

Remove vector.reserve() from hot path in cloud concatenation #3361

Merged
merged 2 commits into from
Sep 24, 2019

Conversation

kunaltyagi
Copy link
Member

@kunaltyagi kunaltyagi commented Sep 24, 2019

reserve in GCC and in clang with libstdc++ causes multiple allocations. Removing reserve allows similar logic to work in both cases.

Also fixed an out of bounds memory access due to use of reserve in place of resize

@jasjuang This fixes the speed issue.

Fixes performance degradation caused by #3320 (see #3320 (comment)).

Copy link
Member

@taketwo taketwo left a comment

Choose a reason for hiding this comment

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

Thanks for the investigation and quick fix. Please split into two commits and also add a short justification to the message for the reserve removing commit. This will simplify our lives if, in two-three years from now, we need to investigate some issues with the function.

common/include/pcl/point_cloud.h Outdated Show resolved Hide resolved
common/src/PCLPointCloud2.cpp Outdated Show resolved Hide resolved
common/src/PCLPointCloud2.cpp Outdated Show resolved Hide resolved
@jasjuang
Copy link
Contributor

Can confirm this speeds it up again. Please merge!

@taketwo taketwo changed the title Remove reserve from hot path Remove vector.reserve() from hot path in cloud concatenation Sep 24, 2019
@taketwo taketwo merged commit 1189a91 into PointCloudLibrary:master Sep 24, 2019
@kunaltyagi kunaltyagi deleted the fix_reserve branch September 24, 2019 22:40
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.

3 participants