planetarium / bencodex.net

Bencodex codec for .NET
https://www.nuget.org/packages/Bencodex
GNU Lesser General Public License v2.1
8 stars 11 forks source link

Change `Dictionary`'s internal data structure to trie #48

Open dahlia opened 3 years ago

dahlia commented 3 years ago

Currently Dictionary is a thin wrapper around ImmutableDictionry<K, V> (data structure wise). However, it does not share common data between copies, which is highly inefficient both space-wise and time-wise. I believe the memory consumption of Bencodex can be significantly reduced by changing its internal data structure to a trie which shares mutual data between instances rather than a naive hash map. As it would require much less memcpy, I expect it will be even faster than as is.

dahlia commented 3 years ago

Possibly useful projects:

Further reading: https://github.com/dotnet/runtime/issues/26001