Skip to content

Commit

Permalink
graph
Browse files Browse the repository at this point in the history
  • Loading branch information
AshinGau committed Dec 3, 2024
1 parent 79347f5 commit 0f639e1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,7 @@ where
self.spec_id
);
self.metrics.block_height = block_height;
self.tx_dependencies.block_height = block_height;
if with_hints {
self.parse_hints();
}
Expand Down
24 changes: 23 additions & 1 deletion src/tx_dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{
pub(crate) type DependentTxsVec = SmallVec<[TxId; 1]>;

use ahash::{AHashMap as HashMap, AHashSet as HashSet};
use metrics::{counter, histogram};
use metrics::{counter, gauge, histogram};

const RAW_TRANSFER_WEIGHT: usize = 1;

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

pub round: Option<usize>,
pub block_height: u64,
}

impl TxDependency {
Expand All @@ -43,6 +44,7 @@ impl TxDependency {
tx_running_time: None,
tx_weight: None,
round: None,
block_height: 0,
}
}

Expand Down Expand Up @@ -210,6 +212,25 @@ impl TxDependency {
self.num_finality_txs = num_finality_txs;
}

fn draw_dependent_graph(&self) {
let num_finality_txs = self.num_finality_txs;
for (index, dep) in self.tx_dependency.iter().enumerate() {
let txid = index + num_finality_txs;
let round = self.round.map(|r| format!("round{}", r)).unwrap_or(String::from("none"));
gauge!("node_status",
"id" => format!("tx{}", txid), "status" => "healthy",
"round" => round.clone(), "block_height" => format!("{}", self.block_height))
.set(1.0);
let dep: BTreeSet<TxId> = dep.clone().into_iter().collect();
for dep_id in dep {
gauge!("edge_flow",
"source" => format!("tx{}", txid), "target" => format!("tx{}", dep_id),
"round" => round.clone(), "block_height" => format!("{}", self.block_height))
.set(1.0);
}
}
}

fn skew_analyze(&self, weighted_group: &BTreeMap<usize, Vec<DependentTxsVec>>) {
if !(*DEBUG_BOTTLENECK) {
return;
Expand All @@ -236,6 +257,7 @@ impl TxDependency {
if num_txs < 64 || num_remaining < num_txs / 3 || subgraph.is_empty() {
return;
}
self.draw_dependent_graph();

// ChainLength -> ChainNumber
let mut chains = BTreeMap::new();
Expand Down

0 comments on commit 0f639e1

Please sign in to comment.