Skip to content
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

refactor!: Replace immutable-chunkmap with dual tree states #495

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mwcampbell
Copy link
Contributor

I'm doing this because I want to minimize the temporary allocations that are needed when applying a tree update. Ideally, if the tree update doesn't add any new data, there should be zero temporary allocations; we should be able to reuse existing collections to apply the update in-place. Since our event handling is built around having a full, consistent snapshot of the tree before the update, and that is now quite a fundamental feature of our design, I've concluded that we need to keep two copies of the tree state at all times. So that means double the memory usage. I'm betting that in most cases, the application uses most of its memory on things other than the accessibility trees, and that on truly memory-constrained systems, the gains from having fewer temporary allocations (and thus less risk of memory fragmentation) outweigh the downside of doubled memory usage for the tree state.

Importantly, the amount of copying that has to be done on each update is proportional to the number of nodes that were actually added, changed, or removed, not the size of the whole tree.

As a bonus, this also eliminates a third-party dependency for which we were the primary user, and reduces compiled code size (by 17.5 KB on x64 Windows).

I have more work to do to minimize temporary allocations, but am submitting this PR now to find out if we're in agreement about going in this direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant