-
Notifications
You must be signed in to change notification settings - Fork 85
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
Upstreaming Bevy ECS Changes #71
Comments
I would also like to go on the record to say that hecs has been an absolute pleasure to work with. Its simple, fast, and the api is clean. You've done some seriously great work here! |
Thanks for the writeup! I'm happy to hear that hecs was so useful to you, and I'm excited at the prospect of pulling in improvements and potentially combining efforts in the future. I'd hoped from the beginning that hecs would be useful for work like yours and it's satisfying to see that borne out. A guiding principle for hecs' design is that any demonstrably useful ECS functionality which is not built in should be painlessly implementable in an external crate, and that as much stuff as possible should be in the latter set, with exceptions for the trivial or near universally applicable. This preserves the simplicity which makes hecs unique and uniquely reusable. As you observe, this does entail some potentially hard API design challenges, but they're challenges I'm interested in. hecs has some initial work in that direction (e.g. the explicit archetype-related APIs) but it's very much early stages, since I haven't wanted to build out APIs without concrete use cases driving them--which bevy now provides. In that spirit, I'm definitely open to making more stuff visible, though we should take care to clearly distinguish end-user-relevant stuff from extension interfaces. So, for each change, let's consider whether it's best merged into hecs, or whether we should explore ways to let it live outside:
|
Looks like the one thing I was leery about got rolled back in bevyengine/bevy#504, so I'm extra enthusiastic for this now! |
Closing as we've intentionally diverged per offline discussion, since serving both projects' requirements with a single library would be a hard research problem. Looking forward to continuing to exchange ideas, though! There's already some stuff I want to crib from Bevy ECS V2... |
My recently announced Bevy ECS project uses a forked version of hecs, which adds the following features on top:
(copied directly from the blog post)
Resource
collection and resource queriesQuery
Bevy ECS exports is actually a wrapper around Hecs Queries. It provides safe, scoped access to theWorld
in a multi-threaded context and improves the ergonomics of iteration.Most of the performance improvements came from removing Entity from the iterator and instead returning it via queries. I suspect it allowed rust to inline something (or otherwise optimize it) in a way that it couldn't before. I also tweaked manual inlining in a few places.
I'd also like to note that Stable Entity IDs do come at a performance cost, and the current version uses random u32's, which bevy users have proven to have a high collision risk. That being said the collision risk is a solvable problem and the performance cost is "worth it" to me. (although entity ids are still a hot discussion, as you can probably see in that thread). You can see the difference illustrated in the performance graphs in the blog post above.
I'd love to upstream whatever features you want from Bevy ECS, so its mainly a question of "what do you want" / "what fits the hecs scope".
I would also like to at least discuss the possibility of Bevy eventually consuming upstream hecs directly. That way improvements to hecs could make it into Bevy, and Bevy developers would be encouraged to contribute to hecs. I see a few things that could block that:
query.rs
. If you don't want these types, then I'd need to move them to bevy_ecs. I've noticed that optimizations sometimes break down when moving code across crates. If theres no way to force optimal performance across crate boundaries, I'd be hesitant to take that performance hit.The text was updated successfully, but these errors were encountered: