Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Do not use binary_search, do simple compare in one loop
Browse files Browse the repository at this point in the history
  • Loading branch information
lijunwangs committed Jan 31, 2024
1 parent 3492fb5 commit 148feaf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion core/src/banking_stage/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,13 @@ impl Consumer {

// Now we track the performance for the interested transactions which is not in the retryable_transaction_indexes
// We assume the retryable_transaction_indexes is already sorted.
let mut retryable_idx = 0;
for (index, packet) in packets_to_process.iter().enumerate() {
if packet.original_packet().meta().is_perf_track_packet() {
if let Some(start_time) = packet.start_time() {
if retryable_transaction_indexes.binary_search(&index).is_err() {
if retryable_idx >= retryable_transaction_indexes.len()
|| retryable_transaction_indexes[retryable_idx] != index
{
let duration = Instant::now().duration_since(*start_time);

debug!(
Expand All @@ -222,6 +225,10 @@ impl Consumer {
"txn-metrics-banking-stage-process-us",
duration.as_micros() as usize
);
} else {
// This packet is retried, advance the retry index to the next, as the next packet's index will
// certainly be > than this.
retryable_idx += 1;
}
}
}
Expand Down

0 comments on commit 148feaf

Please sign in to comment.