-
Notifications
You must be signed in to change notification settings - Fork 390
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
faster iox::vector on POD data #2082
Comments
@lucabart97 go for it :) Just to be sure, struct Point
{
float x{};
float y{};
float z{};
}; There is another optimization opportunity for copy and move for trivially copyable and trivially movable types. Here a simple memcpy would also speed up the operations. |
I just discovered that |
So the idea would be to specialize the I like it. |
@elfenpiff exactly. The same would apply to inserting elements. Just a memcpy and no move or copy opreations |
This type is a POD, so it will be true.
Yes |
For code legibility and length, I prefer |
@lucabart97 You are right, this is better. But please don't use @elBoberido I think we should start to use C++17 now officially. I think we already have an agreement across all committers that we want to have this. Any objections? |
AFAIK the agreement was to switch to C++17 after the |
@mossmaurice @elfenpiff in the September developer meetup I argued for a switch after the v3.0 release and the fellow developers agreed. But I come more and more to the conclusion that the switch to C++17 might actually be one of the main reasons to do a v3.0 release. As you know, there a no new major features in iceoryx itself but "only" some bigger refactorings. Up until now everybody was happy to hear about a switch to C++17 and nobody objected, which was one of the reasons I proposed to do it after the v3.0 release. Therefore I would like to reconsider the decision made in September and move to C++17 ASAP. If there are objections we could discuss this in the next developer meetup. |
@lucabart97 thanks for checking all the variants with |
@elBoberido I'm waiting for the decision for the C++17, we could use an |
@lucabart97 sounds good. We will have a decision at the end of the week. I'll ping you once I know more |
@lucabart97 we decided to move to C++17 with the v3.0 release and I will open an PR later today. Once that is merged you can use the whole beauty of the C++17 features |
I do not understand this part of the code, why there is an operator iceoryx/iceoryx_hoofs/container/include/iox/detail/vector.inl Lines 165 to 176 in 51a018a
|
@lucabart97 because the memory at that position is not initialized and using copy assignment would be undefined behavior for non trivial types. Therefore it needs to be constructed, either by placement new with forwarding of the ctor arguments or by placement new with the copy constructor. |
Optimize the vector class by specializing it for plain old data (POD) types, thereby eliminating the need for explicit constructors, destructors, and copy operators in the vector operations. Signed-off-by: Luca Bartoli <[email protected]>
Optimize the vector class by specializing it for plain old data (POD) types, thereby eliminating the need for explicit constructors, destructors, and copy operators in the vector operations. Signed-off-by: Luca Bartoli <[email protected]>
Optimize the vector class by specializing it for plain old data (POD) types, thereby eliminating the need for explicit constructors, destructors, and copy operators in the vector operations. Signed-off-by: Luca Bartoli <[email protected]>
Optimize the vector class by specializing it for plain old data (POD) types, thereby eliminating the need for explicit constructors, destructors, and copy operators in the vector operations. Signed-off-by: Luca Bartoli <[email protected]>
Optimize the vector class by specializing it for plain old data (POD) types, thereby eliminating the need for explicit constructors, destructors, and copy operators in the vector operations. Signed-off-by: Luca Bartoli <[email protected]>
iox-#2082 faster vector on POD data
@lucabart97 I think I screwed up a bit and we need to revert something from the last PR. The I totally overlooked that struct Point
{
float x;
float y;
float z;
}; would end up with I think this optimization should only be done if the user explicitly opts in, e.g. via a Do you have time to revert that piece of code? If not, I can take care of it. Sorry for the inconvenience. |
Depends on how quickly it needs to be done! |
No problem. I can sneak it into my next PR :) |
…ation-for-iox-vector-elements iox-#2082 Always initialize members in 'iox::vector(count)'
Brief feature description
The current implementation of
iox::vector
calls constructor and destructor also on POD data, this may slow the application if some big different resizes are done.Detailed information
Small example, a pointcloud with 1M points
result:
The results are calculated on my PC with Intel processor, when you use ARM (Eg. jetson) trust me, the time is very high.
Improve the code (my suggestion)
Check the template data with
std::is_pod<>
to avoid constructor and deconstructor calls on POD data.The text was updated successfully, but these errors were encountered: