Skip to content

Commit f28236c

Browse files
Preslav LeConvex, Inc.
authored andcommitted
Log how how often scheduler has to reassign workers (#24495)
Also have a gauge for the age of the reassigned worker. GitOrigin-RevId: 65e7f13df1da91ab70f07c261279e3ba16b6a761
1 parent 6dfaf36 commit f28236c

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

crates/isolate/src/client.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ use common::{
4343
runtime::{
4444
shutdown_and_join,
4545
Runtime,
46+
RuntimeInstant,
4647
SpawnHandle,
4748
UnixTimestamp,
4849
},
@@ -152,6 +153,7 @@ use crate::{
152153
is_developer_ok,
153154
log_pool_allocated_count,
154155
log_pool_running_count,
156+
log_worker_stolen,
155157
queue_timer,
156158
RequestStatus,
157159
},
@@ -1268,6 +1270,13 @@ impl<RT: Runtime, W: IsolateWorker<RT>> SharedIsolateScheduler<RT, W> {
12681270
// No available workers.
12691271
return None;
12701272
};
1273+
log_worker_stolen(
1274+
workers
1275+
.back()
1276+
.expect("Available worker map should never contain an empty list")
1277+
.last_used_ts
1278+
.elapsed(),
1279+
);
12711280
let worker_id = workers
12721281
.pop_back()
12731282
.expect("Available worker map should never contain an empty list");

crates/isolate/src/metrics.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::time::Duration;
2+
13
use common::{
24
types::UdfType,
35
version::Version,
@@ -109,6 +111,17 @@ pub fn service_request_timer(udf_type: &UdfType) -> StatusTimer {
109111
t
110112
}
111113

114+
register_convex_histogram!(
115+
ISOLATE_SCHEDULER_STOLEN_WORKER_AGE_SECONDS,
116+
"The now - last_used_ts in seconds for the stolen worker",
117+
);
118+
pub fn log_worker_stolen(age: Duration) {
119+
log_distribution(
120+
&ISOLATE_SCHEDULER_STOLEN_WORKER_AGE_SECONDS,
121+
age.as_secs_f64(),
122+
);
123+
}
124+
112125
register_convex_histogram!(UDF_QUEUE_SECONDS, "UDF queue time");
113126
pub fn queue_timer() -> Timer<VMHistogram> {
114127
Timer::new(&UDF_QUEUE_SECONDS)

0 commit comments

Comments
 (0)