-
Notifications
You must be signed in to change notification settings - Fork 66
[DO NOT MERGE] Find Windows empty base class inefficiency #842
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
[DO NOT MERGE] Find Windows empty base class inefficiency #842
Conversation
Visual Studio doesn't implement the empty base class optimisation by default in cases of multiple inheritance. To preserve ABI backwards compatibility it only does this when explicitly told. The secret `/d1reportClassLayoutChanges` option will reveal where we might benefit from using `__declspec(empty_bases)`. Relates elastic#840
consoleText.txt from the Windows PR CI build contains the special output. Search for "Future Default Layout" to see the opportunities. For example one is:
The second base class adds 1 byte to the object size, but then padding for alignment increases that to 8 bytes. Many of the classes that would benefit from the optimisation appear to be in the standard library (which Microsoft will not change until the next ABI-breaking release of Visual C++) and Eigen (which we're not allowed to edit because it's under the MPL). Still, there may be a few opportunities for making our code more memory-efficient on Windows. |
This is a way to find our classes in the output:
So, the list of classes that can benefit from
|
Cool stuff! |
The empty base optimization is not used by default with multiple inheritance on Windows, but can be enabled using __declspec(empty_bases). The investigation in elastic#842 shows which of our classes would benefit, so this PR adds the required option to the 5 affected classes.
#844 has the fixes. |
The empty base optimization is not used by default with multiple inheritance on Windows, but can be enabled using __declspec(empty_bases). The investigation in #842 shows which of our classes would benefit, so this PR adds the required option to the 5 affected classes.
The empty base optimization is not used by default with multiple inheritance on Windows, but can be enabled using __declspec(empty_bases). The investigation in elastic#842 shows which of our classes would benefit, so this PR adds the required option to the 5 affected classes. Backport of elastic#844
Visual Studio doesn't implement the empty base class
optimisation by default in cases of multiple inheritance.
To preserve ABI backwards compatibility it only does this
when explicitly told.
The secret
/d1reportClassLayoutChanges
option will revealwhere we might benefit from using
__declspec(empty_bases)
.Relates #840