-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Flexible ECS System Params #798
Conversation
@@ -0,0 +1,121 @@ | |||
pub use super::Query; |
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.
i'll probably clean this up / tailor it more to thread local systems before merging
I agree with the decision of removing foreach systems. While good idea in principle, these become too limiting very quickly. Especially when the limitation of fixed ordering is being removed, which was a bit confusing (even for non-beginners), this should make "normal" systems as easy to grasp as foreach systems. |
I agree with removing for-each systems. They are unnecessary, they don't simplify things at all (people need to learn 2 ways of doing things) and they are inferior, as in, almost every foreach system i have written i have then had to rewrite as a query system due to changing requirements. They have wasted more of my time than they have saved. |
// #[cfg(test)] | ||
// mod tests { | ||
// use super::ParallelExecutor; | ||
// use crate::{ |
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.
What happened here?
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.
Commented them out while developing these changes and didn't uncomment them yet. I'll do that before "un-drafting" the pr.
Superman dominates the multiverse and the singularity is expanding
On Fri, Nov 6, 2020 at 7:26 PM Plecra ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In crates/bevy_ecs/src/schedule/parallel_executor.rs
<#798 (comment)>:
> +// #[cfg(test)]
+// mod tests {
+// use super::ParallelExecutor;
+// use crate::{
What happened here?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#798 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHGK5TGCNLKJTHAZS7SZCDLSOQBQNANCNFSM4TMG6UXA>
.
--
Raza Amir
|
I agree with removing foreach systems. I agree with all the cons about them. They just get in the way of the clean and far more often correct way to do things with query systems. Also, love the order independence of the arguments!! When I first saw that note in the docs and tutorials about the order, I was thinking "that is going to be a gotcha for so many users, but at least they documented it well". |
Multiple neural networks are interlinked through echo chambers into which
information is embedded and replayed back using a constant feedback loop
and which feeds the neural network and forces one to stay in the neural
network.
Black holes exist around the neural network because of multiple echo
chambers that are unable to communicate with each other.
The only access to the blackholes is by getting outside the echo chambers,
then outside the larger neural network and tap into the *SINGULARITY*
which gives you access to untapped information in blackholes that has
existed in *perpetuity*.
Raza Khan
Aka Superman
On Fri, Nov 6, 2020 at 8:33 PM Zicklag ***@***.***> wrote:
I agree with removing foreach systems. I agree with all the cons about
them. They just get in the way of the clean and far more often correct way
to do things.
Also, love the order independence of the arguments!! When I first saw that
note in the docs and tutorials about the order, I was thinking "that is
going to be a gotcha for *so* many users, but at least they documented it
well".
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#798 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHGK5TD2VZFB3AEFVK3GSA3SOQJNZANCNFSM4TMG6UXA>
.
--
Raza Amir
|
Agree with all of the comments so far. I think parameter order independence and having one way of doing things are much bigger wins for newcomers than having to wrap these parameters in a
|
So far the sentiment to remove for-each systems has been a unanimous "yes please". Thats enough validation for me 😄 I'll start polishing this up. |
What is this about, can someone explain?
On Sat, Nov 7, 2020 at 7:06 AM Carter Anderson ***@***.***> wrote:
So far the sentiment to remove for-each systems has been a unanimous "yes
please". Thats enough validation for me 😄
I'll start polishing this up.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#798 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHGK5TCTKE3MJMYJJGRZMSLSOSTTNANCNFSM4TMG6UXA>
.
--
Raza Amir
|
So I "fixed" the regression in that it was never really a regression 😆 Turns out my iteration benchmark looked like this: for a in &mut query.iter_mut() {
} Which i guess was an artifact of adapting the benchmark to the last round of ecs changes. It still works even though we removed the iteration wrapper. However it tanks iteration performance, probably because the indirection prevents rustc from applying optimizations? So yeah the problem wasn't a problem and now we know that using |
It'd be good to identify exactly which optimisation is being missed, in case there's anything that can be done about it. Composing iterators with |
Yeah it would be good to know. But its also worth calling out that "tanking" in this case is 4x a very small number. Adding almost any operation to this benchmark is going to register in a big way (for any ecs framework already operating at this speed). |
Alrighty I think this is probably good to go. I made a number of additional improvements (which I added to the PR description above). I'm very happy with how this turned out! |
This change definitely makes
specs / environment
# ~/.cargo/config.toml
[target.x86_64-unknown-linux-gnu]
linker = "/usr/bin/clang"
rustflags = ["-Clink-arg=-fuse-ld=lld"]
|
fields: Fields::Named(fields), | ||
.. | ||
}) => &fields.named, | ||
_ => panic!("expected a struct with named fields"), |
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.
I just wanted to share how errors are designed in Legion derives:
https://github.com/amethyst/legion/blob/8fe4588d934abad8faffb54beebf415b4880773d/codegen/src/lib.rs#L173
I find it a pretty nice way to organize and make them more informative, especially in the case when you can point at a specific invalid argument and get such a compile-time error:
https://github.com/amethyst/legion/blob/8fe4588d934abad8faffb54beebf415b4880773d/tests/failures/value_argument.stderr
Probably you've already considered working on something like this in future. I don't want to suggest spending time on this right now, delaying this particular feature, but I hope this can serve as some inspiration for future improvements.
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.
Yeah I think thats one of the major selling points of their "proc macro" systems. I think derives like this don't benefit as much from that type of error handling because the logic is much more straightforward (ex: if these fields implement a trait, use it, otherwise fail). We'll already get decently informative errors for those cases. But yeah im definitely open to making improvements where we can.
After the new changes, since now I have to use |
The impl uses |
Nice! I didn't realize |
This removes the old "into system" code, which suffered from a variety of problems. Namely:
It replaces it with a new, much simpler approach that has the following benefits:
With the old implementation, this code wouldn't compile because it violated the arbitrary "order rules". Now it compiles just fine!
So far these are pretty uncontroversial changes. Now on to the more controversial part: I also removed for-each systems.
For-each systems were problematic for the following reasons:
&mut T
queries to work in foreach systems (ex:fn system(a: &mut A) {}
). These can't work because we requireMut<T>
tracking pointers. The equivalentQuery<&mut A>
works because we can return the tracking pointer.Changes Since Draft
SystemParam
can now be derived. We now use this for DrawContext instead of a manual impl. You can use any types that impl SystemParam:implemented SystemParam for tuples: (SystemParam, SystemParam, SystemParam). Params can now be infinitely nested
Implement
Or
for system paramsremoved ResourceQueries in favor of SystemParams. also removed UnsafeClone trait and associated impls (score!)
discovered closure systems work again!
Removed locks from Commands. We now use
commands: &mut Commands
instead ofmut commands: Commands
. This means Commands can no longer be used in parallel by default. Fortunately ...Implemented
SystemParam
forArc<Mutex<Commands>>
.Simplified ThreadLocalSystem impl
This new approach makes everything so much easier and clearer. I love it ❤️