From: Gabriel Goller <g.goller@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 2/2] api: parallelize smartctl checks
Date: Mon, 16 Sep 2024 16:56:27 +0200 [thread overview]
Message-ID: <20240916145627.515861-2-g.goller@proxmox.com> (raw)
In-Reply-To: <20240916145627.515861-1-g.goller@proxmox.com>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=y, Size: 3259 bytes --]
To improve the performance of the smartctl checks, especially when a lot
of disks are used, parallelize the checks using the `ParallelHandler`.
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
Benchmark:
Benchmark 1: proxmox-backup-manager disk list (parallel)
Time (mean ± σ): 75.8 ms ± 5.7 ms [User: 0.8 ms, System: 0.5 ms]
Range (min … max): 63.4 ms … 95.3 ms 100 runs
Benchmark 2: proxmox-backup-manager disk list (sequential)
Time (mean ± σ): 189.4 ms ± 6.7 ms [User: 0.7 ms, System: 1.0 ms]
Range (min … max): 178.8 ms … 223.0 ms 100 runs
Summary
'proxmox-backup-manager disk list (parallel)' ran
2.50 ± 0.21 times faster than 'proxmox-backup-manager disk list (sequential)'
src/tools/disks/mod.rs | 42 +++++++++++++++++++++++++++++-------------
1 file changed, 29 insertions(+), 13 deletions(-)
diff --git a/src/tools/disks/mod.rs b/src/tools/disks/mod.rs
index 04f62b818238..09a3003a9333 100644
--- a/src/tools/disks/mod.rs
+++ b/src/tools/disks/mod.rs
@@ -15,13 +15,15 @@ use once_cell::sync::OnceCell;
use ::serde::{Deserialize, Serialize};
use proxmox_lang::{io_bail, io_format_err};
+use proxmox_log::info;
use proxmox_schema::api;
use proxmox_sys::linux::procfs::{mountinfo::Device, MountInfo};
use pbs_api_types::{BLOCKDEVICE_DISK_AND_PARTITION_NAME_REGEX, BLOCKDEVICE_NAME_REGEX};
+use crate::tools::parallel_handler::ParallelHandler;
+
mod zfs;
-use tracing::info;
pub use zfs::*;
mod zpool_status;
pub use zpool_status::*;
@@ -1047,16 +1049,6 @@ fn get_disks(
usage = DiskUsageType::DeviceMapper;
}
- let mut status = SmartStatus::Unknown;
- let mut wearout = None;
-
- if !no_smart {
- if let Ok(smart) = get_smart_data(&disk, false) {
- status = smart.status;
- wearout = smart.wearout;
- }
- }
-
let info = DiskUsageInfo {
name: name.clone(),
vendor,
@@ -1067,8 +1059,8 @@ fn get_disks(
size,
wwn,
disk_type,
- status,
- wearout,
+ status: SmartStatus::Unknown,
+ wearout: None,
used: usage,
gpt: disk.has_gpt(),
rpm: disk.ata_rotation_rate_rpm(),
@@ -1077,6 +1069,30 @@ fn get_disks(
result.insert(name, info);
}
+ if !no_smart {
+ let (tx, rx) = crossbeam_channel::bounded(result.len());
+
+ let parallel_handler =
+ ParallelHandler::new("smartctl data", 4, move |device: (String, String)| {
+ let smart_data = get_smart_data(Path::new(&device.1), false)?;
+ tx.send((device.0, smart_data))?;
+ Ok(())
+ });
+
+ for (name, path) in device_paths.into_iter() {
+ if let Some(p) = path {
+ parallel_handler.send((name, p))?;
+ }
+ }
+
+ parallel_handler.complete()?;
+ while let Ok(msg) = rx.recv() {
+ if let Some(value) = result.get_mut(&msg.0) {
+ value.wearout = msg.1.wearout;
+ value.status = msg.1.status;
+ }
+ }
+ }
Ok(result)
}
--
2.39.5
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
next prev parent reply other threads:[~2024-09-16 14:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-16 14:56 [pbs-devel] [PATCH proxmox-backup 1/2] api: avoid retrieving lsblk result twice Gabriel Goller
2024-09-16 14:56 ` Gabriel Goller [this message]
2024-09-17 8:03 ` [pbs-devel] [PATCH proxmox-backup 2/2] api: parallelize smartctl checks Gabriel Goller
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=20240916145627.515861-2-g.goller@proxmox.com \
--to=g.goller@proxmox.com \
--cc=pbs-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.