Reduce size of submap by changing submap::camp to unique_ptr #34938
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.
Summary
SUMMARY: Infrastructure "Reduce submap size by changing submap's camp member to unique_ptr"
Purpose of change
Reduce size of submap instance by replacing embedded basecamp with as-needed allocation of basecamp.
Describe the solution
Change
submap
'scamp
member frombasecamp
tostd::unique_ptr<basecamp>
so that we do not pay the memory cost of a basecamp for every submap instance, even when that basecamp is not considered valid. Switching frombasecamp
tostd::unique_ptr<basecamp>
reduces the size ofsubmap
by ~28%.Additional context
Most submaps do not have valid basecamps. Embedding basecamp (8704 Bytes) that are not used by most submaps is wasteful and unnecessary. Without z-levels enabled, the reality bubble (11x11 submaps) will use 1053184 Bytes, just over 1 MiB, on basecamp data with most/all of it in an invalid state. With z-levels enabled this increases to 22116864 Bytes, ~21.09 MiB, of basecamp data for submaps within the reality bubble.