You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR added initialization of etl::optional's storage buffer in the empty-state constructors to avoid compiler warnings.
A problem with this is that now constructing optionals in the empty state requires value initialization (rather than trivial default construction, which "performs no action") of the storage buffer to 0's, which can be quite inefficient in some cases. (See Explanation 3 and Trivial default constructor):
Looking at the std::optional implementations, it looks like some zero-initialize the storage and some don't.
I'm not sure what the best solution is here; being warning-clean is essential, but the extra overhead of the zero-init can be substantial. In my case, this causes ~10% CPU overhead during fairly frequently executed operations when using a not-very-large optional (~36B). I can work around it locally, but it may be a surprising performance hit for users in general. I suppose the [[maybe_unused]] attribute might be used to suppress the warnings, but that's C++17.
Any thoughts? Thanks.
The text was updated successfully, but these errors were encountered:
I think there are a couple of other classes that do the same as etl::optional to suppress warnings. I may need to disable that warning for the constructors.
Hi,
This PR added initialization of
etl::optional
's storage buffer in the empty-state constructors to avoid compiler warnings.A problem with this is that now constructing optionals in the empty state requires value initialization (rather than trivial default construction, which "performs no action") of the storage buffer to 0's, which can be quite inefficient in some cases. (See Explanation 3 and Trivial default constructor):
See https://godbolt.org/z/jMd59sc9T.
Looking at the
std::optional
implementations, it looks like some zero-initialize the storage and some don't.I'm not sure what the best solution is here; being warning-clean is essential, but the extra overhead of the zero-init can be substantial. In my case, this causes ~10% CPU overhead during fairly frequently executed operations when using a not-very-large optional (~36B). I can work around it locally, but it may be a surprising performance hit for users in general. I suppose the
[[maybe_unused]]
attribute might be used to suppress the warnings, but that's C++17.Any thoughts? Thanks.
The text was updated successfully, but these errors were encountered: