The ImmutableData Programming Guide: Benchmarks
Something I haven't been seeing too much publicity for is the TreeDictionary
that shipped in swift-collections
.^1
TreeDictionary
is — for the most part — a drop-in replacement for Swift.Dictionary
. The implementaion leverages structural sharing and CHAMP data structures. This means we can expect logarithmic-time operations to copy-on-write; Swift.Dictionary
would copy-on-write in linear-time.
These benchmarks were originally part of The ImmutableData Programming Guide and the ImmutableData
project, but don't have any dependencies on the ImmutableData
infra.
This data structure can have big performance wins for CPU and Memory at scale. Try the benchmarks on your own data models and see if this can work for you.