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

Reserve space for additional instances in binary deserializer #465

Merged
merged 5 commits into from
Oct 30, 2024

Conversation

kennethloeffler
Copy link
Member

@kennethloeffler kennethloeffler commented Oct 29, 2024

This PR adds a new method WeakDom::reserve that can preallocate additional space for instances, and makes the binary deserializer use it before adding instances.

On my machine, this improves rbx_binary's "Deserialize 10,000 Parts" benchmark by ~4%, reduces the number of heap allocations by a negligible amount, but allocates ~2.4MB less memory.

I'm not sure if this should also call reserve on WeakDom.unique_ids, because UniqueIds won't always be present in inputs, and it could take a possibly significant amount of space for no reason.

@kennethloeffler kennethloeffler changed the title Weak dom reserve Reserve space for additional instances in binary deserializer Oct 29, 2024
Copy link
Member

@Dekkonot Dekkonot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't reserve extra space in unique_ids it'll make deserializing a place file have a fair few allocations still. This optimization is still worth doing but it's something to keep in mind.

rbx_dom_weak/CHANGELOG.md Outdated Show resolved Hide resolved
@kennethloeffler
Copy link
Member Author

kennethloeffler commented Oct 30, 2024

It doesn't seem to make much a difference for a 6MB rbxl file on my machine, but I guess it won't hurt, since truly massive rbxm files aren't very common anyway

@Dekkonot
Copy link
Member

Hilariously for Adopt Me (65MB), it seems to actually make it take longer to deserialize with the UniqueId reservation. If I went through the trouble of checking our full Rojo project it might be more dramatic, since we have around 6000 models with UniqueId written in them, but that's work I don't feel like doing right now.

The difference for Adopt Me is like 11%, so we may want to just not bother with UniqueId reservation.

@kennethloeffler
Copy link
Member Author

Well, that's a bit weird! 🤔

@kennethloeffler kennethloeffler merged commit 70e70fd into rojo-rbx:master Oct 30, 2024
3 checks passed
@kennethloeffler kennethloeffler deleted the weak-dom-reserve branch October 30, 2024 20:21
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