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

Compile multiple run conditions into one #7580

Closed
wants to merge 17 commits into from

Conversation

JoJoJet
Copy link
Member

@JoJoJet JoJoJet commented Feb 9, 2023

Objective

When multiple run conditions are attached to a system, they should be compiled together as one function.

Solution

Add a variant of System{Set}Config that preserves the types of run conditions and combines them with any newly-added ones. This allows the compiler to inline them into one function.

This optimization is performed opportunistically -- run conditions that have already been boxed and type erased are not combined, as there is no benefit to doing so. This means that structs that perform type erasure such as SystemConfig present a barrier for this optimization. Resolving this should be possible in the future, but it would require a much higher-impact change that involves preserving the type data for all SystemConfig instances.

@JoJoJet JoJoJet added A-ECS Entities, components, systems, and events C-Performance A change motivated by improving speed, memory usage or compile times labels Feb 9, 2023
@alice-i-cecile alice-i-cecile added this to the 0.10 milestone Feb 10, 2023
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

I don't love adding more complexity here, but the aim is valuable. Great comments!

Requests:

  1. Add a matching Either combinator (to avoid mangling Or from queries).
  2. Add doc tests to both Either and And.
  3. Add links to both Either and And from the Condition docs. not from [Merged by Bors] - Add condition negation #7559 would be nice to mention there too.

@alice-i-cecile alice-i-cecile added the C-Feature A new feature, making something new possible label Feb 10, 2023
@JoJoJet
Copy link
Member Author

JoJoJet commented Feb 10, 2023

  1. Add a matching Either combinator (to avoid mangling Or from queries).

I'm assuming you want this in order to satisfy #7584 -- however the And combinator I've added here intentionally doesn't short-circuit, so it won't resolve that issue. Instead of building on the And type by adding Either, I think it would be better to keep And an implementation detail and make it #[doc(hidden)].

I am working on another PR that would satify #7584, though.

@alice-i-cecile
Copy link
Member

Okay great, I'm fine to cut 1 from this PR :)

@JoJoJet JoJoJet removed the C-Feature A new feature, making something new possible label Feb 10, 2023
@JoJoJet JoJoJet removed this from the 0.10 milestone Feb 10, 2023
@JoJoJet
Copy link
Member Author

JoJoJet commented Feb 10, 2023

I'm taking this off of the milestone if that's okay, since 0.10 is so close and this is just a nice-to-have optimization.

@alice-i-cecile alice-i-cecile added this to the 0.11 milestone Feb 27, 2023
@JoJoJet
Copy link
Member Author

JoJoJet commented Apr 14, 2023

Closing this since it's out of date, and I don't consider this to be high enough priority to get it working again.

@JoJoJet JoJoJet closed this Apr 14, 2023
@JoJoJet JoJoJet deleted the inline-condition branch September 20, 2023 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Performance A change motivated by improving speed, memory usage or compile times
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants