Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing prioritization heap metrics #370

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions bench/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ fn transaction_size_small() {
let rand_string = random_strings.first().unwrap();
let tx = BenchHelper::create_memo_tx_small(rand_string, &payer_keypair, blockhash);

assert_eq!(bincode::serialized_size(&tx).unwrap(), 179);
assert_eq!(bincode::serialized_size(&tx).unwrap(), 231);
}

#[test]
Expand All @@ -172,5 +172,5 @@ fn transaction_size_large() {
let rand_string = random_strings.first().unwrap();
let tx = BenchHelper::create_memo_tx_large(rand_string, &payer_keypair, blockhash);

assert_eq!(bincode::serialized_size(&tx).unwrap(), 1186);
assert_eq!(bincode::serialized_size(&tx).unwrap(), 1230);
}
4 changes: 3 additions & 1 deletion core/src/structures/prioritization_fee_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl PrioritizationFeesHeap {
}
}

pub async fn remove_expired_transactions(&self, current_blockheight: u64) {
pub async fn remove_expired_transactions(&self, current_blockheight: u64) -> usize {
let mut write_lock = self.map.lock().await;
let mut cells_to_remove = vec![];
let mut signatures_to_remove = vec![];
Expand All @@ -102,9 +102,11 @@ impl PrioritizationFeesHeap {
for p in cells_to_remove {
write_lock.map.remove(&p);
}
let signatures_len = signatures_to_remove.len();
for sig in signatures_to_remove {
write_lock.signatures.remove(&sig);
}
signatures_len
}

pub async fn size(&self) -> usize {
Expand Down
9 changes: 5 additions & 4 deletions services/src/tpu_utils/tpu_connection_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,10 @@ impl ActiveConnection {
// give more priority to transaction sender
tokio::time::sleep(Duration::from_micros(50)).await;
// remove all expired transactions from the queue
priorization_heap
let elements_removed = priorization_heap
.remove_expired_transactions(current_blockheight)
.await;
TRANSACTIONS_IN_HEAP.sub(elements_removed as i64);
}
}
Err(e) => {
Expand All @@ -168,7 +169,7 @@ impl ActiveConnection {
let _permit = permit;
connection.get_connection().await;
});
}
};

'main_loop: loop {
// exit signal set
Expand All @@ -179,15 +180,15 @@ impl ActiveConnection {
tokio::select! {
_ = fill_notify.notified() => {

loop {
'process_heap: loop {
// exit signal set
if exit_signal.load(Ordering::Relaxed) {
break 'main_loop;
}

let Some(tx) = priorization_heap.pop().await else {
// wait to get notification from fill event
break;
break 'process_heap;
};
TRANSACTIONS_IN_HEAP.dec();

Expand Down
Loading