Skip to content
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

--ConfigValue Updates - Matrix4 support, pointer-backed data store. Rev 2.0 #2369

Merged
merged 11 commits into from
Apr 26, 2024

Conversation

jturner65
Copy link
Contributor

@jturner65 jturner65 commented Apr 25, 2024

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.

**Type        New**
ConfigValue buffer stores value : 
bool          16
int           16
double        16
Vector2       16
Mn::Rad       16
ConfigValue buffer stores ptr to value : 
Vector3      16   12
Vector4      16   16   (same for quaternion)
Matrix 3     16   36
String       16   32
Matrix4 (incoming in this PR) 16   64

How Has This Been Tested

C and python tests pass

Valgrind on viewer.cpp for leak detection

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have completed my CLA (see CONTRIBUTING)
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Apr 25, 2024
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.
@jturner65 jturner65 force-pushed the Configuration_Updates branch from 73a2cbe to 37b1f03 Compare April 25, 2024 20:21
@jturner65 jturner65 changed the title --[WIP]ConfigValue Updates - Matrix4 support, pointer-backed data store. Rev 2.0 --ConfigValue Updates - Matrix4 support, pointer-backed data store. Rev 2.0 Apr 25, 2024
@jturner65 jturner65 requested a review from aclegg3 April 25, 2024 20:59
@jturner65 jturner65 marked this pull request as ready for review April 25, 2024 20:59
@jturner65 jturner65 requested a review from mosra April 25, 2024 21:39
Copy link
Contributor

@aclegg3 aclegg3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the thorough evaluation with valgrind. LGTM

@jturner65 jturner65 merged commit 0f9ca1d into main Apr 26, 2024
10 checks passed
@jturner65 jturner65 deleted the Configuration_Updates branch April 26, 2024 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants