mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'imbris/specs-bench' into 'master'
Add server-cli bench command for profiling and update specs See merge request veloren/veloren!4112
This commit is contained in:
commit
b372a0c836
38
Cargo.lock
generated
38
Cargo.lock
generated
@ -3600,12 +3600,6 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mopa"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a785740271256c230f57462d3b83e52f998433a7062fc18f96d5999474a9f915"
|
||||
|
||||
[[package]]
|
||||
name = "more-asserts"
|
||||
version = "0.2.2"
|
||||
@ -4588,7 +4582,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "332cd62e95873ea4f41f3dfd6bbbfc5b52aec892d7e8d534197c4720a0bbbab2"
|
||||
dependencies = [
|
||||
"profiling-procmacros",
|
||||
"tracy-client 0.15.2",
|
||||
"tracy-client",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -5685,13 +5679,12 @@ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
|
||||
|
||||
[[package]]
|
||||
name = "shred"
|
||||
version = "0.13.0"
|
||||
version = "0.14.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "102269e720bb814df57e136161cad841f2b6f411e003ac748fc48aaf2363bea3"
|
||||
checksum = "d6aa4148ce950f367ede79bff6bb04bbf3c31317a1291315078ef60c080821a1"
|
||||
dependencies = [
|
||||
"ahash 0.7.6",
|
||||
"arrayvec 0.7.4",
|
||||
"hashbrown 0.12.3",
|
||||
"mopa",
|
||||
"rayon",
|
||||
"shred-derive",
|
||||
"smallvec",
|
||||
@ -5862,12 +5855,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "specs"
|
||||
version = "0.18.0"
|
||||
version = "0.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ea85dac2880f84d4025ff5ace80cda6d8bc43bc88b6a389b9277fcf894b51e9"
|
||||
checksum = "ad2e89cb8aba27bebf48a5a47b4889e7b317a08884d92cc36109d58992d41325"
|
||||
dependencies = [
|
||||
"ahash 0.7.6",
|
||||
"crossbeam-queue",
|
||||
"hashbrown 0.12.3",
|
||||
"hibitset",
|
||||
"log",
|
||||
"rayon",
|
||||
@ -6532,13 +6525,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tracing-tracy"
|
||||
version = "0.10.3"
|
||||
version = "0.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f3edd27f53bc0e55aefa9223f68eb44354060103d3e34635f6e27627fe0227f"
|
||||
checksum = "55c48ef3e655220d4e43a6be44aa84f078c3004357251cab45f9cc15551a593e"
|
||||
dependencies = [
|
||||
"tracing-core",
|
||||
"tracing-subscriber",
|
||||
"tracy-client 0.16.1",
|
||||
"tracy-client",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -6552,17 +6545,6 @@ dependencies = [
|
||||
"tracy-client-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracy-client"
|
||||
version = "0.16.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1c78458aa3759647e0399e959a06f9f6dc61450a1caaa4f1632a3df8e8c55af7"
|
||||
dependencies = [
|
||||
"loom",
|
||||
"once_cell",
|
||||
"tracy-client-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracy-client-sys"
|
||||
version = "0.21.1"
|
||||
|
@ -149,7 +149,7 @@ serde = { version = "1.0.118", features = ["derive"] }
|
||||
serde_json = { version = "1.0.50" }
|
||||
ron = { version = "0.8", default-features = false}
|
||||
|
||||
specs = { version = "0.18", features = ["nightly"] }
|
||||
specs = { version = "0.19", features = ["nightly"] }
|
||||
image = { version = "0.24", default-features = false, features = ["png"] }
|
||||
rayon = { version = "1.5" }
|
||||
|
||||
|
@ -20,4 +20,5 @@ tracing-subscriber = { version = "0.3.7", default-features = false, features = [
|
||||
|
||||
# Tracy
|
||||
# NOTE: This must be kept in sync with the `profiling` version in `common/base`.
|
||||
tracing-tracy = { version = "0.10.2", optional = true }
|
||||
# NOTE: `=` since the minor version of tracing-tracy bumped a major version of `tracy-client`
|
||||
tracing-tracy = { version = "=0.10.2", optional = true }
|
||||
|
@ -82,10 +82,23 @@ pub struct TuiApp {
|
||||
command: Message,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Parser)]
|
||||
pub struct BenchParams {
|
||||
/// View distance of the loaded area (in chunks)
|
||||
#[arg(long)]
|
||||
pub view_distance: u32,
|
||||
/// Duration to run after loading completes (in seconds).
|
||||
#[arg(long)]
|
||||
pub duration: u32,
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
pub enum ArgvCommand {
|
||||
#[command(flatten)]
|
||||
Shared(SharedCommand),
|
||||
/// Load an area, run the server for some time, and then exit (useful for
|
||||
/// profiling).
|
||||
Bench(BenchParams),
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
|
@ -29,7 +29,7 @@ use server::{persistence::DatabaseSettings, settings::Protocol, Event, Input, Se
|
||||
use std::{
|
||||
io,
|
||||
sync::{atomic::AtomicBool, mpsc, Arc},
|
||||
time::Duration,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
use tracing::{info, trace};
|
||||
|
||||
@ -117,15 +117,16 @@ fn main() -> io::Result<()> {
|
||||
sql_log_mode,
|
||||
};
|
||||
|
||||
let mut bench = None;
|
||||
if let Some(command) = app.command {
|
||||
return match command {
|
||||
match command {
|
||||
ArgvCommand::Shared(SharedCommand::Admin { command }) => {
|
||||
let login_provider = server::login_provider::LoginProvider::new(
|
||||
server_settings.auth_server_address,
|
||||
runtime,
|
||||
);
|
||||
|
||||
match command {
|
||||
return match command {
|
||||
Admin::Add { username, role } => {
|
||||
// FIXME: Currently the UUID can get returned even if the file didn't
|
||||
// change, so this can't be relied on as an error
|
||||
@ -139,6 +140,7 @@ fn main() -> io::Result<()> {
|
||||
&mut editable_settings,
|
||||
&server_data_dir,
|
||||
);
|
||||
Ok(())
|
||||
},
|
||||
Admin::Remove { username } => {
|
||||
// FIXME: Currently the UUID can get returned even if the file didn't
|
||||
@ -152,9 +154,18 @@ fn main() -> io::Result<()> {
|
||||
&mut editable_settings,
|
||||
&server_data_dir,
|
||||
);
|
||||
Ok(())
|
||||
},
|
||||
}
|
||||
Ok(())
|
||||
};
|
||||
},
|
||||
ArgvCommand::Bench(params) => {
|
||||
bench = Some(params);
|
||||
// If we are trying to benchmark, don't limit the server view distance.
|
||||
server_settings.max_view_distance = None;
|
||||
// TODO: add setting to adjust wildlife spawn density, note I
|
||||
// tried but Index setup makes it a bit
|
||||
// annoying, might require a more involved refactor to get
|
||||
// working nicely
|
||||
},
|
||||
};
|
||||
}
|
||||
@ -207,12 +218,28 @@ fn main() -> io::Result<()> {
|
||||
|
||||
// Set up an fps clock
|
||||
let mut clock = Clock::new(Duration::from_secs_f64(1.0 / TPS as f64));
|
||||
// Wait for a tick so we don't start with a zero dt
|
||||
|
||||
if let Some(bench) = bench {
|
||||
#[cfg(feature = "worldgen")]
|
||||
server.create_centered_persister(bench.view_distance);
|
||||
}
|
||||
let mut bench_exit_time = None;
|
||||
|
||||
let mut tick_no = 0u64;
|
||||
loop {
|
||||
tick_no += 1;
|
||||
span!(guard, "work");
|
||||
if let Some(bench) = bench {
|
||||
if let Some(t) = bench_exit_time {
|
||||
if Instant::now() > t {
|
||||
break;
|
||||
}
|
||||
} else if tick_no != 0 && !server.chunks_pending() {
|
||||
println!("Chunk loading complete");
|
||||
bench_exit_time = Some(Instant::now() + Duration::from_secs(bench.duration.into()));
|
||||
}
|
||||
};
|
||||
|
||||
tick_no += 1;
|
||||
// Terminate the server if instructed to do so by the shutdown coordinator
|
||||
if shutdown_coordinator.check(&mut server, &settings) {
|
||||
break;
|
||||
|
@ -1442,6 +1442,15 @@ impl Server {
|
||||
.build();
|
||||
}
|
||||
|
||||
/// Used by benchmarking code.
|
||||
pub fn chunks_pending(&mut self) -> bool {
|
||||
self.state_mut()
|
||||
.mut_resource::<ChunkGenerator>()
|
||||
.pending_chunks()
|
||||
.next()
|
||||
.is_some()
|
||||
}
|
||||
|
||||
/// Sets the SQL log mode at runtime
|
||||
pub fn set_sql_log_mode(&mut self, sql_log_mode: SqlLogMode) {
|
||||
// Unwrap is safe here because we only perform a variable assignment with the
|
||||
|
@ -1,4 +1,5 @@
|
||||
use crate::{
|
||||
chunk_generator::ChunkGenerator,
|
||||
metrics::{EcsSystemMetrics, JobMetrics, PhysicsMetrics, TickMetrics},
|
||||
HwStats, Tick, TickStart,
|
||||
};
|
||||
@ -12,11 +13,12 @@ use std::time::Instant;
|
||||
pub struct Sys;
|
||||
impl<'a> System<'a> for Sys {
|
||||
type SystemData = (
|
||||
Option<Entities<'a>>,
|
||||
Entities<'a>,
|
||||
ReadExpect<'a, HwStats>,
|
||||
ReadExpect<'a, Tick>,
|
||||
ReadExpect<'a, TimeOfDay>,
|
||||
ReadExpect<'a, TickStart>,
|
||||
ReadExpect<'a, ChunkGenerator>,
|
||||
Option<Read<'a, TerrainGrid>>,
|
||||
Read<'a, SysMetrics>,
|
||||
Read<'a, common_ecs::PhysicsMetrics>,
|
||||
@ -39,6 +41,7 @@ impl<'a> System<'a> for Sys {
|
||||
tick,
|
||||
time_of_day,
|
||||
tick_start,
|
||||
chunk_generator,
|
||||
terrain,
|
||||
sys_metrics,
|
||||
phys_metrics,
|
||||
@ -89,7 +92,7 @@ impl<'a> System<'a> for Sys {
|
||||
// Report other info
|
||||
export_tick.time_of_day.set(time_of_day.0);
|
||||
if tick.0.rem_euclid(100) == 0 {
|
||||
if let Some(terrain) = terrain {
|
||||
if let Some(terrain) = terrain.as_ref() {
|
||||
let mut chonk_cnt = 0;
|
||||
let mut group_cnt = 0;
|
||||
let chunk_cnt = terrain.iter().fold(0, |a, (_, c)| {
|
||||
@ -102,11 +105,16 @@ impl<'a> System<'a> for Sys {
|
||||
export_tick.chunk_groups_count.set(group_cnt as i64);
|
||||
}
|
||||
|
||||
if let Some(entities) = entities {
|
||||
let entity_count = entities.join().count();
|
||||
export_tick.entity_count.set(entity_count as i64);
|
||||
common_base::plot!("entity count", entity_count as f64);
|
||||
}
|
||||
let entity_count = entities.join().count();
|
||||
export_tick.entity_count.set(entity_count as i64);
|
||||
}
|
||||
common_base::plot!("entity count", entities.join().count() as f64);
|
||||
common_base::plot!(
|
||||
"pending chunks",
|
||||
chunk_generator.pending_chunks().count() as f64
|
||||
);
|
||||
if let Some(terrain) = terrain.as_ref() {
|
||||
common_base::plot!("chunk count", terrain.iter().count() as f64);
|
||||
}
|
||||
|
||||
//detailed physics metrics
|
||||
|
Loading…
Reference in New Issue
Block a user