-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DRAFT] - Try to optimize preorder iteration with pool allocation #121
base: master
Are you sure you want to change the base?
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.