3 releases

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

#738 in Unix APIs

Download history 80/week @ 2024-10-24 67/week @ 2024-10-31 178/week @ 2024-11-07 169/week @ 2024-11-14 86/week @ 2024-11-21 121/week @ 2024-11-28 270/week @ 2024-12-05 339/week @ 2024-12-12 162/week @ 2024-12-19 228/week @ 2024-12-26 104/week @ 2025-01-02 413/week @ 2025-01-09 202/week @ 2025-01-16 241/week @ 2025-01-23 352/week @ 2025-01-30 327/week @ 2025-02-06

1,156 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