Skip to content

Commit 0f639e1

Browse files
committed
graph
1 parent 79347f5 commit 0f639e1

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/scheduler.rs

+1
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,7 @@ where
767767
self.spec_id
768768
);
769769
self.metrics.block_height = block_height;
770+
self.tx_dependencies.block_height = block_height;
770771
if with_hints {
771772
self.parse_hints();
772773
}

src/tx_dependency.rs

+23-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{
88
pub(crate) type DependentTxsVec = SmallVec<[TxId; 1]>;
99

1010
use ahash::{AHashMap as HashMap, AHashSet as HashSet};
11-
use metrics::{counter, histogram};
11+
use metrics::{counter, gauge, histogram};
1212

1313
const RAW_TRANSFER_WEIGHT: usize = 1;
1414

@@ -33,6 +33,7 @@ pub(crate) struct TxDependency {
3333
tx_weight: Option<Vec<usize>>,
3434

3535
pub round: Option<usize>,
36+
pub block_height: u64,
3637
}
3738

3839
impl TxDependency {
@@ -43,6 +44,7 @@ impl TxDependency {
4344
tx_running_time: None,
4445
tx_weight: None,
4546
round: None,
47+
block_height: 0,
4648
}
4749
}
4850

@@ -210,6 +212,25 @@ impl TxDependency {
210212
self.num_finality_txs = num_finality_txs;
211213
}
212214

215+
fn draw_dependent_graph(&self) {
216+
let num_finality_txs = self.num_finality_txs;
217+
for (index, dep) in self.tx_dependency.iter().enumerate() {
218+
let txid = index + num_finality_txs;
219+
let round = self.round.map(|r| format!("round{}", r)).unwrap_or(String::from("none"));
220+
gauge!("node_status",
221+
"id" => format!("tx{}", txid), "status" => "healthy",
222+
"round" => round.clone(), "block_height" => format!("{}", self.block_height))
223+
.set(1.0);
224+
let dep: BTreeSet<TxId> = dep.clone().into_iter().collect();
225+
for dep_id in dep {
226+
gauge!("edge_flow",
227+
"source" => format!("tx{}", txid), "target" => format!("tx{}", dep_id),
228+
"round" => round.clone(), "block_height" => format!("{}", self.block_height))
229+
.set(1.0);
230+
}
231+
}
232+
}
233+
213234
fn skew_analyze(&self, weighted_group: &BTreeMap<usize, Vec<DependentTxsVec>>) {
214235
if !(*DEBUG_BOTTLENECK) {
215236
return;
@@ -236,6 +257,7 @@ impl TxDependency {
236257
if num_txs < 64 || num_remaining < num_txs / 3 || subgraph.is_empty() {
237258
return;
238259
}
260+
self.draw_dependent_graph();
239261

240262
// ChainLength -> ChainNumber
241263
let mut chains = BTreeMap::new();

0 commit comments

Comments
 (0)