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

Preallocate property tables during deserialization #464

Merged

Conversation

kennethloeffler
Copy link
Member

@kennethloeffler kennethloeffler commented Oct 29, 2024

This PR adds a new method InstanceBuilder::with_property_capacity which can preallocates InstanceBuilder.properties, and makes the rbx_xml and rbx_binary deserializers use it. Since we know how many properties any given instance will (likely) contain via the reflection database, this allows us to avoid resizes during deserialization.

On my machine, this improves rbx_binary's "Deserialize 10,000 Parts" benchmark by ~17%, and reduces the number of heap allocations by ~32%.

The fact that we're using the database's default properties to determine the capacity is a little hairy - we've discussed normalizing default properties in the database in #418, so we should remain mindful of this optimization, lest we inadvertently regress performance.

rbx_dom_weak/CHANGELOG.md Outdated Show resolved Hide resolved
@kennethloeffler kennethloeffler merged commit e909f45 into rojo-rbx:master Oct 29, 2024
3 checks passed
@kennethloeffler kennethloeffler deleted the property-table-prealloc branch October 29, 2024 21:42
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