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

Queries that currently match no archetypes still try to borrow archetypes that they _could_match #80

Closed
cart opened this issue Jul 28, 2020 · 1 comment
Labels
C-Bug An unexpected or incorrect behavior

Comments

@cart
Copy link
Member

cart commented Jul 28, 2020

so i found a kind of nasty bug related to the new parallel scheduler, but that led me to what should be a optimization for large projects

The issue is that the bevy_ecs Query knows more about its archetype access than the internal hecs Query. Lets say you want to query &mut T, but there are no entities with T. The bevy_ecs query knows that it doesn't need to access any archetypes this frame, so the scheduler schedules that system alongside other systems that might access &mut T archetypes. But then if you try to iterate the (empty) query in the first system, it still tries to borrow &mut T in all archetypes that have it
this is because hecs queries iterate over all archetypes and filter them as they go
awhile back i created this issue: #53 because if we have hundreds of archetypes then iteration becomes needlessly expensive. The "fix" here is to pass in a reference to the bevy_ecs Query archetype bitset, so it only accesses the archetypes it needs to this frame.

And if we're doing that to fix the borrow bug (panicing when two &mut systems both borrow T, even though only one actually needs it), we might as well use that data to optimize iteration too.

@cart cart added the C-Bug An unexpected or incorrect behavior label Jul 28, 2020
@cart cart added this to the Open Source Release milestone Jul 28, 2020
@cart
Copy link
Member Author

cart commented Jul 28, 2020

resolved by: bd8e979

@cart cart closed this as completed Jul 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

No branches or pull requests

1 participant