diff --git a/Cargo.lock b/Cargo.lock index aaa8deb05c..10c79eca12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4105,9 +4105,9 @@ dependencies = [ [[package]] name = "portpicker" version = "0.1.0" -source = "git+https://github.com/xMAC94x/portpicker-rs#9d6df36c53c94684080a64a7212dd6bfc3617ee4" +source = "git+https://github.com/xMAC94x/portpicker-rs?rev=df6b37872f3586ac3b21d08b56c8ec7cd92fb172#df6b37872f3586ac3b21d08b56c8ec7cd92fb172" dependencies = [ - "rand 0.7.3", + "rand 0.8.3", ] [[package]] @@ -5030,11 +5030,12 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" [[package]] name = "slotmap" -version = "0.4.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c46a3482db8f247956e464d783693ece164ca056e6e67563ee5505bdb86452cd" +checksum = "ab3003725ae562cf995f3dc82bb99e70926e09000396816765bb6d7adbe740b1" dependencies = [ "serde", + "version_check 0.9.2", ] [[package]] @@ -6177,6 +6178,7 @@ dependencies = [ "portpicker", "prometheus", "rand 0.8.3", + "rayon", "ron", "scan_fmt", "serde", diff --git a/assets/common/abilities/unique/quadlowquick/dash.ron b/assets/common/abilities/unique/quadlowquick/dash.ron index cf29972bc0..5309a610da 100644 --- a/assets/common/abilities/unique/quadlowquick/dash.ron +++ b/assets/common/abilities/unique/quadlowquick/dash.ron @@ -11,7 +11,7 @@ DashMelee( energy_drain: 0, forward_speed: 2.0, buildup_duration: 0.5, - charge_duration: 0.3, + charge_duration: 0.4, swing_duration: 0.1, recover_duration: 0.5, infinite_charge: true, diff --git a/assets/common/abilities/unique/quadmedquick/dash.ron b/assets/common/abilities/unique/quadmedquick/dash.ron index f58c3059dc..83d195e0df 100644 --- a/assets/common/abilities/unique/quadmedquick/dash.ron +++ b/assets/common/abilities/unique/quadmedquick/dash.ron @@ -9,9 +9,9 @@ DashMelee( range: 2.0, angle: 45.0, energy_drain: 0, - forward_speed: 2.0, + forward_speed: 2.5, buildup_duration: 1.2, - charge_duration: 0.3, + charge_duration: 0.5, swing_duration: 0.1, recover_duration: 0.5, infinite_charge: true, diff --git a/common/Cargo.toml b/common/Cargo.toml index fdd42a15f7..8e59157520 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -37,7 +37,7 @@ image = { version = "0.23.12", default-features = false, features = ["png"] } # Data structures hashbrown = { version = "0.9", features = ["rayon", "serde", "nightly"] } -slotmap = { version = "0.4.0", features = ["serde", "unstable"] } +slotmap = { version = "1.0", features = ["serde"] } indexmap = "1.3.0" slab = "0.4.2" diff --git a/common/sys/src/lib.rs b/common/sys/src/lib.rs index 88daef5fa5..560e56af65 100644 --- a/common/sys/src/lib.rs +++ b/common/sys/src/lib.rs @@ -1,6 +1,5 @@ #![feature(label_break_value, bool_to_option, option_unwrap_none)] -pub mod agent; mod aura; mod beam; mod buff; @@ -21,7 +20,6 @@ use specs::DispatcherBuilder; // System names pub const CHARACTER_BEHAVIOR_SYS: &str = "character_behavior_sys"; pub const MELEE_SYS: &str = "melee_sys"; -pub const AGENT_SYS: &str = "agent_sys"; pub const BEAM_SYS: &str = "beam_sys"; pub const CONTROLLER_SYS: &str = "controller_sys"; pub const MOUNT_SYS: &str = "mount_sys"; @@ -33,9 +31,8 @@ pub const BUFFS_SYS: &str = "buffs_sys"; pub const AURAS_SYS: &str = "auras_sys"; pub fn add_local_systems(dispatch_builder: &mut DispatcherBuilder) { - dispatch_builder.add(agent::Sys, AGENT_SYS, &[]); - dispatch_builder.add(mount::Sys, MOUNT_SYS, &[AGENT_SYS]); - dispatch_builder.add(controller::Sys, CONTROLLER_SYS, &[AGENT_SYS, MOUNT_SYS]); + dispatch_builder.add(mount::Sys, MOUNT_SYS, &[]); + dispatch_builder.add(controller::Sys, CONTROLLER_SYS, &[MOUNT_SYS]); dispatch_builder.add(character_behavior::Sys, CHARACTER_BEHAVIOR_SYS, &[ CONTROLLER_SYS, ]); diff --git a/server/Cargo.toml b/server/Cargo.toml index 8281a32f48..aa4c5d3676 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -38,10 +38,11 @@ serde_json = "1.0.50" rand = { version = "0.8", features = ["small_rng"] } chrono = "0.4.9" hashbrown = { version = "0.9", features = ["rayon", "serde", "nightly"] } +rayon = "1.5" crossbeam-channel = "0.5" prometheus = { version = "0.11", default-features = false} tiny_http = "0.7.0" -portpicker = { git = "https://github.com/xMAC94x/portpicker-rs" } +portpicker = { git = "https://github.com/xMAC94x/portpicker-rs", rev = "df6b37872f3586ac3b21d08b56c8ec7cd92fb172" } authc = { git = "https://gitlab.com/veloren/auth.git", rev = "bffb5181a35c19ddfd33ee0b4aedba741aafb68d" } libsqlite3-sys = { version = "0.18", features = ["bundled"] } diesel = { version = "1.4.3", features = ["sqlite"] } diff --git a/server/src/lib.rs b/server/src/lib.rs index 4fc3707b1e..93c5916d72 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -1,7 +1,13 @@ #![deny(unsafe_code)] #![allow(clippy::option_map_unit_fn)] #![deny(clippy::clone_on_ref_ptr)] -#![feature(bool_to_option, drain_filter, option_unwrap_none, option_zip)] +#![feature( + label_break_value, + bool_to_option, + drain_filter, + option_unwrap_none, + option_zip +)] #![cfg_attr(not(feature = "worldgen"), feature(const_panic))] pub mod alias_validator; @@ -195,6 +201,7 @@ impl Server { state.ecs_mut().insert(sys::WaypointTimer::default()); state.ecs_mut().insert(sys::InviteTimeoutTimer::default()); state.ecs_mut().insert(sys::PersistenceTimer::default()); + state.ecs_mut().insert(sys::AgentTimer::default()); // System schedulers to control execution of systems state @@ -500,6 +507,7 @@ impl Server { sys::msg::character_screen::Sys.run_now(&self.state.ecs()); sys::msg::in_game::Sys.run_now(&self.state.ecs()); sys::msg::ping::Sys.run_now(&self.state.ecs()); + sys::agent::Sys.run_now(&self.state.ecs()); let before_state_tick = Instant::now(); @@ -689,6 +697,7 @@ impl Server { // 8) Update Metrics // Get system timing info + let agent_nanos = self.state.ecs().read_resource::().nanos as i64; let entity_sync_nanos = self .state .ecs() @@ -726,7 +735,7 @@ impl Server { .read_resource::() .nanos as i64; let total_sys_ran_in_dispatcher_nanos = - terrain_nanos + waypoint_nanos + invite_timeout_nanos; + terrain_nanos + waypoint_nanos + invite_timeout_nanos + stats_persistence_nanos; // Report timing info self.tick_metrics @@ -796,6 +805,10 @@ impl Server { .tick_time .with_label_values(&["persistence:stats"]) .set(stats_persistence_nanos); + self.tick_metrics + .tick_time + .with_label_values(&["agent"]) + .set(agent_nanos); //detailed state metrics { @@ -813,8 +826,7 @@ impl Server { let projectile_ns = res.projectile_ns.load(Ordering::Relaxed); let melee_ns = res.melee_ns.load(Ordering::Relaxed); - c.with_label_values(&[common_sys::AGENT_SYS]) - .inc_by(agent_ns); + c.with_label_values(&[sys::AGENT_SYS]).inc_by(agent_ns); c.with_label_values(&[common_sys::MOUNT_SYS]) .inc_by(mount_ns); c.with_label_values(&[common_sys::CONTROLLER_SYS]) @@ -831,7 +843,7 @@ impl Server { const NANOSEC_PER_SEC: f64 = Duration::from_secs(1).as_nanos() as f64; let h = &self.state_tick_metrics.state_tick_time_hist; - h.with_label_values(&[common_sys::AGENT_SYS]) + h.with_label_values(&[sys::AGENT_SYS]) .observe(agent_ns as f64 / NANOSEC_PER_SEC); h.with_label_values(&[common_sys::MOUNT_SYS]) .observe(mount_ns as f64 / NANOSEC_PER_SEC); diff --git a/common/sys/src/agent.rs b/server/src/sys/agent.rs similarity index 99% rename from common/sys/src/agent.rs rename to server/src/sys/agent.rs index cfa1eb389f..1f9408ecf3 100644 --- a/common/sys/src/agent.rs +++ b/server/src/sys/agent.rs @@ -1,3 +1,4 @@ +use super::SysTimer; use common::{ comp::{ self, @@ -48,6 +49,7 @@ impl<'a> System<'a> for Sys { Read<'a, Time>, Read<'a, DeltaTime>, Read<'a, group::GroupManager>, + Write<'a, SysTimer>, ), ReadExpect<'a, SysMetrics>, Write<'a, EventBus>, @@ -79,7 +81,7 @@ impl<'a> System<'a> for Sys { fn run( &mut self, ( - (uid_allocator, time, dt, group_manager), + (uid_allocator, time, dt, group_manager, mut sys_timer), sys_metrics, event_bus, entities, @@ -108,6 +110,7 @@ impl<'a> System<'a> for Sys { ) { let start_time = std::time::Instant::now(); span!(_guard, "run", "agent::Sys::run"); + sys_timer.start(); ( &entities, @@ -1595,6 +1598,8 @@ impl<'a> System<'a> for Sys { start_time.elapsed().as_nanos() as u64, std::sync::atomic::Ordering::Relaxed, ); + + sys_timer.end(); } } diff --git a/server/src/sys/mod.rs b/server/src/sys/mod.rs index 7e34ea933b..d784ec5c18 100644 --- a/server/src/sys/mod.rs +++ b/server/src/sys/mod.rs @@ -1,3 +1,4 @@ +pub mod agent; pub mod entity_sync; pub mod invite_timeout; pub mod msg; @@ -29,6 +30,7 @@ pub type WaypointTimer = SysTimer; pub type InviteTimeoutTimer = SysTimer; pub type PersistenceTimer = SysTimer; pub type PersistenceScheduler = SysScheduler; +pub type AgentTimer = SysTimer; // System names // Note: commented names may be useful in the future @@ -41,6 +43,7 @@ const WAYPOINT_SYS: &str = "server_waypoint_sys"; const INVITE_TIMEOUT_SYS: &str = "server_invite_timeout_sys"; const PERSISTENCE_SYS: &str = "server_persistence_sys"; const OBJECT_SYS: &str = "server_object_sys"; +pub const AGENT_SYS: &str = "agent_sys"; pub fn add_server_systems(dispatch_builder: &mut DispatcherBuilder) { dispatch_builder.add(terrain::Sys, TERRAIN_SYS, &[]);