Skip to content

Commit a364c08

Browse files
authored
Less verbose logging (#1756)
Simplifies a few logs from O(N) to O(1)
1 parent baa5d15 commit a364c08

File tree

3 files changed

+36
-11
lines changed

3 files changed

+36
-11
lines changed

upstairs/src/client.rs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Copyright 2023 Oxide Computer Company
22
use crate::{
3-
cdt, integrity_hash, io_limits::ClientIOLimits, live_repair::ExtentInfo,
4-
upstairs::UpstairsConfig, upstairs::UpstairsState, ClientIOStateCount,
5-
ClientId, ConnectionMode, CrucibleDecoder, CrucibleError, DownstairsIO,
6-
DsState, DsStateData, EncryptionContext, IOState, IOop, JobId, Message,
7-
RawReadResponse, ReconcileIO, ReconcileIOState, RegionDefinitionStatus,
8-
RegionMetadata,
3+
cdt, format_job_list, integrity_hash, io_limits::ClientIOLimits,
4+
live_repair::ExtentInfo, upstairs::UpstairsConfig, upstairs::UpstairsState,
5+
ClientIOStateCount, ClientId, ConnectionMode, CrucibleDecoder,
6+
CrucibleError, DownstairsIO, DsState, DsStateData, EncryptionContext,
7+
IOState, IOop, JobId, Message, RawReadResponse, ReconcileIO,
8+
ReconcileIOState, RegionDefinitionStatus, RegionMetadata,
99
};
1010
use crucible_common::{x509::TLSContext, NegotiationError, VerboseTimeout};
1111
use crucible_protocol::{
@@ -399,7 +399,8 @@ impl DownstairsClient {
399399
});
400400
info!(
401401
self.log,
402-
" {} final dependency list {:?}", ds_id, dependencies
402+
" {ds_id} final dependency list {}",
403+
format_job_list(dependencies),
403404
);
404405
}
405406
}
@@ -2277,8 +2278,22 @@ impl ClientIoTask {
22772278
"client task could not reply to main task; shutting down?"
22782279
);
22792280
}
2280-
while let Some(v) = self.request_rx.recv().await {
2281-
warn!(self.log, "exiting client task is ignoring message {v}");
2281+
if let Some(v) = self.request_rx.recv().await {
2282+
// Flush out the queue, waiting for the other side to close the
2283+
// channel before dropping it ourself.
2284+
let mut n = 0;
2285+
while self.request_rx.recv().await.is_some() {
2286+
n += 1;
2287+
}
2288+
warn!(
2289+
self.log,
2290+
"exiting client task is ignoring message {v}{}",
2291+
if n > 0 {
2292+
format!(" and {n} other messages")
2293+
} else {
2294+
"".to_owned()
2295+
}
2296+
);
22822297
}
22832298
info!(self.log, "client task is exiting");
22842299
}

upstairs/src/downstairs.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use crate::{
1313
ClientRunResult, ClientStopReason, DownstairsClient, EnqueueResult,
1414
NegotiationStateData, ShouldSendError,
1515
},
16+
format_job_list,
1617
guest::GuestBlockRes,
1718
io_limits::{IOLimitGuard, IOLimits},
1819
live_repair::ExtentInfo,
@@ -1459,13 +1460,13 @@ impl Downstairs {
14591460

14601461
info!(
14611462
self.log,
1462-
"RE:{} repair extent with ids {},{},{},{} deps:{:?}",
1463+
"RE:{} repair extent with ids {},{},{},{} deps:{}",
14631464
extent,
14641465
close_id,
14651466
repair_id,
14661467
noop_id,
14671468
reopen_id,
1468-
close_deps,
1469+
format_job_list(&close_deps),
14691470
);
14701471

14711472
let repair = self.repair.as_mut().unwrap(); // reborrow

upstairs/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,6 +1595,15 @@ pub struct DtraceInfo {
15951595
pub ds_ro_lr_skipped: [usize; 3],
15961596
}
15971597

1598+
pub(crate) fn format_job_list(ids: &[JobId]) -> String {
1599+
let n = ids.len();
1600+
if n < 4 {
1601+
format!("[{ids:?}]")
1602+
} else {
1603+
format!("[{:?}, ... {:?}] ({n} total)", ids[0], ids[n - 1],)
1604+
}
1605+
}
1606+
15981607
/*
15991608
* This is the main upstairs task that starts all the other async tasks.
16001609
*

0 commit comments

Comments
 (0)