concordium-base
concordium-base copied to clipboard
Optimizations of the trie implementation
Task description
There are several opportunities for optimizations of the trie implementation, both space and time wise.
At least the following ones should be considered. Any changes should be accompanied by meaningful benchmarks or arguments why memory use is reduced.
Sub-tasks
- [ ] The
Stem
andMutStem
types contain a "stem", a list of bytes. In the vast majority of cases, for non-malicious use, these will be very short, very rarely above 40 bytes. Thus a small-scale optimization where we would use something like tinyvec/smallvec for storing the key inline if it is small could be very beneficial to both performance, and reducing memory pressure and fragmentation. - [ ] When serializing (and in store_update) the node's children we now waste a full byte for the child tag. This is wasteful since we could just use the top 4 bits of the
Reference
, still leaving 60 bits to address, which is more than will ever be needed.