You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's a number of places in which we're missing having efficient dictionary data structures in tskit (mainly hash tables and AVL trees). See #1639 as a current example.
I wanted to start this thread to explore some possibilities for libraries that we could use, before we start considering rolling our own.
Some requirements:
Has to be fully cross platform
Embeddable - we can include it in our build, an external library dependency is not an option
License compatible with our MIT licence
Multi-threaded - anything that uses global library-level memory would be treated with deepest suspicion.
"Good". Other people should be using it in production, preferably for a long time.
Looking into libdict a bit more, the code does generally look good. The only thing I don't like really is that the library does all the mallocing rather than allowing the user to take control of mallocing the tree nodes. There is some facility to override this, but it's at the library level (you set the dict_malloc_func, which is then expanded by the MALLOC macro here), but this is worse. Maybe I'm worrying too much about keeping a lid on the number of small mallocs, though, and the library does look like it handles malloc errors pretty well.
Activity
jeromekelleher commentedon Aug 23, 2021
Looking into libdict a bit more, the code does generally look good. The only thing I don't like really is that the library does all the mallocing rather than allowing the user to take control of mallocing the tree nodes. There is some facility to override this, but it's at the library level (you set the dict_malloc_func, which is then expanded by the MALLOC macro here), but this is worse. Maybe I'm worrying too much about keeping a lid on the number of small mallocs, though, and the library does look like it handles malloc errors pretty well.
molpopgen commentedon Aug 30, 2021
Libdict sounds promising. Seems like making a quick set of benchmarks against the old libavl is worth it.
jeromekelleher commentedon Sep 1, 2021
I had a go at integrating libdict, and jeez this is tedious. I'm tempted to just get my copy of TAOCP and implement a balanced tree from scratch.
molpopgen commentedon Sep 1, 2021
Where's that XKCD about competing standards? ;)
jeromekelleher commentedon Sep 6, 2021
For the record, we went with an implementation of Knuth's version of an AVL tree. Much simpler than integrating an external library!