-
-
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
Allow users to blend &mut World
with other system parameters using a "scoped World" pattern
#4158
Comments
In the "stageless" test branch I'm working on, I've been able to make I could split that out into a PR. (It's just the |
Yes please: we should do everything possible to make the stageless work easier to review.
I think I may have failed to explain the point properly. We can't have a system with both This becomes particularly gnarly with complex exclusive systems: you end up having to use deeply nested IMO we should move as much information about the data that these systems need to the type signature as possible for ergonomics. Incidentally, this also enables us to run systems with Suppose we have fn exclusive_events(world: &mut World, events: EventReader<Foo>) {}
fn simple_events(events: EventReader<Foo>) {} Because we've moved the resource scope to the system parameter level, we can actually run these systems in parallel! *requires some cleverness about how we re-merge the scoped world back in (or limitations on what the scoped world can do) |
If we just want to retain the ability to coerce any system to be exclusive without
I'd reeeeeeeeeeeeaaaaaaaaaly rather not.
I think this is reading too far ahead. The Discord threads on turn-based flows only had scopes two levels deep IIRC. If that makes compiler errors harder to debug, maybe we should just recommend users manually remove and re-insert their resources. |
That was intended to be the heart of this discussion. I can see your point though, this does need its own RFC. I'm clearly not motivating this well enough :)
That's the rest of the issue: you should be able to use queries and event readers / writers too. Being able to use event-readers in particular would be a massive win.
I'm not sure I see a second dichotomy? |
I was responding to this:
I mostly took issue with systems running in parallel with systems that take
There's a few distinct ideas here:
Two of these add significant complexity to the system access model while the other does not.
To me right now, these seem like minor ergonomic wins compared to the amount of work required to make it error gracefully and not panic when users do something bad. |
I should clarify that when I said "needs its own discussion" I just meant that I saw two different items being lumped together.
I didn't mean to suggest that one or the other needs an RFC, just that I think those are separate issues. If the "run a system in parallel with another system taking |
Ah: that was taken as "implicitly and obviously correct" for this discussion: I wrote this issue for a post-unification design, intending to focus solely on the params that take ownership as a way to improve ergonomics of exclusive systems. I agree about the need to compare-and-contrast. Fundamentally, I want to wait longer on this: I'm not sure I understand the legitimate use cases of exclusive systems well enough to make firm conclusions, particularly in a post-stageless design. The increased parallelism is very interesting, but I'm not sure it's actually effective, either from a complexity budget or performance perspective. Regardless, it's better to have a place to record these thoughts, in case they become more relevant down the line. |
Exclusive systems now support using |
What problem does this solve or what need does it fill?
The hard line between exclusive and non-exclusive systems results in very frustrating UX: users must learn a whole new API with complex borrow-checking rules in order to access the world.
Many convenient, ergonomic APIs (like
EventReader
) must be manually reimplemented or worked around, encouraging code duplication both within the engine and in user code.What solution would you like?
&mut World
.World
returned by&mut World
is incomplete: any data required by other system parameters is removed from it for the duration of the system.resource_scope
and other parallel APIs.Status
This is a large task, and should be done in a piecemeal fashion.
World::resource_scope
#4159.EventReader
.World::query_scope
API #4157.Commands
from&mut World
#3096, but not completely solve it.Entities
,Archetypes
and&World
: these are fundamentally impossible (or useless), as they are part of the metadata of the world.As a result, it seems like there's a split between "scopable" and "non-scopable" system parameters, that we should probably try to reflect in the type system somehow.
What alternative(s) have you considered?
WorldCell
is an API that exists largely to get around this pain. #3939 proposes removing it completely, due to its limitations and runtime-panicking nature.#4090 also attempts to relieve this pain, but there are some things that genuinely require
&mut World
access.Additional context
Dissolving the boundaries between exclusive and regular (
FunctionSystem
) systems is one of the incidental goals behind the Stageless RFC. This design would help further that process.#4157 is a necessary step to allow us to extend this work to queries (and hence entity-component data).
This is likely to be useful when working with e.g. saving the game, working with scenes or networking, as we commonly want to operate on a massive scale across the whole world, except for some data that is used for coordinating the task.
The text was updated successfully, but these errors were encountered: