Skip to content

--ConfigValue Updates - Matrix4 support, pointer-backed data store.#2363

Merged
jturner65 merged 6 commits intomainfrom
Configuration_Updates
Apr 22, 2024
Merged

--ConfigValue Updates - Matrix4 support, pointer-backed data store.#2363
jturner65 merged 6 commits intomainfrom
Configuration_Updates

Conversation

@jturner65
Copy link
Copy Markdown
Contributor

@jturner65 jturner65 commented Apr 17, 2024

Motivation and Context

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

Local c++ and python tests pass

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 17, 2024
@jturner65 jturner65 requested review from aclegg3 and mosra April 17, 2024 19:30
@jturner65 jturner65 marked this pull request as ready for review April 17, 2024 21:24
@jturner65 jturner65 requested a review from 0mdc April 22, 2024 13:08
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.
@jturner65 jturner65 force-pushed the Configuration_Updates branch from 58e1176 to 3666224 Compare April 22, 2024 13:32
Copy link
Copy Markdown
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.

Cool, LGTM

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