-
Notifications
You must be signed in to change notification settings - Fork 272
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
Use of pImpl pattern #1327
Comments
I think the link you refer to explains it rather well? Herb also has lot's of posts on the topic, e.g. https://herbsutter.com/gotw/_100/ |
@ronag the links do indeed explain what pImpl pattern is, but not the motivation for its use in CCG server. From the first link: "This technique is used to construct C++ library interfaces with stable ABI and to reduce compile-time dependencies."
From the 2nd link: "In C++, when anything in a header file class definition changes, all users of that class must be recompiled – even if the only change was to the private class members that the users of the class cannot even access."
Did I miss anything? |
It's compile time. When working on CCG and compiling dozens of times while developing even small compile time differences make huge difference in developer ergonomics. At least for me. Also, not all of use have access to powerful machines. Some of us work on laptops.
Absolutely. Depends though on how many other files depend on the file being modified. |
If that's the only issue, @dotarmin could we organize a proper development laptop for @ronag? 😜 In all seriousness though, we all know there is no free lunch. So, the gain at compile time comes at a cost of runtime overhead. In your defense, I myself don't have any concrete benchmarks to show how that affects runtime performance, but I do remember reading that pImpl inhibits certain types of optimizations (unless LTO is enabled). And from maintenance perspective, each pImpl class requires a set of boilerplate forwarding functions, which may also lead to bugs. The article I've linked to in the beginning has a bit more details. Anyway, not trying to knock on you. As one of the top contributors to the project, I have but full respect for you. I mainly just wanted to clarify it for myself and maybe inject some critical thinking 😀 |
It's negligible. We don't use it in any performance sensitive parts. |
I see the pImpl pattern being heavily used in the CCG server code and I was wondering what is the motivation for it.
The text was updated successfully, but these errors were encountered: