mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
adjust metrics to rebased Chunks
This commit is contained in:
parent
49b08b55c7
commit
58b0b49dfe
@ -66,6 +66,10 @@ impl<V: Vox, S: RectVolSize, M: Clone> Chonk<V, S, M> {
|
||||
self.z_offset + (self.sub_chunks.len() as u32 * SubChunkSize::<S>::SIZE.z) as i32
|
||||
}
|
||||
|
||||
pub fn sub_chunks_len(&self) -> usize {
|
||||
self.sub_chunks.len()
|
||||
}
|
||||
|
||||
// Returns the index (in self.sub_chunks) of the SubChunk that contains
|
||||
// layer z; note that this index changes when more SubChunks are prepended
|
||||
fn sub_chunk_idx(&self, z: i32) -> i32 {
|
||||
@ -267,40 +271,6 @@ impl<'a, V: Vox, S: RectVolSize, M: Clone> IntoPosIterator for &'a Chonk<V, S, M
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct ChonkMetrics {
|
||||
chonks: usize,
|
||||
homogeneous: usize,
|
||||
hash: usize,
|
||||
heterogeneous: usize,
|
||||
}
|
||||
|
||||
impl ChonkMetrics {
|
||||
pub fn chonks(&self) -> usize {
|
||||
self.chonks
|
||||
}
|
||||
pub fn homogeneous(&self) -> usize {
|
||||
self.homogeneous
|
||||
}
|
||||
pub fn hash(&self) -> usize {
|
||||
self.hash
|
||||
}
|
||||
pub fn heterogeneous(&self) -> usize {
|
||||
self.heterogeneous
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for ChonkMetrics {
|
||||
fn default() -> Self {
|
||||
ChonkMetrics {
|
||||
chonks: 0,
|
||||
homogeneous: 0,
|
||||
hash: 0,
|
||||
heterogeneous: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, V: Vox, S: RectVolSize, M: Clone> IntoVolIterator<'a> for &'a Chonk<V, S, M> {
|
||||
type IntoIter = ChonkVolIter<'a, V, S, M>;
|
||||
|
||||
|
@ -23,7 +23,7 @@ use common::{
|
||||
msg::{ClientMsg, ClientState, RequestStateError, ServerError, ServerInfo, ServerMsg},
|
||||
net::PostOffice,
|
||||
state::{BlockChange, State, TimeOfDay, Uid},
|
||||
terrain::{block::Block, chonk::ChonkMetrics, TerrainChunk, TerrainChunkSize, TerrainGrid},
|
||||
terrain::{block::Block, TerrainChunk, TerrainChunkSize, TerrainGrid},
|
||||
vol::{ReadVol, RectVolSize, Vox},
|
||||
};
|
||||
use crossbeam::channel;
|
||||
@ -617,23 +617,13 @@ impl Server {
|
||||
.with_label_values(&["sync"])
|
||||
.set((before_tick_7 - before_tick_6).as_nanos() as i64);
|
||||
self.metrics.player_online.set(self.clients.len() as i64);
|
||||
let cm = self
|
||||
.state
|
||||
.terrain()
|
||||
.iter()
|
||||
.fold(ChonkMetrics::default(), |a, (_, c)| a + c.get_metrics());
|
||||
self.metrics
|
||||
.chonks_count
|
||||
.with_label_values(&["homogeneous"])
|
||||
.set(cm.homogeneous() as i64);
|
||||
self.metrics
|
||||
.chonks_count
|
||||
.with_label_values(&["hash"])
|
||||
.set(cm.hash() as i64);
|
||||
self.metrics
|
||||
.chonks_count
|
||||
.with_label_values(&["heterogeneous"])
|
||||
.set(cm.heterogeneous() as i64);
|
||||
let mut chonk_cnt = 0;
|
||||
let chunk_cnt = self.state.terrain().iter().fold(0, |a, (_, c)| {
|
||||
chonk_cnt += 1;
|
||||
a + c.sub_chunks_len()
|
||||
});
|
||||
self.metrics.chonks_count.set(chonk_cnt as i64);
|
||||
self.metrics.chunks_count.set(chunk_cnt as i64);
|
||||
//self.metrics.entity_count.set(self.state.);
|
||||
self.metrics
|
||||
.tick_time
|
||||
|
@ -8,7 +8,8 @@ use std::thread;
|
||||
use std::thread::JoinHandle;
|
||||
|
||||
pub struct ServerMetrics {
|
||||
pub chonks_count: IntGaugeVec,
|
||||
pub chonks_count: IntGauge,
|
||||
pub chunks_count: IntGauge,
|
||||
pub player_online: IntGauge,
|
||||
pub entity_count: IntGauge,
|
||||
pub tick_time: IntGaugeVec,
|
||||
@ -39,15 +40,16 @@ impl ServerMetrics {
|
||||
"number of all lights currently active on the server",
|
||||
);
|
||||
let light_count = IntGauge::with_opts(opts).unwrap();
|
||||
let vec = IntGaugeVec::new(
|
||||
Opts::new(
|
||||
"chonks_count",
|
||||
"number of all chonks currently active on the server",
|
||||
),
|
||||
&["type"],
|
||||
)
|
||||
.unwrap();
|
||||
let chonks_count: IntGaugeVec = IntGaugeVec::from(vec);
|
||||
let opts = Opts::new(
|
||||
"chonks_count",
|
||||
"number of all chonks currently active on the server",
|
||||
);
|
||||
let chonks_count = IntGauge::with_opts(opts).unwrap();
|
||||
let opts = Opts::new(
|
||||
"chunks_count",
|
||||
"number of all chunks currently active on the server",
|
||||
);
|
||||
let chunks_count = IntGauge::with_opts(opts).unwrap();
|
||||
let vec = IntGaugeVec::new(
|
||||
Opts::new("tick_time", "time in ns requiered for a tick of the server"),
|
||||
&["period"],
|
||||
@ -62,16 +64,19 @@ impl ServerMetrics {
|
||||
registry.register(Box::new(build_info.clone())).unwrap();
|
||||
//registry.register(Box::new(light_count.clone())).unwrap();
|
||||
registry.register(Box::new(chonks_count.clone())).unwrap();
|
||||
registry.register(Box::new(chunks_count.clone())).unwrap();
|
||||
registry.register(Box::new(tick_time.clone())).unwrap();
|
||||
prometheus::register(Box::new(player_online.clone())).unwrap();
|
||||
prometheus::register(Box::new(entity_count.clone())).unwrap();
|
||||
prometheus::register(Box::new(build_info.clone())).unwrap();
|
||||
//prometheus::register(Box::new(light_count.clone())).unwrap();
|
||||
prometheus::register(Box::new(chonks_count.clone())).unwrap();
|
||||
prometheus::register(Box::new(chunks_count.clone())).unwrap();
|
||||
prometheus::register(Box::new(tick_time.clone())).unwrap();
|
||||
|
||||
let mut metrics = Self {
|
||||
chonks_count,
|
||||
chunks_count,
|
||||
player_online,
|
||||
entity_count,
|
||||
tick_time,
|
||||
|
Loading…
Reference in New Issue
Block a user