-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
Improve exception safety with smart pointers #128
Comments
@elfring, thanks for pointing these out! IIRC, I actually was using smart pointers in both of these parts of the code a one point or another. I ended reverting to raw pointers after performance on some machines turned out to be faster with the raw pointers (I don't remember which machines... probably worthwhile to measure again). I've asked some more advanced C++ programmers about this, and the consensus is that using smart pointers "should be" just as fast as raw pointers. I've wondered if there's some compiler flags or something similar that I need to change to make sure the compiler optimises smart pointers to the fullest extent possible. In the meantime, I'm not terribly worried about memory-safety in these parts of the code, since their construction/destruction code will only ever be called in a very controlled way. That said, I'd be happy to hear if you have any suggestions for improving the memory-safety/smart-pointer performance situation. If you need to measure the performance yourself, I've been writing up small blurb on how to measure the performance using the ChowTape headless tool, but I haven't finished yet. Basically, you can build headless by running: cmake -Bbuild -DBUILD_HEADLESS=True
cmake --build build --target ChowTapeModel_Headless and then run the benchmarking tool with |
🤔 How do you think about to take the C++ guideline “R.11: Avoid calling new and delete explicitly” into account? |
Yes, I'm aware that using For the moment, I'd say there are two things that would make me switch back to using smart pointers in these parts of the code:
Relatively speaking, this is not a very large program, and the All that said, I would love to be proven wrong! Have you experienced any issues with the plugin related to memery allocation? Or, in your experience, are there tricks to using smart pointers to handle arrays without introducing this overhead? |
I dare to point implementation details out for further development considerations.
|
Yes, and thank you for pointing them out! Sorry if I came off as rude or dismissive, that was certainly not my intention. I was simply trying to explain why these decisions were made originally (I think sometime in July?).
I have tried this before for FIR filters (in a different codebase), and I remember abandoning that approach for similar performance considerations. The other approach I've tried has been using I think what might be best for me to do is to write 3 implementations, one with raw pointers, one with smart pointers, and one with Thanks, |
I did not interpret your feedback in such a direction.
The explanation approach was helpful to some degree. |
So it took me a lot longer that I expected, but I was able to convince myself that I can do FIR filtering with The raw pointers in the |
Would you like to wrap any pointer data members with the class template “std::unique_ptr”?
Update candidates:
The text was updated successfully, but these errors were encountered: