Skip to content

Commit

Permalink
Aggregate cost_model into cost_tracker (solana-labs#18374)
Browse files Browse the repository at this point in the history
* * aggregate cost_model into cost_tracker, decouple it from banking_stage to prevent accidental deadlock. * Simplified code, removed unused functions

* review fixes
  • Loading branch information
tao-stones committed Sep 29, 2021
1 parent 6b3f118 commit 3c0bed7
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 303 deletions.
6 changes: 4 additions & 2 deletions banking-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crossbeam_channel::unbounded;
use log::*;
use rand::{thread_rng, Rng};
use rayon::prelude::*;
use solana_core::{banking_stage::BankingStage, cost_model::CostModel};
use solana_core::{banking_stage::BankingStage, cost_model::CostModel, cost_tracker::CostTracker};
use solana_gossip::{cluster_info::ClusterInfo, cluster_info::Node};
use solana_ledger::{
blockstore::Blockstore,
Expand Down Expand Up @@ -231,7 +231,9 @@ fn main() {
vote_receiver,
None,
replay_vote_sender,
&Arc::new(RwLock::new(CostModel::default())),
Arc::new(RwLock::new(CostTracker::new(Arc::new(RwLock::new(
CostModel::default(),
))))),
);
poh_recorder.lock().unwrap().set_bank(&bank);

Expand Down
11 changes: 7 additions & 4 deletions core/benches/banking_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ fn bench_consume_buffered(bencher: &mut Bencher) {
None::<Box<dyn Fn()>>,
&BankingStageStats::default(),
&recorder,
&Arc::new(RwLock::new(CostModel::default())),
&Arc::new(RwLock::new(CostTracker::new(std::u64::MAX, std::u64::MAX))),
&Arc::new(RwLock::new(CostTracker::new(Arc::new(RwLock::new(
CostModel::new(std::u64::MAX, std::u64::MAX),
))))),
);
});

Expand Down Expand Up @@ -215,15 +216,17 @@ fn bench_banking(bencher: &mut Bencher, tx_type: TransactionType) {
);
let cluster_info = Arc::new(cluster_info);
let (s, _r) = unbounded();
let _banking_stage = BankingStage::new_with_cost_limit(
let _banking_stage = BankingStage::new(
&cluster_info,
&poh_recorder,
verified_receiver,
tpu_vote_receiver,
vote_receiver,
None,
s,
&Arc::new(RwLock::new(CostModel::new(std::u64::MAX, std::u64::MAX))),
Arc::new(RwLock::new(CostTracker::new(Arc::new(RwLock::new(
CostModel::new(std::u64::MAX, std::u64::MAX),
))))),
);
poh_recorder.lock().unwrap().set_bank(&bank);

Expand Down
Loading

0 comments on commit 3c0bed7

Please sign in to comment.