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

Use global borrow flags to avoid per-archetype borrow checking overhead. #28

Merged
merged 1 commit into from
Jan 15, 2022

Conversation

adamreichold
Copy link
Owner

This reduces the number of dynamic borrow checks to one per component instead of one per archetype, thereby avoiding dynamic allocations for the reference wrappers.

However, it also means that e.g. World::get_mut can now fail due overlapping borrows for entities in different archetypes which would have worked before.

@ghost
Copy link

ghost commented Jan 12, 2022

Tested this using swifco-rs and it does work. Performance improvements are hardly measurable though, i.e. from

Benchmark #1: python3 test.py
  Time (mean ± σ):      3.409 s ±  0.106 s    [User: 3.572 s, System: 0.881 s]
  Range (min … max):    3.260 s …  3.605 s    10 runs

to

Benchmark #1: python3 test.py
  Time (mean ± σ):      3.393 s ±  0.040 s    [User: 3.552 s, System: 0.885 s]
  Range (min … max):    3.313 s …  3.438 s    10 runs

This reduces the number of dynamic borrow checks to one per component instead of
one per archetype, thereby avoiding dynamic allocations for the reference
wrappers.

However, it also means that e.g. World::get_mut can now fail due overlapping
borrows for entities in different archetypes which would have worked before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant