Add spans to server systems

This commit is contained in:
Imbris 2020-08-29 02:39:16 -04:00
parent 4f68a6df27
commit 63d60c212c
13 changed files with 31 additions and 3 deletions

View File

@ -354,7 +354,6 @@ impl<'a> System<'a> for Sys {
radius: f32,
z_range: Range<f32>,
) -> impl Iterator<Item = Aabb<f32>> + '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);

View File

@ -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<Event> {
span!(_guard, "Server::handle_events");
let mut frontend_events = Vec::new();
let mut requested_chunks = Vec::new();

View File

@ -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::<Client>().get(entity) {
let participant = match client.participant.try_lock() {
Ok(mut p) => p.take().unwrap(),

View File

@ -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;

View File

@ -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();

View File

@ -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();

View File

@ -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

View File

@ -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(

View File

@ -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);

View File

@ -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

View File

@ -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();

View File

@ -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

View File

@ -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