diff --git a/runtime/src/accounts_index.rs b/runtime/src/accounts_index.rs index 3f22845c37..25448c0a74 100644 --- a/runtime/src/accounts_index.rs +++ b/runtime/src/accounts_index.rs @@ -1382,7 +1382,9 @@ impl, ) -> (Vec, u64) { - let expected_items_per_bin = item_len * 2 / BINS; // big enough so not likely to re-allocate, small enough to not over-allocate + // big enough so not likely to re-allocate, small enough to not over-allocate by too much + // this assumes the largest bin contains twice the expected amount of the average size per bin + let expected_items_per_bin = item_len * 2 / BINS; let mut binned = (0..BINS) .into_iter() .map(|pubkey_bin| (pubkey_bin, Vec::with_capacity(expected_items_per_bin))) @@ -1401,9 +1403,12 @@ impl