concordium-base icon indicating copy to clipboard operation
concordium-base copied to clipboard

Optimizations of the trie implementation

Open abizjak opened this issue 2 years ago • 0 comments

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 and MutStem 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.

abizjak avatar Mar 21 '22 20:03 abizjak