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

Commit

Permalink
correctly calculate hash_total for hash/lamport calculation (#18144) (#…
Browse files Browse the repository at this point in the history
…18146)

(cherry picked from commit d5f9f3b)

Co-authored-by: Jeff Washington (jwash) <75863576+jeffwashington@users.noreply.github.com>
  • Loading branch information
mergify[bot] and jeffwashington authored Jun 22, 2021
1 parent 597429a commit aca6667
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion runtime/src/accounts_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ impl AccountsHash {
let mut zeros = Measure::start("eliminate zeros");
let overall_sum = Mutex::new(0u64);
let unreduced_entries = AtomicUsize::new(0);
let hash_total = AtomicUsize::new(0);
let hashes: Vec<Vec<Hash>> = (0..max_bin)
.into_par_iter()
.map(|bin| {
Expand All @@ -531,13 +532,15 @@ impl AccountsHash {
Self::checked_cast_for_capitalization(sum as u128 + *overall as u128);
}
unreduced_entries.fetch_add(unreduced_entries_count, Ordering::Relaxed);
hash_total.fetch_add(hashes.len(), Ordering::Relaxed);
hashes
})
.collect();
zeros.stop();
stats.zeros_time_total_us += zeros.as_us();
let sum = *overall_sum.lock().unwrap();
stats.unreduced_entries += unreduced_entries.load(Ordering::Relaxed);
stats.hash_total += hash_total.load(Ordering::Relaxed);
(hashes, sum)
}

Expand Down Expand Up @@ -688,7 +691,6 @@ impl AccountsHash {
let mut next_pass = PreviousPass::default();
let cumulative = CumulativeOffsets::from_raw(&hashes);
let mut hash_total = cumulative.total_count;
stats.hash_total += hash_total;
next_pass.reduced_hashes = previous_state.reduced_hashes;

const TARGET_FANOUT_LEVEL: usize = 3;
Expand Down

0 comments on commit aca6667

Please sign in to comment.