Write Barriers for ECS Data#86
Open
caniko wants to merge 1 commit into
Open
Conversation
A schedule-level primitive that locks writes to a chosen component type between a producer and a consumer set, with a static check at schedule construction that no other system in the window mutates it.
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.
Summary
A schedule-level primitive that locks writes to a chosen component type between a producer set and a consumer set, with a static check at schedule construction that no other system in the window mutates it. Resources are covered by the same API because as of 0.19 they are components on singleton entities.
The motivation is a real production desync in a deterministic P2P multiplayer Bevy project: a phase hash is queued by an observer on
BoardSeededEventand flushed inPostUpdate; an unrelated auto-play system in the same schedule mutatesRoundStatebetween queue and flush; peers hash at different logical moments and the session enters infinite state-sync recovery..before(FlushPhaseHashSet)patches this specific writer. The next writer ships the bug again, because nothing tells a new contributor about the window. This RFC makes that schedule-build error instead of production-runtime corruption.The RFC includes a worked end-to-end example (before/after code, schedule-build diagnostic, fix line) drawn from the motivating bug.
Scope
.may_insert::<T>()), strict by default with a lax mode for prototypingFilteredAccess(#23384),SystemBuffer::queue()(#22832), delayed commands (#23090)Related Bevy work acknowledged in the RFC
Open RFCs: #16 Subworld, #36 Side Effect Lifecycles, #46 Atomic schedule groups (closest sibling), #47 Relaxed ordering.
Shipped in 0.19: #20934 + chain, #22144, #22602, #23090, #23384, #23414, #22832.
Outstanding issues: #4918, #15036, #14951, #18310, #23057.
Open questions called out
WriteBarriercollides with informal community usage for command-queue sync points)Result-returning vs panic-on-violation at schedule buildFeedback particularly welcome on those three and on whether the diagnostic shape in Implementation strategy matches what #15036 will land on.