Improve memory footprint of JobOptionsSvc
Reduce the memory footprint of JobOptionsSvc by replacing the internal unordered_map<string,PropertyRef>
to unordered_map<PropertyId,PropertyRef>
where PropertyId
uses a vector of pointers to global string instances to save space.
The implementation consists two classes: SharedString
and PropertyId
.
SharedString
translates string
to const string*
where the actual string is stored in an unordered_set<string>
so that we use always the same chunk of memory for duplicated strings. In this way the memory used by a string is one pointer per copy plus the unordered_map
metadata plus the actual size of the string.
PropertyId
translates a string in the format "chunk.chunk.chunk" in a vector of SharedString
instances, one per chunk, plus the std::hash
of the original string.
I did not manage yet to measure (or calculate) how much memory we save in this way.
Closes #194 (closed)