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:
@ -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
|
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
|
// Returns the index (in self.sub_chunks) of the SubChunk that contains
|
||||||
// layer z; note that this index changes when more SubChunks are prepended
|
// layer z; note that this index changes when more SubChunks are prepended
|
||||||
fn sub_chunk_idx(&self, z: i32) -> i32 {
|
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> {
|
impl<'a, V: Vox, S: RectVolSize, M: Clone> IntoVolIterator<'a> for &'a Chonk<V, S, M> {
|
||||||
type IntoIter = ChonkVolIter<'a, V, S, M>;
|
type IntoIter = ChonkVolIter<'a, V, S, M>;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ use common::{
|
|||||||
msg::{ClientMsg, ClientState, RequestStateError, ServerError, ServerInfo, ServerMsg},
|
msg::{ClientMsg, ClientState, RequestStateError, ServerError, ServerInfo, ServerMsg},
|
||||||
net::PostOffice,
|
net::PostOffice,
|
||||||
state::{BlockChange, State, TimeOfDay, Uid},
|
state::{BlockChange, State, TimeOfDay, Uid},
|
||||||
terrain::{block::Block, chonk::ChonkMetrics, TerrainChunk, TerrainChunkSize, TerrainGrid},
|
terrain::{block::Block, TerrainChunk, TerrainChunkSize, TerrainGrid},
|
||||||
vol::{ReadVol, RectVolSize, Vox},
|
vol::{ReadVol, RectVolSize, Vox},
|
||||||
};
|
};
|
||||||
use crossbeam::channel;
|
use crossbeam::channel;
|
||||||
@ -617,23 +617,13 @@ impl Server {
|
|||||||
.with_label_values(&["sync"])
|
.with_label_values(&["sync"])
|
||||||
.set((before_tick_7 - before_tick_6).as_nanos() as i64);
|
.set((before_tick_7 - before_tick_6).as_nanos() as i64);
|
||||||
self.metrics.player_online.set(self.clients.len() as i64);
|
self.metrics.player_online.set(self.clients.len() as i64);
|
||||||
let cm = self
|
let mut chonk_cnt = 0;
|
||||||
.state
|
let chunk_cnt = self.state.terrain().iter().fold(0, |a, (_, c)| {
|
||||||
.terrain()
|
chonk_cnt += 1;
|
||||||
.iter()
|
a + c.sub_chunks_len()
|
||||||
.fold(ChonkMetrics::default(), |a, (_, c)| a + c.get_metrics());
|
});
|
||||||
self.metrics
|
self.metrics.chonks_count.set(chonk_cnt as i64);
|
||||||
.chonks_count
|
self.metrics.chunks_count.set(chunk_cnt as i64);
|
||||||
.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);
|
|
||||||
//self.metrics.entity_count.set(self.state.);
|
//self.metrics.entity_count.set(self.state.);
|
||||||
self.metrics
|
self.metrics
|
||||||
.tick_time
|
.tick_time
|
||||||
|
@ -8,7 +8,8 @@ use std::thread;
|
|||||||
use std::thread::JoinHandle;
|
use std::thread::JoinHandle;
|
||||||
|
|
||||||
pub struct ServerMetrics {
|
pub struct ServerMetrics {
|
||||||
pub chonks_count: IntGaugeVec,
|
pub chonks_count: IntGauge,
|
||||||
|
pub chunks_count: IntGauge,
|
||||||
pub player_online: IntGauge,
|
pub player_online: IntGauge,
|
||||||
pub entity_count: IntGauge,
|
pub entity_count: IntGauge,
|
||||||
pub tick_time: IntGaugeVec,
|
pub tick_time: IntGaugeVec,
|
||||||
@ -39,15 +40,16 @@ impl ServerMetrics {
|
|||||||
"number of all lights currently active on the server",
|
"number of all lights currently active on the server",
|
||||||
);
|
);
|
||||||
let light_count = IntGauge::with_opts(opts).unwrap();
|
let light_count = IntGauge::with_opts(opts).unwrap();
|
||||||
let vec = IntGaugeVec::new(
|
let opts = Opts::new(
|
||||||
Opts::new(
|
"chonks_count",
|
||||||
"chonks_count",
|
"number of all chonks currently active on the server",
|
||||||
"number of all chonks currently active on the server",
|
);
|
||||||
),
|
let chonks_count = IntGauge::with_opts(opts).unwrap();
|
||||||
&["type"],
|
let opts = Opts::new(
|
||||||
)
|
"chunks_count",
|
||||||
.unwrap();
|
"number of all chunks currently active on the server",
|
||||||
let chonks_count: IntGaugeVec = IntGaugeVec::from(vec);
|
);
|
||||||
|
let chunks_count = IntGauge::with_opts(opts).unwrap();
|
||||||
let vec = IntGaugeVec::new(
|
let vec = IntGaugeVec::new(
|
||||||
Opts::new("tick_time", "time in ns requiered for a tick of the server"),
|
Opts::new("tick_time", "time in ns requiered for a tick of the server"),
|
||||||
&["period"],
|
&["period"],
|
||||||
@ -62,16 +64,19 @@ impl ServerMetrics {
|
|||||||
registry.register(Box::new(build_info.clone())).unwrap();
|
registry.register(Box::new(build_info.clone())).unwrap();
|
||||||
//registry.register(Box::new(light_count.clone())).unwrap();
|
//registry.register(Box::new(light_count.clone())).unwrap();
|
||||||
registry.register(Box::new(chonks_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();
|
registry.register(Box::new(tick_time.clone())).unwrap();
|
||||||
prometheus::register(Box::new(player_online.clone())).unwrap();
|
prometheus::register(Box::new(player_online.clone())).unwrap();
|
||||||
prometheus::register(Box::new(entity_count.clone())).unwrap();
|
prometheus::register(Box::new(entity_count.clone())).unwrap();
|
||||||
prometheus::register(Box::new(build_info.clone())).unwrap();
|
prometheus::register(Box::new(build_info.clone())).unwrap();
|
||||||
//prometheus::register(Box::new(light_count.clone())).unwrap();
|
//prometheus::register(Box::new(light_count.clone())).unwrap();
|
||||||
prometheus::register(Box::new(chonks_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();
|
prometheus::register(Box::new(tick_time.clone())).unwrap();
|
||||||
|
|
||||||
let mut metrics = Self {
|
let mut metrics = Self {
|
||||||
chonks_count,
|
chonks_count,
|
||||||
|
chunks_count,
|
||||||
player_online,
|
player_online,
|
||||||
entity_count,
|
entity_count,
|
||||||
tick_time,
|
tick_time,
|
||||||
|
Reference in New Issue
Block a user