--ConfigValue Updates - Matrix4 support, pointer-backed data store. Rev 2.0#2369
Merged
--ConfigValue Updates - Matrix4 support, pointer-backed data store. Rev 2.0#2369
Conversation
By passing some boolean condition as a template argument, this macro acts like a template alias, and enables choosing template specializations based on some compile-time condition.
If a type is larger than 8 bytes, the ConfigValue holding it will hold a pointer to a pointer to the data (the _data array will be a pointer to the data), while the ConfigValue itself has been cut down in size by a factor of >4 (72 bytes each to 16 bytes each) . This change should be transparent to users.
copy construction seems to still be leaking in certain cases. These changes attempt to address this.
73a2cbe to
37b1f03
Compare
aclegg3
approved these changes
Apr 25, 2024
Contributor
aclegg3
left a comment
There was a problem hiding this comment.
Thanks for the thorough evaluation with valgrind. LGTM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
This is an updated, corrected version of an earlier PR which got merged before some leaks it was causing were caught and it was subsequently reverted. Mea culpa.
From Original PR :
This PR changes how esp::core::config::Configurations store data by having the underlying ConfigValue class store a pointer to the data in question instead of directly storing the data (i.e. the class member _data is now a pointer to a pointer to the data instead of a pointer to the data) if the data type is too large to be stored within the _data buffer. This PR also introduces, as a way to demonstrate this new feature, support for a new type in the configs, Magnum::Matrix4.
Currently on main branch, every ConfigValue includes a buffer that holds the actual data being consumed; due to the size of this buffer, every ConfigValue takes up 72 bytes of memory. This PR decreases this to 16 bytes + whatever heap allocation is necessary to hold the larger-than-8 byte types (the config value consists of a data array, now 8 bytes, and an enum denoting the type, 4 bytes, along with 4 bytes padding.)
Here's the memory footprint for each ConfigValue, along with any heap allocation if necessary (for larger objects), in this PR.
How Has This Been Tested
C++ and python tests pass
Valgrind on viewer.cpp for leak detection
Types of changes
Checklist