fix(obs): isolate process sampler windows (#4492)

* fix(obs): isolate process sampler windows

Refs rustfs/backlog#1004
Refs rustfs/backlog#986

- add a reusable ProcessSampler so callers can own independent sysinfo refresh windows
- wire separate sampler instances for obs metrics scheduling and memory observability
- keep compatibility helpers while avoiding cross-task CPU and disk delta interference

Co-Authored-By: heihutu <heihutu@gmail.com>

* fix(obs): import process sampler bundle helper

Refs rustfs/backlog#1004
Refs rustfs/backlog#986

- import collect_process_metric_bundle_with in the metrics scheduler
- drop the stale collect_process_metric_bundle import after switching scheduler sampling to independent process samplers

Co-Authored-By: heihutu <heihutu@gmail.com>

* fix(obs): move process sampler into blocking task

Refs rustfs/backlog#1004
Refs rustfs/backlog#986

- move the memory observability process sampler into the spawn_blocking closure
- satisfy the closure static lifetime required by tokio while keeping the isolated sampler design intact

Co-Authored-By: heihutu <heihutu@gmail.com>

---------

Co-authored-by: heihutu <heihutu@gmail.com>
This commit is contained in:
houseme
2026-07-08 23:51:34 +08:00
committed by GitHub
parent 6bdfdd164a
commit 6cb47049e8
7 changed files with 98 additions and 27 deletions
+12 -1
View File
@@ -372,12 +372,17 @@ impl FastObjectLockManager {
/// Start background cleanup task
fn start_cleanup_task(&self) {
let Ok(handle) = tokio::runtime::Handle::try_current() else {
tracing::debug!("Skipping fast lock cleanup task startup because no Tokio runtime is active");
return;
};
let shards = self.shards.clone();
let metrics = self.metrics.clone();
let cleanup_interval = self.config.cleanup_interval;
let _max_idle_time = self.config.max_idle_time;
let handle = tokio::spawn(async move {
let handle = handle.spawn(async move {
let mut interval = interval(cleanup_interval);
loop {
@@ -531,6 +536,12 @@ mod tests {
manager.shutdown().await;
}
#[test]
fn test_manager_construction_without_runtime_does_not_panic() {
let manager = FastObjectLockManager::new();
assert_eq!(manager.shards.len(), crate::fast_lock::DEFAULT_SHARD_COUNT);
}
#[tokio::test]
async fn test_list_locks_reports_held_locks() {
let manager = FastObjectLockManager::new();