public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Lukas Wagner" <l.wagner@proxmox.com>
To: "Arthur Bied-Charreton" <a.bied-charreton@proxmox.com>,
	"Lukas Wagner" <l.wagner@proxmox.com>
Cc: pdm-devel@lists.proxmox.com
Subject: Re: [PATCH proxmox 11/26] procfs: add helpers for querying pressure stall information
Date: Wed, 18 Mar 2026 15:08:07 +0100	[thread overview]
Message-ID: <DH5YTOLJ7A2Z.2ILESDQV7HSRD@proxmox.com> (raw)
In-Reply-To: <js7os5l2oonivy6i4jdpzqdkz4bfylqsrzcuxd37juevf4b556@ujd7nc6t45ss>

Hey Arthur, thanks for the review!

On Mon Mar 16, 2026 at 2:25 PM CET, Arthur Bied-Charreton wrote:
> On Thu, Mar 12, 2026 at 02:52:12PM +0100, Lukas Wagner wrote:
>> This is put into a new crate, proxmox-procfs, since proxmox-sys is
>> already quite large and should be split in the future. The general idea
>> is that the contents of proxmox_sys::linux::procfs should be moved into
>> this new crate (potentially after some API cleanup) at some point.
>> 
>> Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
> I really like how you designed this, it reads very nicely! 
>
> 2 comments inline 
>> ---
>>  Cargo.toml                          |   2 +
>>  proxmox-procfs/Cargo.toml           |  18 ++
>>  proxmox-procfs/debian/changelog     |   5 +
>>  proxmox-procfs/debian/control       |  50 +++++
>>  proxmox-procfs/debian/copyright     |  18 ++
>>  proxmox-procfs/debian/debcargo.toml |   7 +
>>  proxmox-procfs/src/lib.rs           |   1 +
>>  proxmox-procfs/src/pressure.rs      | 334 ++++++++++++++++++++++++++++
>>  8 files changed, 435 insertions(+)
>>  create mode 100644 proxmox-procfs/Cargo.toml
>>  create mode 100644 proxmox-procfs/debian/changelog
>>  create mode 100644 proxmox-procfs/debian/control
>>  create mode 100644 proxmox-procfs/debian/copyright
>>  create mode 100644 proxmox-procfs/debian/debcargo.toml
>>  create mode 100644 proxmox-procfs/src/lib.rs
>>  create mode 100644 proxmox-procfs/src/pressure.rs
>> +
> [...]
>> +    fn read_pressure_line<R: BufRead>(
>> +        reader: &mut R,
>> +        buf: &mut Vec<u8>,
>> +    ) -> Result<(PressureRecordKind, PressureRecord), Error> {
>> +        // The buffer should be empty. It is only passed by the caller as a performance
>> +        // optimization
>> +        debug_assert!(buf.is_empty());
>> +
>> +        reader.read_until(b'\n', buf)?;
>> +        // SAFETY: In production, `reader` is expected to read from
>> +        // procfs/sysfs pressure files, which only ever should return ASCII strings.
>> +        let line = unsafe { std::str::from_utf8_unchecked(buf) };
> Major nit, but I wonder if using unsafe here is justified, given that this 
> assumption is not enforced at the type level (BufRead could return anything),
> and this is not really a hot code path

I saw the same unsafe block elsewhere in `proxmox-sys` which inspired me
to do the same - but it's probably worth to benchmark this and check if
it actually gives us a real-world performance benefit that is worth the
hassle. As you said, will never be a particularly hot code path, in PDM
(and soon PBS context) this will be called once every 10 seconds.

>> +
>> +        Self::read_record(line)
>> +    }
>> +
>> +
> [...]
>> +#[cfg(test)]
>> +mod test {
>> +    use super::*;
>> +
>> +    #[test]
>> +    fn test_read_psi() {
>> +        let s = "some avg10=1.42 avg60=2.09 avg300=1.42 total=40979658
>> +full avg10=0.08 avg60=0.18 avg300=0.13 total=22865313
>> +";
>> +
>> +        let mut reader = std::io::Cursor::new(s);
>> +        let stats = PressureData::read(&mut reader).unwrap();
>> +
>> +        assert_eq!(stats.some.total, 40979658);
>> +        assert!((stats.some.average_10 - 1.82).abs() < f64::EPSILON);
> This test is failing, looks like this was supposed to be 1.42

Argh, this was a last-minute clippy fix before I sent the series (I
forgot the .abs() initially), apparently I failed to run the tests again
after that.

Thanks! I will of course fix this for v2.

>> +        assert!((stats.some.average_60 - 2.09).abs() < f64::EPSILON);
>> +        assert!((stats.some.average_300 - 1.42).abs() < f64::EPSILON);
>> +
> [...]





  reply	other threads:[~2026-03-18 14:07 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-12 13:52 [PATCH datacenter-manager/proxmox{,-backup,-yew-comp} 00/26] metric collection for the PDM host Lukas Wagner
2026-03-12 13:52 ` [PATCH proxmox 01/26] sys: procfs: don't read from sysfs during unit tests Lukas Wagner
2026-03-12 13:52 ` [PATCH proxmox 02/26] parallel-handler: import code from Proxmox Backup Server Lukas Wagner
2026-03-12 13:52 ` [PATCH proxmox 03/26] parallel-handler: introduce custom error type Lukas Wagner
2026-03-12 13:52 ` [PATCH proxmox 04/26] parallel-handler: add documentation Lukas Wagner
2026-03-12 13:52 ` [PATCH proxmox 05/26] parallel-handler: add simple unit-test suite Lukas Wagner
2026-03-12 13:52 ` [PATCH proxmox 06/26] disks: import from Proxmox Backup Server Lukas Wagner
2026-03-16 13:13   ` Arthur Bied-Charreton
2026-03-18 13:54     ` Lukas Wagner
2026-03-12 13:52 ` [PATCH proxmox 07/26] disks: fix typo in `initialize_gpt_disk` Lukas Wagner
2026-03-12 13:52 ` [PATCH proxmox 08/26] disks: add parts of gather_disk_stats from PBS Lukas Wagner
2026-03-12 13:52 ` [PATCH proxmox 09/26] disks: gate api macro behind 'api-types' feature Lukas Wagner
2026-03-12 13:52 ` [PATCH proxmox 10/26] disks: clippy: collapse if-let chains where possible Lukas Wagner
2026-03-12 13:52 ` [PATCH proxmox 11/26] procfs: add helpers for querying pressure stall information Lukas Wagner
2026-03-16 13:25   ` Arthur Bied-Charreton
2026-03-18 14:08     ` Lukas Wagner [this message]
2026-03-12 13:52 ` [PATCH proxmox 12/26] time: use u64 parse helper from nom Lukas Wagner
2026-03-12 13:52 ` [PATCH proxmox-backup 13/26] tools: move ParallelHandler to new proxmox-parallel-handler crate Lukas Wagner
2026-03-12 13:52 ` [PATCH proxmox-backup 14/26] tools: replace disks module with proxmox-disks Lukas Wagner
2026-03-16 13:27   ` Arthur Bied-Charreton
2026-03-18 14:08     ` Lukas Wagner
2026-03-12 13:52 ` [PATCH proxmox-backup 15/26] metric collection: use blockdev_stat_for_path from proxmox_disks Lukas Wagner
2026-03-12 13:52 ` [PATCH proxmox-yew-comp 16/26] node status panel: add `children` property Lukas Wagner
2026-03-12 13:52 ` [PATCH proxmox-yew-comp 17/26] RRDGrid: fix size observer by attaching node reference to rendered container Lukas Wagner
2026-03-12 13:52 ` [PATCH proxmox-yew-comp 18/26] RRDGrid: add padding and increase gap between elements Lukas Wagner
2026-03-12 13:52 ` [PATCH datacenter-manager 19/26] metric collection: clarify naming for remote metric collection Lukas Wagner
2026-03-12 13:52 ` [PATCH datacenter-manager 20/26] metric collection: fix minor typo in error message Lukas Wagner
2026-03-12 13:52 ` [PATCH datacenter-manager 21/26] metric collection: collect PDM host metrics in a new collection task Lukas Wagner
2026-03-12 13:52 ` [PATCH datacenter-manager 22/26] api: fix /nodes/localhost/rrddata endpoint Lukas Wagner
2026-03-12 13:52 ` [PATCH datacenter-manager 23/26] pdm: node rrd data: rename 'total-time' to 'metric-collection-total-time' Lukas Wagner
2026-03-12 13:52 ` [PATCH datacenter-manager 24/26] pdm-api-types: add PDM host metric fields Lukas Wagner
2026-03-12 13:52 ` [PATCH datacenter-manager 25/26] ui: node status: add RRD graphs for PDM host metrics Lukas Wagner
2026-03-12 13:52 ` [PATCH datacenter-manager 26/26] ui: lxc/qemu/node: use RRD value render helpers Lukas Wagner
2026-03-16 13:42 ` [PATCH datacenter-manager/proxmox{,-backup,-yew-comp} 00/26] metric collection for the PDM host Arthur Bied-Charreton
2026-03-18 14:09   ` Lukas Wagner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DH5YTOLJ7A2Z.2ILESDQV7HSRD@proxmox.com \
    --to=l.wagner@proxmox.com \
    --cc=a.bied-charreton@proxmox.com \
    --cc=pdm-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal