3 ms·
Looks nice. That said, if you want to reduce mallocs and encourage data locality, maybe you could try a more traditional tree implementation using a pool of nod
by zeroCalories 3y ago
Looks nice. That said, if you want to reduce mallocs and encourage data locality, maybe you could try a more traditional tree implementation using a pool of nodes similar to thread pools. I've found that most of my problems related to those were solved by such techniques.
- OnlyMortal 3y agoA custom pool for objects is often a good idea. Pre-allocate “enough” memory and dish them out as appropriate, releasing back to the pool when the reference count goes to zero. You can also use the pool to bound the maximum size you’re able to allow.
- mathiasgredal 3y agoWhy is this better than an arena style allocator?
- akoboldfrying 3y agoIt is an arena-style allocator. At least, if someone asked me to explain what an arena allocator is/does, I would say essentially what they wrote -- likely without the "disappears automatically once all references disappear" part, which is IMHO just a clever nice-to-have.
- OnlyMortal 3y agoYou allocate a large lump of memory up front and supply parts of it on demand. This would be different from an allocator which may allocate smaller amounts of memory as needed. This can help reduce memory fragmentation. It also helps to bound your memory usage. A request could block until memory was free.
- winrid 3y agoMan, if only something already did this. We could call it Oak... Or maybe Java? :)