Turn apply_deferred into a ZST System#16642
Merged
alice-i-cecile merged 8 commits intobevyengine:mainfrom Dec 5, 2024
Merged
Conversation
ItsDoot
commented
Dec 4, 2024
ItsDoot
commented
Dec 4, 2024
bushrat011899
approved these changes
Dec 4, 2024
Contributor
bushrat011899
left a comment
There was a problem hiding this comment.
Nice! I'm in favour of a breaking change to rename this ApplyDeferred. Users aren't supposed to actually call this as a function anyway, and giving it a PascalCase name should help highlight to users that it isn't a normal system.
Memory saving is also nice, especially since this system will be reused a lot in a typical application.
chescock
approved these changes
Dec 4, 2024
Contributor
Author
|
I've gone ahead and renamed |
ecoskey
pushed a commit
to ecoskey/bevy
that referenced
this pull request
Jan 6, 2025
# Objective - Required by bevyengine#16622 due to differing implementations of `System` by `FunctionSystem` and `ExclusiveFunctionSystem`. - Optimize the memory usage of instances of `apply_deferred` in system schedules. ## Solution By changing `apply_deferred` from being an ordinary system that ends up as an `ExclusiveFunctionSystem`, and instead into a ZST struct that implements `System` manually, we save ~320 bytes per instance of `apply_deferred` in any schedule. ## Testing - All current tests pass. --- ## Migration Guide - If you were previously calling the special `apply_deferred` system via `apply_deferred(world)`, don't.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
SystembyFunctionSystemandExclusiveFunctionSystem.apply_deferredin system schedules.Solution
By changing
apply_deferredfrom being an ordinary system that ends up as anExclusiveFunctionSystem, and instead into a ZST struct that implementsSystemmanually, we save ~320 bytes per instance ofapply_deferredin any schedule.Testing
Migration Guide
apply_deferredsystem viaapply_deferred(world), don't.