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

Don't create queue in WeakDom::insert for leaf instances #463

Conversation

kennethloeffler
Copy link
Member

This PR adds a fast path for leaf instances to WeakDom::insert. When an instance does not have any children, then we don't need to create a queue, avoiding a heap allocation, and can perform the insertion then exit the method immediately.

On my machine, this improves rbx_binary's "Deserialize 10,000 Parts" benchmark by ~4%, and reduces the number of heap allocations by ~7%. Note that the effectiveness of this optimization depends on how many leaf instances the requested insertion has, so this improvement is probably overstated on this benchmark, which contains vastly more leaf instances than internal instances.

@kennethloeffler kennethloeffler merged commit 69f3acc into rojo-rbx:master Oct 29, 2024
3 checks passed
@kennethloeffler kennethloeffler deleted the weakdom-insert-no-child-fast-path branch October 29, 2024 20:25
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.

2 participants