-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Merged by Bors] - Add a SystemParam
primitive for deferred mutations; allow #[derive]
ing more types of SystemParam
#6817
Closed
Closed
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
c0a66aa
add the `Buf<>` systemparam
joseph-gio e819787
use `Buf` to derive `Commands`
joseph-gio 3bff701
derive `ParallelCommands`
joseph-gio 7f324d6
improve diff
joseph-gio bf9840e
rename trait `Buffer` -> `SystemBuffer`
joseph-gio 1daccbf
rename struct `Buf` -> `Buffer`
joseph-gio cdf6bbd
Merge remote-tracking branch 'upstream/main' into buffer-param
joseph-gio b4b1461
propagate `SystemMeta`
joseph-gio 3a64d16
Merge remote-tracking branch 'upstream/main' into buffer-param
joseph-gio 78ea2cc
Merge remote-tracking branch 'upstream/main' into buffer-param
joseph-gio b0d4e2e
make `ParallelCommandQueue` private
joseph-gio d585826
Merge remote-tracking branch 'upstream/main' into buffer-param
joseph-gio e568345
fix a doc link
joseph-gio ff97bf1
make those docs good
joseph-gio bcba009
add an example to `Buffer<T>`
joseph-gio 4a46300
add more docs to `SystemBuffer`
joseph-gio 6020791
rename `Buffer<>` -> `Deferred<>`
joseph-gio 1a24fa7
add `Deferred<>` to the prelude
joseph-gio 4a0d59b
Merge branch 'main' into buffer-param
joseph-gio a1b8f45
fix a redundant panic in the example
joseph-gio 9637850
no coziness for these methods :(
joseph-gio 35c79fe
cargo fmt
joseph-gio 2817097
improve a note about up-front computations
joseph-gio 0ff8aee
reorganize docs for `Deferred`
joseph-gio 6a1aa3d
polish the example more
joseph-gio a86ce13
document when `Deferred` should and should not be used
joseph-gio ef12641
make the example a better use-case
joseph-gio e403150
fix CI
joseph-gio 5ded352
Merge branch 'main' into buffer-param
joseph-gio 094141d
add a note to the example about `SystemBuffer::apply`
joseph-gio 27b6795
cargo fmt
joseph-gio e85e34e
Merge remote-tracking branch 'upstream/main' into buffer-param
joseph-gio 9d6212a
fix a merge artefact
joseph-gio be1b372
migrate example to stageless
joseph-gio 542e42a
Revert "fix a merge artefact"
joseph-gio 1a746a6
Merge remote-tracking branch 'upstream/main' into buffer-param
joseph-gio 8ac61af
merge error
joseph-gio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
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.
This example does a great job of illustrating the API, but I am worried it might teach "bad practice". It might lead people to think that using such a deferred pattern is expected to be faster / perform better than simply mutating the resource normally from the system. That is not true: deferring actions via system buffers adds a lot of overhead (that typically outweighs gains from parallelism for such small systems), and in this example the operation (mutating a resource value) could have been done from parallel systems just fine. Deferred does not win anything.
I think the example could be made better if it actually uses an operation that cannot be done from parallel systems without using Deferred, such as adding/removing components or spawning entities. "Sounding the alarm" could be done by spawning an entity or adding a component, instead of mutating a value. That way, we actually have a reason to use Deferred.
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.
Why do you say that this adds a lot of overhead?
apply_buffers
gets called on every system via dynamic dispatch, so there is already an overhead for each system regardless of whether it has any buffers to apply. Any additional overhead associated withDeferred<>
should be very small, and entirely dependent on how the user implementsSystemBuffer
.That said, I agree with your other points. I believe I have addressed them all.