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

Wrap world access in a SystemParam for granular access #418

Merged
merged 4 commits into from
Feb 14, 2025

Conversation

Shatur
Copy link
Contributor

@Shatur Shatur commented Feb 14, 2025

This allows replication to run in parallel with other systems that write to non-replicated components.
Benchmarks show the same performance, but we run them without multi_threaded.

Supersedes #417.

This allows replication to run in parallel with other systems that write to non-replicated components.
Benchmarks show the same performance, but we run them without `multi_threaded`.
@Shatur Shatur enabled auto-merge (squash) February 14, 2025 19:12
@Shatur Shatur changed the title Wrap world access in a SystemParam for granular access. Wrap world access in a SystemParam for granular access Feb 14, 2025
@Shatur Shatur requested a review from UkoeHB February 14, 2025 19:12
Copy link

codecov bot commented Feb 14, 2025

Codecov Report

Attention: Patch coverage is 88.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 85.12%. Comparing base (098f54e) to head (f716dd4).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/server.rs 77.77% 2 Missing ⚠️
src/server/replicated_archetypes.rs 60.00% 2 Missing ⚠️
src/server/replication_read_world.rs 94.44% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #418      +/-   ##
==========================================
- Coverage   89.17%   85.12%   -4.06%     
==========================================
  Files          53       54       +1     
  Lines        2808     2957     +149     
==========================================
+ Hits         2504     2517      +13     
- Misses        304      440     +136     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 25 to 31
impl<'w> ReplicatedWorld<'w, '_> {
/// Extracts a component as [`Ptr`] and its ticks from a table or sparse set, depending on its storage type.
///
/// # Safety
///
/// The component must be present in this archetype, have the specified storage type, and be previously marked for replication.
pub(super) unsafe fn get_component_unchecked(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this also require that the source of the ptr doesn't get reallocated? I don't think we can make that guarantee.

Copy link
Contributor Author

@Shatur Shatur Feb 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We configured the access by manually implementing SystemParam to prevent other systems running in parallel from writing to replicated components. And we expose only read access with the associated runtime on Ptr, so it should be fine.

I will need a similar thing for writing part in the future.
@Shatur
Copy link
Contributor Author

Shatur commented Feb 14, 2025

Pushed a small rename to rework the receiving. But I'll make a separate PR for it.

Copy link
Collaborator

@UkoeHB UkoeHB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm ok seems plausible, although I'm no expert on the intricacies of bevy's memory model.

@Shatur Shatur merged commit e6f6712 into master Feb 14, 2025
7 checks passed
@Shatur Shatur deleted the parallelize-replication-send branch February 14, 2025 23:47
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.

2 participants