-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add petgraph
back to bevy_ecs
#18735
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
Conversation
Right off the bat, refer to the PR that removed Petgraph for a benchmark that was used at the time. I believe it showed a performance increase switching away from Petgraph that was later attributed to using a better hasher in the specialised solution. It would be good to verify that switching back doesn't drastically reduce performance. IMO, a small performance decrease is acceptable for the sake of reduced maintenance burden, and I'd rather we contribute upstream fixes for performance. |
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.
Nicely done! It's always nice to have a PR that just removes code. Provided benchmarks don't show substantive regressions, LGTM.
I'm not super thrilled about the idea of pulling a petgraph dependency again. I don't think it's a particularly good long term fit for Bevy, and I'd rather leave things as they are now until we have a much clearer idea of broader requirements. |
I'd also be curious about how this might interact with the future Petgraph reminds me of a catch-all python lib. That's not a bad thing, (it's really useful for data science stuff, etc) but I'm hesitant on using a catch-all lib for something so specialized. As an extreme example, the archetype system is a graph, but we don't use a graph library for that because the custom solution offers more flexibility. If there's no real performance regression, and it doesn't conflict with future plans for schedule executors, I'm not opposed to this. But in principal, I think custom solutions to Bevy's unique use cases will generally offer more flexibility and performance than an additional dependency. |
Objective
petgraph
usage was removed frombevy_ecs
in #15519 in order forbevy_ecs
to work inno_std
environments, because at that point in timepetgraph
did not supportno_std
. However, with the recent0.8
release ofpetgraph
, it now works inno_std
environments. We should replace our specialized in-tree versions withpetgraph
once again in order to reduce code maintenance and duplication.Solution
Graph
structure frombevy_ecs
.DiGraph
andUnGraph
type aliases to instead point topetgraph
'sDiGraphMap
andUnGraphMap
, respectively.TarjanScc
structure withpetgraph
's own algorithm implementation.Testing
One test was modified to test against petgraph's tarjan-scc instead of our previously existing implementation.