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

System builder syntax rework #31

Closed
wants to merge 2 commits into from
Closed

System builder syntax rework #31

wants to merge 2 commits into from

Conversation

thechubbypanda
Copy link

Existing PR: #2736
Original issue: #1978

@Ratysz
Copy link

Ratysz commented Sep 2, 2021

Rendered.

@alice-i-cecile
Copy link
Member

Are we happy to fundamentally alter the end user experience of Bevy and basically make all existing docs out of date.

Yep! This change is only going to get more painful the longer we wait.

@alice-i-cecile
Copy link
Member

IMO there's an important bit of Future work that should be included: this would provide an excellent unified foundation for "label descriptors", a much-discussed future feature that would allow users to specify schedule and run criteria information on labels, which would then be dispatched to each system with that label.

@thechubbypanda
Copy link
Author

thechubbypanda commented Sep 2, 2021

IMO there's an important bit of Future work that should be included

By included do you mean the changes required for label descriptors be made on top of this pr before merging it?

If so, might it be easier to handle 2 smaller prs rather than one massive one?

@Ratysz
Copy link

Ratysz commented Sep 2, 2021

"Future work" refers to a subsection of the RFC where you note down stuff that could happen after this RFC is accepted and implemented.

I don't think label properties are relevant here, though. It's mostly an orthogonal feature, in both API and potential implementation.

@alice-i-cecile
Copy link
Member

alice-i-cecile commented Sep 2, 2021

Alright, I'm happy to accept @Ratysz's judgement on that.

@Nilirad
Copy link

Nilirad commented Sep 6, 2021

I have a couple of ideas about the add_exclusive(system.exclusive_system()) API:

  1. Changing it to add_exclusive(system): Yeeting .exclusive_system() since it is assumed that the system is exculsive.
  2. Changing it to add_system(system.exclusive_system()): Removing add_exclusive method and specifying the exclusiveness through the builder-like pattern.

I'm quite ignorant to that part of the codebase so I don't know if the proposed APIs are possible or the implementation effort broaden too much the scope of the RFC/PR.

@alice-i-cecile
Copy link
Member

Changing it to add_exclusive(system): Yeeting .exclusive_system() since it is assumed that the system is exclusive.

I'd be quite happy with this, although I'd prefer add_exclusive_system for clarity. @DJMcNab, you ran into some issues with yeeting .exclusive_system though right?

@Ratysz
Copy link

Ratysz commented Sep 6, 2021

@DJMcNab, you ran into some issues with yeeting .exclusive_system though right?

That was a while ago, I've fixed that. This breaks it again; haven't had the time to try and fix it yet.

@DJMcNab
Copy link
Member

DJMcNab commented Sep 6, 2021

I didn't even try to get rid of .exclusive_system - to be honest, my PR was mostly just about recognising the for<'a> &'a mut F: FnMut(...) was the way to remove needing .system

Mostly described in [#1978](https://github.com/bevyengine/bevy/issues/1978).

- Allows us to unify the existing `.label()`, `.after()`, etc. methods and the stage positioning of systems.
- App would only have 3 methods to add systems: `add_system`, `add_exclusive` and `add_system_set`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced that giving exclusive systems their own api / making them more separate is the direction we should be going in (at least, not yet). Exclusive systems are just systems with arbitrary side effects (new archetypes, new components, etc). Our plans for "stageless schedules" need to have some way to accommodate "normal system" side effects (ex: applying Commands). I personally think solving that problem well will involve blurring the lines between exclusive and normal systems, potentially to the point that distinguishing between the two isn't worthwhile. Given that we don't yet know what this will look like in practice, I'd rather stick with what we currently have (which also happens to align better with the future that I think is coming). @Ratysz what are your thoughts on this?

Copy link

@Ratysz Ratysz Sep 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think separation is absolutely the right way to go. In fact, this PR doesn't go as far as it probably should - a lot of the weird API and implementation somersaults had to happen precisely to accomodate exclusive systems.

We should stop trying to merge parallel and exclusive systems until we actually have the ability to do so (which is, indeed, a part of stageless), because right now we definitely can't blur the lines. Or so I keep saying.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to mention: we tried here. It looks like a Rust limitation, it refuses to infer types across one of the boundaries.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha I figured you'd take that stance. I don't have strong opinions here because exclusive systems are relatively uncommon and there are definitely good reasons to keep them separate in the current implementation. This change just creates more churn for existing exclusive system users and creates a situation where in the future we'll probably break them again in favor of something that will probably be closer to the current api. To me the (possibly temporary) marginal wins we get from this separation don't outweigh the cost of breaking everyone, but I won't push back too hard on this if everyone else thinks differently.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to mention: we tried here. It looks like a Rust limitation, it refuses to infer types across one of the boundaries.

For what its worth, I made some changes to exclusive systems in #2777 that probably enable this.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change just creates more churn for existing exclusive system users and creates a situation where in the future we'll probably break them again in favor of something that will probably be closer to the current api. To me the (possibly temporary) marginal wins we get from this separation don't outweigh the cost of breaking everyone, but I won't push back too hard on this if everyone else thinks differently.

Don't get me wrong, I also subscribe to this line of thinking; it's too early to merge them, too late to not merge them - hence the dredged-up post. It's hard to not be a little bitter after time and time again seeing a shiny new API get completely blown up and polluted with faux specialisation and pseudo-HKT noise as soon as it needs to account for exclusive systems.

For what its worth, I made some changes to exclusive systems in #2777 that probably enable this.

Unlikely, the issue is the same that lead to enum SystemDescriptor: we need to have a concrete type somewhere between generic system and its consumer. Only this time the boundary is smeared across half a dozen traits with 3-4 implementors each.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's hard to not be a little bitter after time and time again seeing a shiny new API get completely blown up and polluted with faux specialisation and pseudo-HKT noise as soon as it needs to account for exclusive systems.

Yup I totally get that and concede the point that the current implementation would be much cleaner if we embraced a hard split. But from my perspective its hard not to be bitter that we keep investing in a "detour" in the interest of simplicity of the current executor. We wouldn't need to care about ugly faux specialization and pseudo-HKT noise if we just decided to treat exclusive systems as "normal systems" like we did in the old executor. Which I'm relatively certain is where we are headed in the future too. I pushed back pretty hard on the exclusive system split when the new executor landed and honestly its becoming clear to me that this split really is a "detour" that optimizes for a specific executor implementation that is lacking a feature that we all know we want. If cleanness and simplicity are the goals, imo our time is best spent on re-unifying exclusive systems and normal systems / formally acknowledging that Systems can have side effects (which again, is what the old impl did and what I pushed for in the new executor).

Im being a bit overly dramatic here. Not trying to be combative / turn this into an argument. I'm very happy with the improvements the new executor brought and we may very well have been better served by embracing fully separate exclusive systems in the short term. Just trying to illustrate that I also have some strong feelings about this situation / trying to qualify why I think investing further in the system/exclusive system split isn't what I want personally.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the most part, I agree; I don't think being conservative about splitting is unreasonable. I keep trying to advocate for it because I believe that the amount of headache it saves us in the short term is far, far greater than the amount of headache we will endure when mending this schism further down the line.

@thechubbypanda
Copy link
Author

So how's this going. Has cart's prerequisite stuff been merged?

@thechubbypanda thechubbypanda closed this by deleting the head repository Oct 2, 2022
@alice-i-cecile
Copy link
Member

Fixed by #45.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants