From 63d60c212c00135ca1c129c15ddd7ea35d985b32 Mon Sep 17 00:00:00 2001 From: Imbris Date: Sat, 29 Aug 2020 02:39:16 -0400 Subject: [PATCH] Add spans to server systems --- common/src/sys/phys.rs | 1 - server/src/events/mod.rs | 6 +++++- server/src/events/player.rs | 3 +++ server/src/sys/entity_sync.rs | 2 ++ server/src/sys/invite_timeout.rs | 2 ++ server/src/sys/message.rs | 2 ++ server/src/sys/object.rs | 2 ++ server/src/sys/persistence.rs | 6 +++++- server/src/sys/sentinel.rs | 2 ++ server/src/sys/subscription.rs | 2 ++ server/src/sys/terrain.rs | 2 ++ server/src/sys/terrain_sync.rs | 2 ++ server/src/sys/waypoint.rs | 2 ++ 13 files changed, 31 insertions(+), 3 deletions(-) diff --git a/common/src/sys/phys.rs b/common/src/sys/phys.rs index 4083c74514..405adea302 100644 --- a/common/src/sys/phys.rs +++ b/common/src/sys/phys.rs @@ -354,7 +354,6 @@ impl<'a> System<'a> for Sys { radius: f32, z_range: Range, ) -> impl Iterator> + 'a { - span!(_guard, "collision_iter"); near_iter.filter_map(move |(i, j, k)| { let block_pos = pos.map(|e| e.floor() as i32) + Vec3::new(i, j, k); diff --git a/server/src/events/mod.rs b/server/src/events/mod.rs index 948fbc6355..5adaaec801 100644 --- a/server/src/events/mod.rs +++ b/server/src/events/mod.rs @@ -1,5 +1,8 @@ use crate::{state_ext::StateExt, Server}; -use common::event::{EventBus, ServerEvent}; +use common::{ + event::{EventBus, ServerEvent}, + span, +}; use entity_creation::{ handle_create_npc, handle_create_waypoint, handle_initialize_character, handle_loaded_character_data, handle_shoot, @@ -36,6 +39,7 @@ pub enum Event { impl Server { pub fn handle_events(&mut self) -> Vec { + span!(_guard, "Server::handle_events"); let mut frontend_events = Vec::new(); let mut requested_chunks = Vec::new(); diff --git a/server/src/events/player.rs b/server/src/events/player.rs index d9fb034144..486b826982 100644 --- a/server/src/events/player.rs +++ b/server/src/events/player.rs @@ -6,6 +6,7 @@ use common::{ comp, comp::{group, Player}, msg::{ClientState, PlayerListUpdate, ServerMsg}, + span, sync::{Uid, UidAllocator}, }; use futures_executor::block_on; @@ -13,6 +14,7 @@ use specs::{saveload::MarkerAllocator, Builder, Entity as EcsEntity, WorldExt}; use tracing::{debug, error, trace, warn}; pub fn handle_exit_ingame(server: &mut Server, entity: EcsEntity) { + span!(_guard, "handle_exit_ingame"); let state = server.state_mut(); // Create new entity with just `Client`, `Uid`, and `Player` components @@ -78,6 +80,7 @@ pub fn handle_exit_ingame(server: &mut Server, entity: EcsEntity) { } pub fn handle_client_disconnect(server: &mut Server, entity: EcsEntity) -> Event { + span!(_guard, "handle_client_disconnect"); if let Some(client) = server.state().read_storage::().get(entity) { let participant = match client.participant.try_lock() { Ok(mut p) => p.take().unwrap(), diff --git a/server/src/sys/entity_sync.rs b/server/src/sys/entity_sync.rs index 171c5bb7db..d3dc15b2ea 100644 --- a/server/src/sys/entity_sync.rs +++ b/server/src/sys/entity_sync.rs @@ -11,6 +11,7 @@ use common::{ msg::ServerMsg, outcome::Outcome, region::{Event as RegionEvent, RegionMap}, + span, state::TimeOfDay, sync::{CompSyncPackage, Uid}, terrain::TerrainChunkSize, @@ -77,6 +78,7 @@ impl<'a> System<'a> for Sys { trackers, ): Self::SystemData, ) { + span!(_guard, "entity_sync::Sys::run"); timer.start(); let tick = tick.0; diff --git a/server/src/sys/invite_timeout.rs b/server/src/sys/invite_timeout.rs index 7a701b03a4..8c725d976e 100644 --- a/server/src/sys/invite_timeout.rs +++ b/server/src/sys/invite_timeout.rs @@ -3,6 +3,7 @@ use crate::client::Client; use common::{ comp::group::{Invite, PendingInvites}, msg::{InviteAnswer, ServerMsg}, + span, sync::Uid, }; use specs::{Entities, Join, ReadStorage, System, Write, WriteStorage}; @@ -24,6 +25,7 @@ impl<'a> System<'a> for Sys { &mut self, (entities, mut invites, mut pending_invites, mut clients, uids, mut timer): Self::SystemData, ) { + span!(_guard, "invite_timeout::Sys::run"); timer.start(); let now = std::time::Instant::now(); diff --git a/server/src/sys/message.rs b/server/src/sys/message.rs index b2d6ea97dc..a25c23f622 100644 --- a/server/src/sys/message.rs +++ b/server/src/sys/message.rs @@ -4,6 +4,7 @@ use crate::{ persistence::character::CharacterLoader, ServerSettings, }; use common::{ + span, comp::{ Admin, AdminList, CanBuild, ChatMode, ChatType, ControlEvent, Controller, ForceUpdate, Ori, Player, Pos, Stats, UnresolvedChatMsg, Vel, @@ -454,6 +455,7 @@ impl<'a> System<'a> for Sys { alias_validator, ): Self::SystemData, ) { + span!(_guard, "message::Sys::run"); timer.start(); let mut server_emitter = server_event_bus.emitter(); diff --git a/server/src/sys/object.rs b/server/src/sys/object.rs index 8a59fd32a6..f044c198fc 100644 --- a/server/src/sys/object.rs +++ b/server/src/sys/object.rs @@ -1,6 +1,7 @@ use common::{ comp::{HealthSource, Object, PhysicsState, Pos, Vel}, event::{EventBus, ServerEvent}, + span, state::DeltaTime, }; use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage}; @@ -23,6 +24,7 @@ impl<'a> System<'a> for Sys { &mut self, (entities, _dt, server_bus, positions, velocities, physics_states, mut objects): Self::SystemData, ) { + span!(_guard, "object::Sys::run"); let mut server_emitter = server_bus.emitter(); // Objects diff --git a/server/src/sys/persistence.rs b/server/src/sys/persistence.rs index bc6d8fc493..444754b79c 100644 --- a/server/src/sys/persistence.rs +++ b/server/src/sys/persistence.rs @@ -2,7 +2,10 @@ use crate::{ persistence::character, sys::{SysScheduler, SysTimer}, }; -use common::comp::{Inventory, Loadout, Player, Stats}; +use common::{ + comp::{Inventory, Loadout, Player, Stats}, + span, +}; use specs::{Join, ReadExpect, ReadStorage, System, Write}; pub struct Sys; @@ -31,6 +34,7 @@ impl<'a> System<'a> for Sys { mut timer, ): Self::SystemData, ) { + span!(_guard, "persistence::Sys::run"); if scheduler.should_run() { timer.start(); updater.batch_update( diff --git a/server/src/sys/sentinel.rs b/server/src/sys/sentinel.rs index adcc76bd30..8f67f2d03c 100644 --- a/server/src/sys/sentinel.rs +++ b/server/src/sys/sentinel.rs @@ -5,6 +5,7 @@ use common::{ Loadout, Mass, MountState, Mounting, Ori, Player, Pos, Scale, Stats, Sticky, Vel, }, msg::EcsCompPacket, + span, sync::{CompSyncPackage, EntityPackage, EntitySyncPackage, Uid, UpdateTracker, WorldSyncExt}, }; use hashbrown::HashMap; @@ -26,6 +27,7 @@ impl<'a> System<'a> for Sys { ); fn run(&mut self, (mut timer, comps, mut trackers): Self::SystemData) { + span!(_guard, "sentinel::Sys::run"); timer.start(); record_changes(&comps, &mut trackers); diff --git a/server/src/sys/subscription.rs b/server/src/sys/subscription.rs index f494b30f49..a29243df18 100644 --- a/server/src/sys/subscription.rs +++ b/server/src/sys/subscription.rs @@ -7,6 +7,7 @@ use common::{ comp::{Ori, Player, Pos, Vel}, msg::ServerMsg, region::{region_in_vd, regions_in_vd, Event as RegionEvent, RegionMap}, + span, sync::Uid, terrain::TerrainChunkSize, vol::RectVolSize, @@ -55,6 +56,7 @@ impl<'a> System<'a> for Sys { tracked_comps, ): Self::SystemData, ) { + span!(_guard, "subscription::Sys::run"); timer.start(); // To update subscriptions diff --git a/server/src/sys/terrain.rs b/server/src/sys/terrain.rs index 2270807410..dc8b77347b 100644 --- a/server/src/sys/terrain.rs +++ b/server/src/sys/terrain.rs @@ -11,6 +11,7 @@ use common::{ generation::get_npc_name, msg::ServerMsg, npc::NPC_NAMES, + span, state::TerrainChanges, terrain::TerrainGrid, LoadoutBuilder, @@ -55,6 +56,7 @@ impl<'a> System<'a> for Sys { mut clients, ): Self::SystemData, ) { + span!(_guard, "terrain::Sys::run"); timer.start(); let mut server_emitter = server_event_bus.emitter(); diff --git a/server/src/sys/terrain_sync.rs b/server/src/sys/terrain_sync.rs index a9899be209..1398a2b1af 100644 --- a/server/src/sys/terrain_sync.rs +++ b/server/src/sys/terrain_sync.rs @@ -3,6 +3,7 @@ use crate::client::Client; use common::{ comp::{Player, Pos}, msg::ServerMsg, + span, state::TerrainChanges, terrain::TerrainGrid, }; @@ -26,6 +27,7 @@ impl<'a> System<'a> for Sys { &mut self, (terrain, terrain_changes, mut timer, positions, players, mut clients): Self::SystemData, ) { + span!(_guard, "terrain_sync::Sys::run"); timer.start(); // Sync changed chunks diff --git a/server/src/sys/waypoint.rs b/server/src/sys/waypoint.rs index 9129af814a..870dacf8ab 100644 --- a/server/src/sys/waypoint.rs +++ b/server/src/sys/waypoint.rs @@ -3,6 +3,7 @@ use crate::client::Client; use common::{ comp::{Player, Pos, Waypoint, WaypointArea}, msg::{Notification, ServerMsg}, + span, state::Time, }; use specs::{Entities, Join, Read, ReadStorage, System, Write, WriteStorage}; @@ -30,6 +31,7 @@ impl<'a> System<'a> for Sys { &mut self, (entities, positions, players, waypoint_areas, mut waypoints, mut clients, time, mut timer): Self::SystemData, ) { + span!(_guard, "waypoint::Sys::run"); timer.start(); for (entity, player_pos, _, client) in