3 releases

0.1.2 Oct 17, 2019
0.1.1 Aug 31, 2019
0.1.0 Aug 31, 2019

#775 in Unix APIs

Download history 8/week @ 2024-07-27 15/week @ 2024-09-21 22/week @ 2024-09-28 93/week @ 2024-10-05 161/week @ 2024-10-12 114/week @ 2024-10-19 77/week @ 2024-10-26 86/week @ 2024-11-02

444 downloads per month

MPL-2.0 license

22KB
557 lines

PSI (Pressure Stall Information)

Utilities for working with PSI on Linux 4.20+.

Documentation Build Status Crate

Usage

[dependencies]
psi = "0.1"

License

Copyright (c) Chris Manning

This project is licensed under the MPL-2.0 license.


lib.rs:

Linux Pressure Stall Information (PSI) support for Rust.

About

The Linux Pressure Stall Information (PSI) feature provides real-time pressure information for CPU, IO and memory. psi is a rust library for reading PSI and monitoring for pressure thresholds on Linux 4.20+.

Example

use crate::psi::*;

fn example() -> Result<()> {
    let all: AllPsiStats = PsiKind::Memory.read_psi()?;
    if all.some.avg10 > 0.1f32 {
        // do something
    }
    let full: Psi = PsiKind::Memory.read_psi_line(PsiLine::Full)?;
    if full.avg60 > 0.1f32 {
        // do something else
    }
    Ok(())
}

Monitor Example

use std::time::Duration;
use crate::psi::*;

fn example() -> Result<()> {
    let mut monitor = PsiMonitor::new()?;
    let oom_id = monitor.add_trigger(
        Trigger::new_builder()
            .memory()
            .full()
            .stall(Duration::from_millis(100))
            .window(Duration::from_millis(500))
            .build(),
    )?;

    loop {
        let psi_event: PsiEvent = monitor.wait_single()?;
        // react to psi_event
    }
}

TODO

  • cgroup2 support

Dependencies

~110KB