seokjin0414 commented on code in PR #2917:
URL: https://github.com/apache/iggy/pull/2917#discussion_r2926429884


##########
core/server/src/shard/system/stats.rs:
##########
@@ -118,6 +120,20 @@ impl IggyShard {
                 }
             }
 
+            let data_path = std::path::Path::new(&self.config.system.path);
+            let data_path =
+                std::fs::canonicalize(data_path).unwrap_or_else(|_| 
data_path.to_path_buf());
+            let disks = sysinfo::Disks::new_with_refreshed_list();
+            let mut best_mount_len = 0usize;
+            for disk in disks.list() {
+                let mount = disk.mount_point();
+                if data_path.starts_with(mount) && mount.as_os_str().len() > 
best_mount_len {
+                    best_mount_len = mount.as_os_str().len();
+                    stats.free_disk_space = disk.available_space().into();
+                    stats.total_disk_space = disk.total_space().into();
+                }
+            }

Review Comment:
   Replaced sysinfo::Disks with fs2::available_space() / fs2::total_space() in 
a5f7f70b.
   fs2 uses a single statvfs syscall on the given path — it does not scan 
directory contents, so file count (10k++) has zero impact.
   Measured overhead is ~10μs regardless of directory size.
   fs2 is already a dependency of the server crate (used in logger.rs for the 
same purpose).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to