From a531474ee4982b769b428c7e4ee0d10c23b70def Mon Sep 17 00:00:00 2001 From: Neil Shen Date: Fri, 15 Dec 2023 22:24:06 +0800 Subject: [PATCH] *: upgrade array_zip See rust-lang/rust/pull/112096 Signed-off-by: Neil Shen --- components/resource_control/src/lib.rs | 1 - components/resource_control/src/resource_group.rs | 8 ++++---- components/resource_control/src/worker.rs | 15 +++++++++------ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/components/resource_control/src/lib.rs b/components/resource_control/src/lib.rs index 917718e8409..875b7af9046 100644 --- a/components/resource_control/src/lib.rs +++ b/components/resource_control/src/lib.rs @@ -1,7 +1,6 @@ // Copyright 2022 TiKV Project Authors. Licensed under Apache-2.0. #![feature(test)] #![feature(local_key_cell_methods)] -#![feature(array_zip)] use std::sync::Arc; diff --git a/components/resource_control/src/resource_group.rs b/components/resource_control/src/resource_group.rs index d6933d0a383..db1fba09028 100644 --- a/components/resource_control/src/resource_group.rs +++ b/components/resource_control/src/resource_group.rs @@ -342,8 +342,8 @@ impl ResourceGroupManager { #[inline] pub fn get_priority_resource_limiters( &self, - ) -> [Arc; TaskPriority::PRIORITY_COUNT] { - self.priority_limiters.clone() + ) -> &[Arc; TaskPriority::PRIORITY_COUNT] { + &self.priority_limiters } } @@ -606,8 +606,8 @@ impl ResourceController { }); if near_overflow { let end = Instant::now_coarse(); - info!("all resource groups' virtual time are near overflow, do reset"; - "min" => min_vt, "max" => max_vt, "dur" => ?end.duration_since(start), + info!("all resource groups' virtual time are near overflow, do reset"; + "min" => min_vt, "max" => max_vt, "dur" => ?end.duration_since(start), "reset_dur" => ?end.duration_since(self.last_rest_vt_time.get())); max_vt -= RESET_VT_THRESHOLD; self.last_rest_vt_time.set(end); diff --git a/components/resource_control/src/worker.rs b/components/resource_control/src/worker.rs index b90787914d6..244b2726a57 100644 --- a/components/resource_control/src/worker.rs +++ b/components/resource_control/src/worker.rs @@ -332,10 +332,13 @@ impl PriorityLimiterAdjustWorker { resource_ctl: Arc, resource_quota_getter: R, ) -> Self { - let trackers = resource_ctl - .get_priority_resource_limiters() - .zip(TaskPriority::priorities()) - .map(|(l, p)| PriorityLimiterStatsTracker::new(l, p.as_str())); + let limiters = resource_ctl.get_priority_resource_limiters(); + let priorities = TaskPriority::priorities(); + let trackers = [ + PriorityLimiterStatsTracker::new(limiters[0].clone(), priorities[0].as_str()), + PriorityLimiterStatsTracker::new(limiters[1].clone(), priorities[1].as_str()), + PriorityLimiterStatsTracker::new(limiters[2].clone(), priorities[2].as_str()), + ]; Self { resource_ctl, trackers, @@ -447,9 +450,9 @@ impl PriorityLimiterAdjustWorker { limits[i - 1] = limit; expect_cpu_time_total -= level_expected[i]; } - debug!("adjsut cpu limiter by priority"; "cpu_quota" => process_cpu_stats.total_quota, + debug!("adjsut cpu limiter by priority"; "cpu_quota" => process_cpu_stats.total_quota, "process_cpu" => process_cpu_stats.current_used, "expected_cpu" => ?level_expected, - "cpu_costs" => ?cpu_duration, "limits" => ?limits, + "cpu_costs" => ?cpu_duration, "limits" => ?limits, "limit_cpu_total" => expect_pool_cpu_total, "pool_cpu_cost" => real_cpu_total); } }