-
Notifications
You must be signed in to change notification settings - Fork 49
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
Reserve space for additional instances in binary deserializer #465
Conversation
There was a problem hiding this 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.
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 |
Co-authored-by: Micah <[email protected]>
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 The difference for Adopt Me is like 11%, so we may want to just not bother with |
This reverts commit a935a02.
Well, that's a bit weird! 🤔 |
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
onWeakDom.unique_ids
, because UniqueIds won't always be present in inputs, and it could take a possibly significant amount of space for no reason.