fn clean_old_stats(&mut self) {
        let stat_ptr = &self.stat_buffer[0];
        let size_of_stat = size_of_val(stat_ptr);
        let curr_size = size_of_stat * self.stat_buffer.len();
        trace!("current_size of stats in socket {}: {}", self.id, curr_size);
        trace!(
            "estimated max nb of socket stats: {}",
            self.buffer_max_kbytes as f32 * 1000.0 / size_of_stat as f32
        );
        if curr_size > (self.buffer_max_kbytes * 1000) as usize {
            let size_diff = curr_size - (self.buffer_max_kbytes * 1000) as usize;
            trace!(
                "socket {} size_diff: {} size of: {}",
                self.id,
                size_diff,
                size_of_stat
            );
            if size_diff > size_of_stat {
                let nb_stats_to_delete = size_diff as f32 / size_of_stat as f32;
                trace!(
                    "socket {} nb_stats_to_delete: {} size_diff: {} size of: {}",
                    self.id,
                    nb_stats_to_delete,
                    size_diff,
                    size_of_stat
                );
                trace!("nb stats to delete: {}", nb_stats_to_delete as u32);
                for _ in 1..nb_stats_to_delete as u32 {
                    if !self.stat_buffer.is_empty() {
                        let res = self.stat_buffer.pop();
                        debug!(
                            "Cleaning stat buffer of socket {}, removing: {:?}",
                            self.id, res
                        );
                    }
                }
            }
        }
    }
/// Checks the size in memory of stats_buffer and deletes as many CPUStat
/// instances from the buffer to make it smaller in memory than buffer_max_kbytes.
Checks the size in memory of stats_buffer and deletes as many CPUStat
instances from the buffer to make it smaller in memory than buffer_max_kbytes.
Checks the size in memory of stats_buffer and deletes as many CPUStat instances from the buffer to make it smaller in memory than buffer_max_kbytes .
fn clean_old_stats(&mut self) {
        let stat_ptr = &self.stat_buffer[0];
        let size_of_stat = size_of_val(stat_ptr);
        let curr_size = size_of_stat * self.stat_buffer.len();
        trace!("current_size of stats in socket {}: {}", self.id, curr_size);
        trace!(
            "estimated max nb of socket stats: {}",
            self.buffer_max_kbytes as f32 * 1000.0 / size_of_stat as f32
        );
        if curr_size > (self.buffer_max_kbytes * 1000) as usize {
            let size_diff = curr_size - (self.buffer_max_kbytes * 1000) as usize;
            trace!(
                "socket {} size_diff: {} size of: {}",
                self.id,
                size_diff,
                size_of_stat
            );
            if size_diff > size_of_stat {
                let nb_stats_to_delete = size_diff as f32 / size_of_stat as f32;
                trace!(
                    "socket {} nb_stats_to_delete: {} size_diff: {} size of: {}",
                    self.id,
                    nb_stats_to_delete,
                    size_diff,
                    size_of_stat
                );
                trace!("nb stats to delete: {}", nb_stats_to_delete as u32);
                for _ in 1..nb_stats_to_delete as u32 {
                    if !self.stat_buffer.is_empty() {
                        let res = self.stat_buffer.pop();
                        debug!(
                            "Cleaning stat buffer of socket {}, removing: {:?}",
                            self.id, res
                        );
                    }
                }
            }
        }
    }
fn clean_old_stats ( & mut self ) { let stat_ptr = & self . stat_buffer [ 0 ] ; let size_of_stat = size_of_val ( stat_ptr ) ; let curr_size = size_of_stat * self . stat_buffer . len ( ) ; trace ! ( " " self id curr_size ) ; trace ! ( " " self buffer_max_kbytes as f32 1000.0 size_of_stat as f32 ) ; if curr_size > ( self . buffer_max_kbytes * 1000 ) as usize { let size_diff = curr_size - ( self . buffer_max_kbytes * 1000 ) as usize ; trace ! ( " " self id size_diff size_of_stat ) ; if size_diff > size_of_stat { let nb_stats_to_delete = size_diff as f32 / size_of_stat as f32 ; trace ! ( " " self id nb_stats_to_delete size_diff size_of_stat ) ; trace ! ( " " nb_stats_to_delete as u32 ) ; for _ in 1 .. nb_stats_to_delete as u32 { if ! self . stat_buffer . is_empty ( ) { let res = self . stat_buffer . pop ( ) ; debug ! ( " " self id res ) ; } } } } }
Checks the size in memory of stats_buffer and deletes as many CPUStat
instances from the buffer to make it smaller in memory than buffer_max_kbytes.
Checks the size in memory of stats_buffer and deletes as many CPUStat instances from the buffer to make it smaller in memory than buffer_max_kbytes .
&mut self
&mut self