Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 9e8b26f

Browse files
sandreimordian
andauthored
Per subsystem CPU usage tracking (#4239)
* SubsystemContext: add subsystem name str Signed-off-by: Andrei Sandu <[email protected]> * Overseer builder proc macro changes * initilize SubsystemContext name field. * Add subsystem name in TaskKind::launch_task() Signed-off-by: Andrei Sandu <[email protected]> * Update ToOverseer enum Signed-off-by: Andrei Sandu <[email protected]> * Assign subsystem names to orphan tasks Signed-off-by: Andrei Sandu <[email protected]> * cargo fmt Signed-off-by: Andrei Sandu <[email protected]> * SubsystemContext: add subsystem name str Signed-off-by: Andrei Sandu <[email protected]> * Overseer builder proc macro changes * initilize SubsystemContext name field. * Add subsystem name in TaskKind::launch_task() Signed-off-by: Andrei Sandu <[email protected]> * Update ToOverseer enum Signed-off-by: Andrei Sandu <[email protected]> * Assign subsystem names to orphan tasks Signed-off-by: Andrei Sandu <[email protected]> * cargo fmt Signed-off-by: Andrei Sandu <[email protected]> * Rebase changes for new spawn() group param Signed-off-by: Andrei Sandu <[email protected]> * Add subsystem constat in JobTrait Signed-off-by: Andrei Sandu <[email protected]> * Add subsystem string Signed-off-by: Andrei Sandu <[email protected]> * Fix tests Signed-off-by: Andrei Sandu <[email protected]> * Fix spawn() calls Signed-off-by: Andrei Sandu <[email protected]> * cargo fmt Signed-off-by: Andrei Sandu <[email protected]> * Fix Signed-off-by: Andrei Sandu <[email protected]> * Fix tests Signed-off-by: Andrei Sandu <[email protected]> * fix Signed-off-by: Andrei Sandu <[email protected]> * Fix more tests Signed-off-by: Andrei Sandu <[email protected]> * Address PR review feedback #1 Signed-off-by: Andrei Sandu <[email protected]> * Address PR review round 2 Signed-off-by: Andrei Sandu <[email protected]> * Fixes - remove JobTrait::Subsystem - fix tests Signed-off-by: Andrei Sandu <[email protected]> * update Cargo.lock Co-authored-by: Andronik Ordian <[email protected]>
1 parent 83e5955 commit 9e8b26f

File tree

22 files changed

+340
-260
lines changed

22 files changed

+340
-260
lines changed

Cargo.lock

Lines changed: 197 additions & 204 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node/collation-generation/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ async fn handle_new_activations<Context: SubsystemContext>(
291291
let mut task_sender = sender.clone();
292292
let metrics = metrics.clone();
293293
ctx.spawn(
294-
"collation generation collation builder",
294+
"collation-builder",
295295
Box::pin(async move {
296296
let persisted_validation_data_hash = validation_data.hash();
297297

node/core/av-store/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,9 @@ impl Error {
383383
fn trace(&self) {
384384
match self {
385385
// don't spam the log with spurious errors
386-
Self::RuntimeApi(_) | Self::Oneshot(_) =>
387-
tracing::debug!(target: LOG_TARGET, err = ?self),
386+
Self::RuntimeApi(_) | Self::Oneshot(_) => {
387+
tracing::debug!(target: LOG_TARGET, err = ?self)
388+
},
388389
// it's worth reporting otherwise
389390
_ => tracing::warn!(target: LOG_TARGET, err = ?self),
390391
}

node/core/backing/src/lib.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ impl CandidateBackingJob {
659659
}
660660
};
661661
sender
662-
.send_command(FromJobCommand::Spawn("Backing Validation", bg.boxed()))
662+
.send_command(FromJobCommand::Spawn("backing-validation", bg.boxed()))
663663
.await?;
664664
}
665665

@@ -900,11 +900,13 @@ impl CandidateBackingJob {
900900
.await;
901901

902902
match confirmation_rx.await {
903-
Err(oneshot::Canceled) =>
904-
tracing::debug!(target: LOG_TARGET, "Dispute coordinator confirmation lost",),
903+
Err(oneshot::Canceled) => {
904+
tracing::debug!(target: LOG_TARGET, "Dispute coordinator confirmation lost",)
905+
},
905906
Ok(ImportStatementsResult::ValidImport) => {},
906-
Ok(ImportStatementsResult::InvalidImport) =>
907-
tracing::warn!(target: LOG_TARGET, "Failed to import statements of validity",),
907+
Ok(ImportStatementsResult::InvalidImport) => {
908+
tracing::warn!(target: LOG_TARGET, "Failed to import statements of validity",)
909+
},
908910
}
909911
}
910912

@@ -1168,7 +1170,7 @@ impl util::JobTrait for CandidateBackingJob {
11681170
type RunArgs = SyncCryptoStorePtr;
11691171
type Metrics = Metrics;
11701172

1171-
const NAME: &'static str = "CandidateBackingJob";
1173+
const NAME: &'static str = "candidate-backing-job";
11721174

11731175
fn run<S: SubsystemSender>(
11741176
parent: Hash,

node/core/bitfield-signing/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ impl JobTrait for BitfieldSigningJob {
233233
type RunArgs = SyncCryptoStorePtr;
234234
type Metrics = Metrics;
235235

236-
const NAME: &'static str = "BitfieldSigningJob";
236+
const NAME: &'static str = "bitfield-signing-job";
237237

238238
/// Run a job for the parent block indicated
239239
fn run<S: SubsystemSender>(

node/core/provisioner/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl JobTrait for ProvisioningJob {
148148
type RunArgs = ();
149149
type Metrics = Metrics;
150150

151-
const NAME: &'static str = "ProvisioningJob";
151+
const NAME: &'static str = "provisioner-job";
152152

153153
/// Run a job for the parent block indicated
154154
//

node/core/pvf/src/executor_intf.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,21 @@ impl TaskExecutor {
278278
}
279279

280280
impl sp_core::traits::SpawnNamed for TaskExecutor {
281-
fn spawn_blocking(&self, _: &'static str, future: futures::future::BoxFuture<'static, ()>) {
281+
fn spawn_blocking(
282+
&self,
283+
_task_name: &'static str,
284+
_subsystem_name: Option<&'static str>,
285+
future: futures::future::BoxFuture<'static, ()>,
286+
) {
282287
self.0.spawn_ok(future);
283288
}
284289

285-
fn spawn(&self, _: &'static str, future: futures::future::BoxFuture<'static, ()>) {
290+
fn spawn(
291+
&self,
292+
_task_name: &'static str,
293+
_subsystem_name: Option<&'static str>,
294+
future: futures::future::BoxFuture<'static, ()>,
295+
) {
286296
self.0.spawn_ok(future);
287297
}
288298
}

node/core/runtime-api/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ where
270270
)
271271
}
272272
} else {
273-
self.spawn_handle.spawn_blocking(API_REQUEST_TASK_NAME, request);
273+
self.spawn_handle
274+
.spawn_blocking(API_REQUEST_TASK_NAME, Some("runtime-api"), request);
274275
self.active_requests.push(receiver);
275276
}
276277
}
@@ -288,7 +289,8 @@ where
288289
}
289290

290291
if let Some((req, recv)) = self.waiting_requests.pop_front() {
291-
self.spawn_handle.spawn_blocking(API_REQUEST_TASK_NAME, req);
292+
self.spawn_handle
293+
.spawn_blocking(API_REQUEST_TASK_NAME, Some("runtime-api"), req);
292294
self.active_requests.push(recv);
293295
}
294296
}

node/jaeger/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ impl Jaeger {
112112
// Spawn a background task that pulls span information and sends them on the network.
113113
spawner.spawn(
114114
"jaeger-collector",
115+
Some("jaeger"),
115116
Box::pin(async move {
116117
match async_std::net::UdpSocket::bind("0.0.0.0:0").await {
117118
Ok(udp_socket) => loop {

node/network/availability-distribution/src/tests/state.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ impl TestState {
197197
// lock ;-)
198198
let update_tx = tx.clone();
199199
harness.pool.spawn(
200-
"Sending active leaves updates",
200+
"sending-active-leaves-updates",
201+
None,
201202
async move {
202203
for update in updates {
203204
overseer_signal(update_tx.clone(), OverseerSignal::ActiveLeaves(update)).await;
@@ -308,7 +309,8 @@ fn to_incoming_req(
308309
let (tx, rx): (oneshot::Sender<netconfig::OutgoingResponse>, oneshot::Receiver<_>) =
309310
oneshot::channel();
310311
executor.spawn(
311-
"Message forwarding",
312+
"message-forwarding",
313+
None,
312314
async {
313315
let response = rx.await;
314316
let payload = response.expect("Unexpected canceled request").result;

0 commit comments

Comments
 (0)