Remove memref references from each data object #390
Merged
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.
Memrefs are managed by the runtime, and were only stored directly in the data objects when calling the old (pre-rc_runtime_t) functions to manage the objects. This PR eliminates the unused reference from the data objects, and provides a container when using the pre-rc_runtime_t functions.
This change saves 8 bytes for every trigger and value, and 40 bytes for every leaderboard (as it contains three triggers and a value) when managed by the runtime (either
rc_runtime_t
orrc_client_t
), which most (if not all) clients should be using. Constructing these items outside of the runtime (legacy support) will allocate an extra 40 bytes per item for managing the chunks (described below).This also turns the memref collection from a linked list of
rc_memref_t
s to a linked list of chunks ofrc_memref_t
s, which eliminates 8 bytes from each memref, but adds 16 bytes for each chunk. The minimum chunk size is 8 elements, so that's a net gain of 48 bytes per chunk, and potentially more when larger chunks are allocated. The initial runtime chunk is 32 elements.There are also marginal performance gains for processing the memrefs as an array instead of a linked list.