Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[move][stdlib] Add efficient BigOrderedMap implementation (#14753)
## Description Having efficient and concurrent large-sized "Map" and "OrderedMap" implementations is useful across variety of needs. Current SmartTable implementation has various limitations, from it being sequential, to it not having smart ways to deal with collisions. It cannot be improved - as the structs are unmodifiable, and so should be deprecated fully. In this PR: * provide efficient big "OrderedMap" implementation. BPlusTreeMap is chosen as it is best suited for the onchain storage layout - where majority of cost comes from loading and writing to storage items, and there is no partial read/write of them. It also rebalances in a way that reduces amount writes needed * writing to keys that are not close enough, to a BPlusTreeMap with multiple layers, is generally parallel. More elements in the BPlusTreeMap, the more operations will be parallel. * it is an enum, so can be evolved in the future as needed * has an option to pre-pay and pre-allocate storage slots, and to reuse them, achieving predictable gas charges. * defined potentially generally useful StorageSlotsAllocator, to manage indexed storage slots for datastructures that need it. Easier to use and more flexible/configurable than directly using Table. (which is also an enum, and so can be evolved / new strategies can be added) * keeps root note directly inside the resource, to reduce number of resources needed by 1, and optimizes operations when root is the leaf node. * whenever key or value is inserted/modified, we check the size to make sure it is allowed (i.e. that it is smaller than max_node_size / max_degree). this requires bcs::serialized_size() call on every insert/upsert. * in case types have constant sizes, check is performed once, on construction, and then it’s skipped on insert/upsert
- Loading branch information