correctly calculate hash_total for hash/lamport calculation (#18144) (#18146)

(cherry picked from commit d5f9f3b7ce)

Co-authored-by: Jeff Washington (jwash) <75863576+jeffwashington@users.noreply.github.com>
This commit is contained in:
mergify[bot]
2021-06-22 21:21:10 +00:00
committed by GitHub
parent 597429ab3e
commit aca66674d3

View File

@ -520,6 +520,7 @@ impl AccountsHash {
let mut zeros = Measure::start("eliminate zeros"); let mut zeros = Measure::start("eliminate zeros");
let overall_sum = Mutex::new(0u64); let overall_sum = Mutex::new(0u64);
let unreduced_entries = AtomicUsize::new(0); let unreduced_entries = AtomicUsize::new(0);
let hash_total = AtomicUsize::new(0);
let hashes: Vec<Vec<Hash>> = (0..max_bin) let hashes: Vec<Vec<Hash>> = (0..max_bin)
.into_par_iter() .into_par_iter()
.map(|bin| { .map(|bin| {
@ -531,6 +532,7 @@ impl AccountsHash {
Self::checked_cast_for_capitalization(sum as u128 + *overall as u128); Self::checked_cast_for_capitalization(sum as u128 + *overall as u128);
} }
unreduced_entries.fetch_add(unreduced_entries_count, Ordering::Relaxed); unreduced_entries.fetch_add(unreduced_entries_count, Ordering::Relaxed);
hash_total.fetch_add(hashes.len(), Ordering::Relaxed);
hashes hashes
}) })
.collect(); .collect();
@ -538,6 +540,7 @@ impl AccountsHash {
stats.zeros_time_total_us += zeros.as_us(); stats.zeros_time_total_us += zeros.as_us();
let sum = *overall_sum.lock().unwrap(); let sum = *overall_sum.lock().unwrap();
stats.unreduced_entries += unreduced_entries.load(Ordering::Relaxed); stats.unreduced_entries += unreduced_entries.load(Ordering::Relaxed);
stats.hash_total += hash_total.load(Ordering::Relaxed);
(hashes, sum) (hashes, sum)
} }
@ -688,7 +691,6 @@ impl AccountsHash {
let mut next_pass = PreviousPass::default(); let mut next_pass = PreviousPass::default();
let cumulative = CumulativeOffsets::from_raw(&hashes); let cumulative = CumulativeOffsets::from_raw(&hashes);
let mut hash_total = cumulative.total_count; let mut hash_total = cumulative.total_count;
stats.hash_total += hash_total;
next_pass.reduced_hashes = previous_state.reduced_hashes; next_pass.reduced_hashes = previous_state.reduced_hashes;
const TARGET_FANOUT_LEVEL: usize = 3; const TARGET_FANOUT_LEVEL: usize = 3;