-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract shm stats code into common crate
Also change log level to INFO, as it's really useful for performance tuning, and would get lost in DEBUG messages...
- Loading branch information
Showing
11 changed files
with
166 additions
and
130 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ members = [ | |
"ipc_test", | ||
"playegui", | ||
"bs-sys", | ||
"stats", | ||
] | ||
|
||
[profile.release] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
name = "libertem-asi-tpx3" | ||
authors = ["Alexander Clausen <[email protected]>"] | ||
license = "MIT" | ||
version = "0.2.6" | ||
version = "0.2.7" | ||
edition = "2021" | ||
readme = "README.md" | ||
|
||
|
@@ -22,6 +22,7 @@ pyo3 = { version = "0.17", features = ["abi3-py37"] } | |
serde = { version = "1.0.143", features = ["derive"] } | ||
uuid = { version = "1.1.2", features = ["v4", "fast-rng"] } | ||
ipc-test = { path = "../ipc_test" } | ||
stats = { path = "../stats" } | ||
zerocopy = "0.6.1" | ||
|
||
[dev-dependencies] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,31 @@ | ||
use log::debug; | ||
use stats::GetStats; | ||
|
||
use crate::chunk_stack::ChunkStackHandle; | ||
|
||
pub struct Stats { | ||
/// total number of bytes (compressed) that have flown through the system | ||
payload_size_sum: usize, | ||
|
||
/// maximum size of compressed frames seen | ||
frame_size_max: usize, | ||
|
||
/// minimum size of compressed frames seen | ||
frame_size_min: usize, | ||
|
||
/// sum of the size of the slots used | ||
slots_size_sum: usize, | ||
|
||
/// number of frames seen | ||
num_frames: usize, | ||
|
||
/// number of times a frame stack was split | ||
split_count: usize, | ||
} | ||
|
||
impl Stats { | ||
pub fn new() -> Self { | ||
Self { | ||
payload_size_sum: 0, | ||
slots_size_sum: 0, | ||
frame_size_max: 0, | ||
frame_size_min: usize::MAX, | ||
num_frames: 0, | ||
split_count: 0, | ||
} | ||
impl GetStats for ChunkStackHandle { | ||
fn payload_size(&self) -> usize { | ||
self.payload_size() | ||
} | ||
|
||
pub fn count_chunk_stack(&mut self, chunk_stack: &ChunkStackHandle) { | ||
self.payload_size_sum += chunk_stack.payload_size(); | ||
self.slots_size_sum += chunk_stack.slot_size(); | ||
self.frame_size_max = self.frame_size_max.max( | ||
chunk_stack | ||
.get_layout() | ||
.iter() | ||
.max_by_key(|fm| fm.data_length_bytes) | ||
.map_or(self.frame_size_max, |fm| fm.data_length_bytes), | ||
); | ||
self.frame_size_min = self.frame_size_min.min( | ||
chunk_stack | ||
.get_layout() | ||
.iter() | ||
.min_by_key(|fm| fm.data_length_bytes) | ||
.map_or(self.frame_size_min, |fm| fm.data_length_bytes), | ||
); | ||
self.num_frames += chunk_stack.len() as usize; | ||
fn slot_size(&self) -> usize { | ||
self.slot_size() | ||
} | ||
|
||
pub fn count_split(&mut self) { | ||
self.split_count += 1; | ||
fn max_frame_size(&self, old_max: usize) -> usize { | ||
self.get_layout() | ||
.iter() | ||
.max_by_key(|fm| fm.data_length_bytes) | ||
.map_or(old_max, |fm| fm.data_length_bytes) | ||
} | ||
|
||
pub fn log_stats(&self) { | ||
let efficiency = self.payload_size_sum as f32 / self.slots_size_sum as f32; | ||
debug!( | ||
"Stats: frames seen: {}, total payload size: {}, total slot size used: {}, min chunk size: {}, max chunk size: {}, splits: {}, shm efficiency: {}", | ||
self.num_frames, self.payload_size_sum, self.slots_size_sum, self.frame_size_min, self.frame_size_max, self.split_count, efficiency, | ||
); | ||
fn min_frame_size(&self, old_min: usize) -> usize { | ||
self.get_layout() | ||
.iter() | ||
.min_by_key(|fm| fm.data_length_bytes) | ||
.map_or(old_min, |fm| fm.data_length_bytes) | ||
} | ||
} | ||
|
||
impl Default for Stats { | ||
fn default() -> Self { | ||
Self::new() | ||
fn num_frames(&self) -> usize { | ||
self.len() as usize | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
name = "libertem-dectris" | ||
authors = ["Alexander Clausen <[email protected]>"] | ||
license = "MIT" | ||
version = "0.2.6" | ||
version = "0.2.7" | ||
edition = "2021" | ||
readme = "README.md" | ||
|
||
|
@@ -32,6 +32,7 @@ spin_sleep = "1.1.1" | |
uuid = { version = "1.1.2", features = ["v4", "fast-rng"] } | ||
zmq = { version = "0.10.0", features = [] } | ||
ipc-test = { path = "../ipc_test" } | ||
stats = { path = "../stats" } | ||
nix = "0.26.1" | ||
lz4 = "1.24.0" | ||
zerocopy = "0.6.1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,31 @@ | ||
use log::debug; | ||
use stats::GetStats; | ||
|
||
use crate::frame_stack::FrameStackHandle; | ||
|
||
pub struct Stats { | ||
/// total number of bytes (compressed) that have flown through the system | ||
payload_size_sum: usize, | ||
|
||
/// maximum size of compressed frames seen | ||
frame_size_max: usize, | ||
|
||
/// minimum size of compressed frames seen | ||
frame_size_min: usize, | ||
|
||
/// sum of the size of the slots used | ||
slots_size_sum: usize, | ||
|
||
/// number of frames seen | ||
num_frames: usize, | ||
|
||
/// number of times a frame stack was split | ||
split_count: usize, | ||
} | ||
|
||
impl Stats { | ||
pub fn new() -> Self { | ||
Self { | ||
payload_size_sum: 0, | ||
slots_size_sum: 0, | ||
frame_size_max: 0, | ||
frame_size_min: usize::MAX, | ||
num_frames: 0, | ||
split_count: 0, | ||
} | ||
impl GetStats for FrameStackHandle { | ||
fn payload_size(&self) -> usize { | ||
self.payload_size() | ||
} | ||
|
||
pub fn count_frame_stack(&mut self, frame_stack: &FrameStackHandle) { | ||
self.payload_size_sum += frame_stack.payload_size(); | ||
self.slots_size_sum += frame_stack.slot_size(); | ||
self.frame_size_max = self.frame_size_max.max( | ||
frame_stack | ||
.get_meta() | ||
.iter() | ||
.max_by_key(|fm| fm.data_length_bytes) | ||
.map_or(self.frame_size_max, |fm| fm.data_length_bytes), | ||
); | ||
self.frame_size_min = self.frame_size_min.min( | ||
frame_stack | ||
.get_meta() | ||
.iter() | ||
.min_by_key(|fm| fm.data_length_bytes) | ||
.map_or(self.frame_size_min, |fm| fm.data_length_bytes), | ||
); | ||
self.num_frames += frame_stack.len(); | ||
fn slot_size(&self) -> usize { | ||
self.slot_size() | ||
} | ||
|
||
pub fn count_split(&mut self) { | ||
self.split_count += 1; | ||
fn max_frame_size(&self, old_max: usize) -> usize { | ||
self.get_meta() | ||
.iter() | ||
.max_by_key(|fm| fm.data_length_bytes) | ||
.map_or(old_max, |fm| fm.data_length_bytes) | ||
} | ||
|
||
pub fn log_stats(&self) { | ||
let efficiency = self.payload_size_sum as f32 / self.slots_size_sum as f32; | ||
debug!( | ||
"Stats: frames seen: {}, total payload size: {}, total slot size used: {}, min frame size: {}, max frame size: {}, splits: {}, shm efficiency: {}", | ||
self.num_frames, self.payload_size_sum, self.slots_size_sum, self.frame_size_min, self.frame_size_max, self.split_count, efficiency, | ||
); | ||
fn min_frame_size(&self, old_min: usize) -> usize { | ||
self.get_meta() | ||
.iter() | ||
.min_by_key(|fm| fm.data_length_bytes) | ||
.map_or(old_min, |fm| fm.data_length_bytes) | ||
} | ||
} | ||
|
||
impl Default for Stats { | ||
fn default() -> Self { | ||
Self::new() | ||
fn num_frames(&self) -> usize { | ||
self.len() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "stats" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
log = "0.4.17" |
Oops, something went wrong.