[DRAFT] - Try to optimize preorder iteration with pool allocation#121
[DRAFT] - Try to optimize preorder iteration with pool allocation#121theo-lw wants to merge 11 commits intorust-analyzer:masterfrom
Conversation
|
Yeah, in general, it is a reasonable assumption that at any given point at time there are only few live nodes for any given tree. (although might be good to check that using rust-analyzer's analysis_stats). So it'd be cool to just add nodes to / pop them from a free-list. Ideally, tree traversal which doesn't retain nodes shouldn't do any allocation or atomic ops. In the original implementation, this was achieved by using a thread-local free-list of nodes. As it turned out several years later, at least my implementation of that apporoach was slower than just allocating the nodes. |
Yeah right now my implementation isn't faster than just allocating the nodes. Maybe this is a fruitless endeavour. |


Preorder iteration allocates O(size of tree) nodes. However, there are some cases where only O(height of tree) nodes are alive at a given time. I'm trying to see if using a pool allocator can help avoid excess allocations in this case.