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

Add group name in task metrics #10196

Merged
merged 18 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions bin/node-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub fn new_partial(
let client = Arc::new(client);

let telemetry = telemetry.map(|(worker, telemetry)| {
task_manager.spawn_handle().spawn("telemetry", worker.run());
task_manager.spawn_handle().spawn("telemetry", "", worker.run());
telemetry
});

Expand Down Expand Up @@ -289,7 +289,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>

// the AURA authoring task is considered essential, i.e. if it
// fails we take down the service with it.
task_manager.spawn_essential_handle().spawn_blocking("aura", aura);
task_manager.spawn_essential_handle().spawn_blocking("aura", "", aura);
sandreim marked this conversation as resolved.
Show resolved Hide resolved
}

// if the node isn't actively participating in consensus then it doesn't
Expand Down Expand Up @@ -329,6 +329,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
// if it fails we take down the service with it.
task_manager.spawn_essential_handle().spawn_blocking(
"grandpa-voter",
"",
sc_finality_grandpa::run_grandpa_voter(grandpa_config)?,
);
}
Expand Down
20 changes: 12 additions & 8 deletions bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ pub fn new_partial(
let client = Arc::new(client);

let telemetry = telemetry.map(|(worker, telemetry)| {
task_manager.spawn_handle().spawn("telemetry", worker.run());
task_manager.spawn_handle().spawn("telemetry", "", worker.run());
telemetry
});

Expand Down Expand Up @@ -434,7 +434,7 @@ pub fn new_full_base(
};

let babe = sc_consensus_babe::start_babe(babe_config)?;
task_manager.spawn_essential_handle().spawn_blocking("babe-proposer", babe);
task_manager.spawn_essential_handle().spawn_blocking("babe-proposer", "", babe);
sandreim marked this conversation as resolved.
Show resolved Hide resolved
}

// Spawn authority discovery module.
Expand All @@ -461,9 +461,11 @@ pub fn new_full_base(
prometheus_registry.clone(),
);

task_manager
.spawn_handle()
.spawn("authority-discovery-worker", authority_discovery_worker.run());
task_manager.spawn_handle().spawn(
"authority-discovery-worker",
"",
sandreim marked this conversation as resolved.
Show resolved Hide resolved
authority_discovery_worker.run(),
);
}

// if the node isn't actively participating in consensus then it doesn't
Expand Down Expand Up @@ -501,9 +503,11 @@ pub fn new_full_base(

// the GRANDPA voter task is considered infallible, i.e.
// if it fails we take down the service with it.
task_manager
.spawn_essential_handle()
.spawn_blocking("grandpa-voter", grandpa::run_grandpa_voter(grandpa_config)?);
task_manager.spawn_essential_handle().spawn_blocking(
"grandpa-voter",
"",
grandpa::run_grandpa_voter(grandpa_config)?,
);
}

network_starter.start_network();
Expand Down
14 changes: 12 additions & 2 deletions bin/node/testing/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,21 @@ impl TaskExecutor {
}

impl SpawnNamed for TaskExecutor {
fn spawn(&self, _: &'static str, future: futures::future::BoxFuture<'static, ()>) {
fn spawn(
&self,
_: &'static str,
_: &'static str,
future: futures::future::BoxFuture<'static, ()>,
) {
self.pool.spawn_ok(future);
}

fn spawn_blocking(&self, _: &'static str, future: futures::future::BoxFuture<'static, ()>) {
fn spawn_blocking(
&self,
_: &'static str,
_: &'static str,
future: futures::future::BoxFuture<'static, ()>,
) {
self.pool.spawn_ok(future);
}
}
Expand Down
1 change: 1 addition & 0 deletions client/basic-authorship/src/basic_authorship.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ where

spawn_handle.spawn_blocking(
"basic-authorship-proposer",
"",
Box::pin(async move {
// leave some time for evaluation and block finalization (33%)
let deadline = (self.now)() + max_duration - max_duration / 3;
Expand Down
4 changes: 2 additions & 2 deletions client/consensus/babe/src/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ where
);

check_secondary_plain_header::<B>(pre_hash, secondary, sig, &epoch)?;
}
},
PreDigest::SecondaryVRF(secondary)
if epoch.config.allowed_slots.is_secondary_vrf_slots_allowed() =>
{
Expand All @@ -125,7 +125,7 @@ where
);

check_secondary_vrf_header::<B>(pre_hash, secondary, sig, &epoch)?;
}
},
_ => return Err(babe_err(Error::SecondarySlotAssignmentsDisabled)),
}

Expand Down
2 changes: 1 addition & 1 deletion client/consensus/common/src/import_queue/basic_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl<B: BlockT, Transaction: Send + 'static> BasicQueue<B, Transaction> {
metrics,
);

spawner.spawn_essential_blocking("basic-block-import-worker", future.boxed());
spawner.spawn_essential_blocking("basic-block-import-worker", "", future.boxed());
sandreim marked this conversation as resolved.
Show resolved Hide resolved

Self { justification_sender, block_import_sender, result_port, _phantom: PhantomData }
}
Expand Down
1 change: 1 addition & 0 deletions client/executor/src/native_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ impl RuntimeSpawn for RuntimeInstanceSpawn {
let scheduler = self.scheduler.clone();
self.scheduler.spawn(
"executor-extra-runtime-instance",
"",
Box::pin(async move {
let module = AssertUnwindSafe(module);

Expand Down
1 change: 1 addition & 0 deletions client/offchain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ pub async fn notification_future<Client, Block, Spawner>(
if n.is_new_best {
spawner.spawn(
"offchain-on-block",
"",
sandreim marked this conversation as resolved.
Show resolved Hide resolved
offchain
.on_block_imported(&n.header, network_provider.clone(), is_validator)
.boxed(),
Expand Down
2 changes: 1 addition & 1 deletion client/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl SubscriptionTaskExecutor {

impl Spawn for SubscriptionTaskExecutor {
fn spawn_obj(&self, future: FutureObj<'static, ()>) -> Result<(), SpawnError> {
self.0.spawn("substrate-rpc-subscription", future.map(drop).boxed());
self.0.spawn("substrate-rpc-subscription", "", future.map(drop).boxed());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.0.spawn("substrate-rpc-subscription", "", future.map(drop).boxed());
self.0.spawn("substrate-rpc-subscription", "rpc", future.map(drop).boxed());

Ok(())
}

Expand Down
20 changes: 13 additions & 7 deletions client/service/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ where
if let Some(offchain) = offchain_workers.clone() {
spawn_handle.spawn(
"offchain-notifications",
"",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"",
"offchain-worker",

sc_offchain::notification_future(
config.role.is_authority(),
client.clone(),
Expand Down Expand Up @@ -505,11 +506,13 @@ where
// Inform the tx pool about imported and finalized blocks.
spawn_handle.spawn(
"txpool-notifications",
"",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"",
"transaction-pool",

sc_transaction_pool::notification_future(client.clone(), transaction_pool.clone()),
);

spawn_handle.spawn(
"on-transaction-imported",
"",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"",
"transaction-pool",

transaction_notifications(transaction_pool.clone(), network.clone(), telemetry.clone()),
);

Expand All @@ -520,6 +523,7 @@ where
let metrics = MetricsService::with_prometheus(telemetry.clone(), &registry, &config)?;
spawn_handle.spawn(
"prometheus-endpoint",
"",
prometheus_endpoint::init_prometheus(port, registry).map(drop),
);

Expand All @@ -531,6 +535,7 @@ where
// Periodically updated metrics and telemetry updates.
spawn_handle.spawn(
"telemetry-periodic-send",
"",
metrics_service.run(client.clone(), transaction_pool.clone(), network.clone()),
);

Expand Down Expand Up @@ -567,6 +572,7 @@ where
// Spawn informant task
spawn_handle.spawn(
"informant",
"",
sc_informant::build(
client.clone(),
network.clone(),
Expand Down Expand Up @@ -798,7 +804,7 @@ where
config.network.default_peers_set.in_peers as usize +
config.network.default_peers_set.out_peers as usize,
);
spawn_handle.spawn("block_request_handler", handler.run());
spawn_handle.spawn("block_request_handler", "", handler.run());
sandreim marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
spawn_handle.spawn("block_request_handler", "", handler.run());
spawn_handle.spawn("block-request-handler", "networking", handler.run());

protocol_config
}
};
Expand All @@ -815,7 +821,7 @@ where
config.network.default_peers_set.in_peers as usize +
config.network.default_peers_set.out_peers as usize,
);
spawn_handle.spawn("state_request_handler", handler.run());
spawn_handle.spawn("state_request_handler", "", handler.run());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
spawn_handle.spawn("state_request_handler", "", handler.run());
spawn_handle.spawn("state-request-handler", "networking", handler.run());

protocol_config
}
};
Expand All @@ -828,7 +834,7 @@ where
// Allow both outgoing and incoming requests.
let (handler, protocol_config) =
WarpSyncRequestHandler::new(protocol_id.clone(), provider.clone());
spawn_handle.spawn("warp_sync_request_handler", handler.run());
spawn_handle.spawn("warp_sync_request_handler", "", handler.run());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
spawn_handle.spawn("warp_sync_request_handler", "", handler.run());
spawn_handle.spawn("warp-sync-request-handler", "networking", handler.run());

protocol_config
};
(provider, protocol_config)
Expand All @@ -842,7 +848,7 @@ where
// Allow both outgoing and incoming requests.
let (handler, protocol_config) =
LightClientRequestHandler::new(&protocol_id, client.clone());
spawn_handle.spawn("light_client_request_handler", handler.run());
spawn_handle.spawn("light_client_request_handler", "", handler.run());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
spawn_handle.spawn("light_client_request_handler", "", handler.run());
spawn_handle.spawn("light-client-request-handler", "networking", handler.run());

protocol_config
}
};
Expand All @@ -852,13 +858,13 @@ where
executor: {
let spawn_handle = Clone::clone(&spawn_handle);
Some(Box::new(move |fut| {
spawn_handle.spawn("libp2p-node", fut);
spawn_handle.spawn("libp2p-node", "", fut);
sandreim marked this conversation as resolved.
Show resolved Hide resolved
}))
},
transactions_handler_executor: {
let spawn_handle = Clone::clone(&spawn_handle);
Box::new(move |fut| {
spawn_handle.spawn("network-transactions-handler", fut);
spawn_handle.spawn("network-transactions-handler", "", fut);
sandreim marked this conversation as resolved.
Show resolved Hide resolved
})
},
network_config: config.network.clone(),
Expand Down Expand Up @@ -920,7 +926,7 @@ where
// issue, and ideally we would like to fix the network future to take as little time as
// possible, but we also take the extra harm-prevention measure to execute the networking
// future using `spawn_blocking`.
spawn_handle.spawn_blocking("network-worker", async move {
spawn_handle.spawn_blocking("network-worker", "", async move {
sandreim marked this conversation as resolved.
Show resolved Hide resolved
if network_start_rx.await.is_err() {
log::warn!(
"The NetworkStart returned as part of `build_network` has been silently dropped"
Expand Down
Loading