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

String default values don't need to be sized to the max length of the string. #5927

Closed
bzbarsky-apple opened this issue Apr 10, 2021 · 0 comments · Fixed by #11768
Closed

Comments

@bzbarsky-apple
Copy link
Contributor

Problem

Right now if we have a string attribute of at most 32 chars, it looks to me like ZAP allocates 32 bytes of storage for it both in the mutable attribute store and in the default value store.

Proposed Solution

In the default value store we could allocate less space: just enough to fit the actual value. This is particularly useful for the many strings that have empty string as default. Might save some .rodata.

One issue is whether that involves storing more state per-attribute in the attr descriptors, which will tend to bloat rodata. On the other hand, the default-value string stores its length anyway, so I don't think we need to add anything to the attr descriptors, just a bit of logic in the "determine the size in the default value store" code, I hope.

@vivien-apple @jepenven-silabs @jmartinez-silabs

bzbarsky-apple added a commit to bzbarsky-apple/connectedhomeip that referenced this issue Nov 13, 2021
Pulls in changes to make the default attribute storage for strings
depend on the actual string value, not the maximum size of the value.

Fixes project-chip#5927
bzbarsky-apple added a commit that referenced this issue Nov 15, 2021
Pulls in changes to make the default attribute storage for strings
depend on the actual string value, not the maximum size of the value.

Fixes #5927
PSONALl pushed a commit to PSONALl/connectedhomeip that referenced this issue Dec 3, 2021
Pulls in changes to make the default attribute storage for strings
depend on the actual string value, not the maximum size of the value.

Fixes project-chip#5927
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

1 participant