Skip to content

Commit

Permalink
merge with master
Browse files Browse the repository at this point in the history
  • Loading branch information
ironpeak committed Nov 29, 2024
2 parents a9a276a + a8e10a0 commit f35def0
Show file tree
Hide file tree
Showing 55 changed files with 2,545 additions and 1,837 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,6 @@ jobs:
name: code-coverage-report

- name: Upload to Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,39 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- RTT, bytes per second and packet loss information for `RepliconClient` and `ConnectedClients`.
- `ClientSet::Diagnostics` for systems that collect client diagnostics.

### Changed

- Make `core::replication::replication_rules::ReplicationRules` public.
- Various optimizations for replication messages to use fewer bytes.
- Accept `Vec<u8>` instead of `Cursor<Vec<u8>>` for serialization.
- `ConnectedClients` now store `ConnectedClient` instead of `ClientId` with more information about the client.
- All `TestFnsEntityExt` now accept `FnsId`.
- Move replication-related modules from `core` module under `core::replication`.
- Move `Replicated` to the `replication` module.
- Split the `ctx` module and move event-related contexts under `core::events_registry::ctx` and replication-related contexts under `core::replication_registry::ctx`.
- Separate paths from `diagnostics` module by `/` and their parent path now `client/replication` instead of `replication/client`.
- Provide replication statistics by sum instead of per second and use `usize` for it.
- Rename `ServerPlugin::change_timeout` into `ServerPlugin::mutations_timeout`.
- Rename `ServerInitTick` into `ServerChangeTick`.
- Rename `ReplicatedClient::init_tick` into `ReplicatedClient::change_tick`.
- Rename `ReplicatedClient::get_change_tick` into `ReplicatedClient::mutation_tick`.
- Rename `ReplicationChannel::Init` into `ReplicationChannel::Changes`.
- Rename `ReplicationChannel::Update` into `ReplicationChannel::Mutations`.
- Rename `ClientStats` into `ClientReplicationStats`.
- Rename `ClientDiagnosticsPlugin::MESSAGES` into `ClientDiagnosticsPlugin::REPLICATION_MESSAGES`.
- Rename `ClientDiagnosticsPlugin::BYTES` into `ClientDiagnosticsPlugin::REPLICATION_BYTES`.
- Rename `ClientDiagnosticsPlugin::ENTITY_CHANGES` into `ClientDiagnosticsPlugin::ENTITIES_CHANGED`.
- Rename `ClientDiagnosticsPlugin::COMPONENT_CHANGES` into `ClientDiagnosticsPlugin::COMPONENTS_CHANGED`.

### Removed

- `FnsInfo`, use `(ComponentId, FnsId)` instead.

## [0.28.4] - 2024-10-15

### Added
Expand Down
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ bevy = { version = "0.15.0", default-features = false, features = [
bytes = "1.5"
bincode = "1.3"
serde = "1.0"
varint-rs = "2.2"
integer-encoding = "4.0"
ordered-multimap = "0.7"
bitflags = "2.6"

[dev-dependencies]
bevy = { version = "0.15.0", default-features = false, features = [
Expand Down Expand Up @@ -68,7 +69,7 @@ name = "replication"
harness = false

[[test]]
name = "changes"
name = "mutations"
required-features = ["client", "server"]

[[test]]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Have any questions? Feel free to ask in the dedicated [`bevy_replicon` channel](
- [`bevy_replicon_renet`](https://github.com/projectharmonia/bevy_replicon_renet) - integration for [`bevy_renet`](https://github.com/lucaspoffo/renet/tree/master/bevy_renet). Maintained by the authors of this crate.
- [`bevy_replicon_renet2`](https://github.com/UkoeHB/renet2/tree/main/bevy_replicon_renet2) - integration for [`bevy_renet2`](https://github.com/UkoeHB/renet2/tree/main/bevy_renet2). Includes a WebTransport backend for browsers, and enables servers that can manage multi-platform clients simultaneously.
- [`bevy_replicon_quinnet`](https://github.com/Henauxg/bevy_quinnet/tree/main/bevy_replicon_quinnet) - integration for [`bevy_quinnet`](https://github.com/Henauxg/bevy_quinnet).
- [`aeronet_replicon`](https://github.com/aecsocket/aeronet/tree/main/crates/aeronet_replicon) - integration for [`aeronet`](https://github.com/aecsocket/aeronet). Works on any IO layer supported by `aeronet_io`, but requires `aeronet_transport`.

#### Helpers

Expand Down
77 changes: 40 additions & 37 deletions benches/replication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn replication<C: Component + Default + Serialize + DeserializeOwned + Clone>(c:
name = &name[MODULE_PREFIX_LEN..];

for clients in [1, 20] {
c.bench_function(&format!("{name}, init send, {clients} client(s)"), |b| {
c.bench_function(&format!("{name}, changes send, {clients} client(s)"), |b| {
b.iter_custom(|iter| {
let mut elapsed = Duration::ZERO;
for _ in 0..iter {
Expand Down Expand Up @@ -82,53 +82,56 @@ fn replication<C: Component + Default + Serialize + DeserializeOwned + Clone>(c:
})
});

c.bench_function(&format!("{name}, update send, {clients} client(s)"), |b| {
b.iter_custom(|iter| {
let mut server_app = create_app::<C>();
let mut client_apps = Vec::new();
for _ in 0..clients {
client_apps.push(create_app::<C>());
}

for client_app in &mut client_apps {
server_app.connect_client(client_app);
}

server_app
.world_mut()
.spawn_batch(vec![(Replicated, C::default()); ENTITIES as usize]);
let mut query = server_app.world_mut().query::<&mut C>();

server_app.update();
for client_app in &mut client_apps {
server_app.exchange_with_client(client_app);
client_app.update();
assert_eq!(client_app.world().entities().len(), ENTITIES);
}
c.bench_function(
&format!("{name}, mutations send, {clients} client(s)"),
|b| {
b.iter_custom(|iter| {
let mut server_app = create_app::<C>();
let mut client_apps = Vec::new();
for _ in 0..clients {
client_apps.push(create_app::<C>());
}

let mut elapsed = Duration::ZERO;
for _ in 0..iter {
for mut component in query.iter_mut(server_app.world_mut()) {
component.set_changed();
for client_app in &mut client_apps {
server_app.connect_client(client_app);
}

let instant = Instant::now();
server_app.update();
elapsed += instant.elapsed();
server_app
.world_mut()
.spawn_batch(vec![(Replicated, C::default()); ENTITIES as usize]);
let mut query = server_app.world_mut().query::<&mut C>();

server_app.update();
for client_app in &mut client_apps {
server_app.exchange_with_client(client_app);
client_app.update();
assert_eq!(client_app.world().entities().len(), ENTITIES);
}
}

elapsed
})
});
let mut elapsed = Duration::ZERO;
for _ in 0..iter {
for mut component in query.iter_mut(server_app.world_mut()) {
component.set_changed();
}

let instant = Instant::now();
server_app.update();
elapsed += instant.elapsed();

for client_app in &mut client_apps {
server_app.exchange_with_client(client_app);
client_app.update();
assert_eq!(client_app.world().entities().len(), ENTITIES);
}
}

elapsed
})
},
);
}

c.bench_function(&format!("{name}, init receive"), |b| {
c.bench_function(&format!("{name}, changes receive"), |b| {
b.iter_custom(|iter| {
let mut elapsed = Duration::ZERO;
for _ in 0..iter {
Expand All @@ -154,7 +157,7 @@ fn replication<C: Component + Default + Serialize + DeserializeOwned + Clone>(c:
})
});

c.bench_function(&format!("{name}, update receive"), |b| {
c.bench_function(&format!("{name}, mutations receive"), |b| {
b.iter_custom(|iter| {
let mut server_app = create_app::<C>();
let mut client_app = create_app::<C>();
Expand Down
Loading

0 comments on commit f35def0

Please sign in to comment.