Reimplement boost::split and optimize tokenization#5285
Reimplement boost::split and optimize tokenization#5285mvieth merged 2 commits intoPointCloudLibrary:masterfrom
Conversation
c32ba62 to
7402a6e
Compare
|
Thank you! This looks very promising.
|
|
Hi, Thanks for taking a look at this and for nice initial comments :)
Sure thing! Currently, I am a bit swarmed by everything but I will try to find time in order to do it. I think I will be able to do it in a week or something like that.
First and biggest thing why see iter_find.hpp:186 here https://github.com/boostorg/algorithm/blob/00c6f1d6c10508d06598466a15190fc9812c9100/include/boost/algorithm/string/iter_find.hpp#L186 The other thing is functor copy constructions that happen because functors that do the splitting are not trivial and they need a heap allocation. Quick note, I don't fully understand this part so this is maybe gibberish.. Implementation in the boost starts to get magical around this point... I am attaching full DHAT report generated from master branch without changes in this PR. You can check it out by opening: If I get smarter about this in the meantime, I will try to correct myself here. Thanks, Darko |
This commit reimplements boost::split in a io/split.h. Implementation is then used for obj and pcd file parsing. Boost::split was reimplemented because the function was aggressively allocating new memory in a hot parsing loops and that was slowing down sequential and parallel execution. New implementation is generic in way that it will work with current std::vector<std::string> result type but also with a std::vector<std::string_view> result type. Signed-off-by: Darko Janekovic <darko.janekovic@gmail.com>
4068d49 to
eeb2e20
Compare
|
Hi, I pushed one set of tests for |
|
Thank you for the insight into |
Signed-off-by: Darko Janekovic <darko.janekovic@gmail.com>
eeb2e20 to
0f42b35
Compare
|
These two new test cases are added |
mvieth
left a comment
There was a problem hiding this comment.
Great, thank you! This is a really nice speed/memory improvement!
|
Thanks! First and hopefully not the last improvement from me :) |
Hi all!
This PR is addressing #4333.
Boost::split was pretty aggressive with allocations and they were slowing down parallel and sequential execution.
New implementation is generic in way that it will work with current
std::vector<std::string>result type but it should also work with C++17std::string_viewinstead ofstd::string.Implementation of
pcl::splitis currently used for pcd and obj file parsing, see benchmarks below.Before:
After:
Just a minor comment, majority of allocations in obj_io.cpp is now done in
boost::lexical_cast. I think I could optimize it away since it is a bit of overkill there but that would be a new PR and I would need to experiment a bit.Thanks in advance and kind regards,
Darko