From e9c3e0b0eee52e4849dcf3d22092e13e44e7829a Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 20 May 2021 04:37:10 +0000 Subject: [PATCH] datapoint for verify_snapshot_bank (#17306) (#17339) (cherry picked from commit 75335b4f58d69616833d6b50a2cd8c5672c502a4) Co-authored-by: Jeff Washington (jwash) <75863576+jeffwashington@users.noreply.github.com> --- runtime/src/bank.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index b17ecc8a1c..d97c95207d 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -4415,12 +4415,36 @@ impl Bank { /// A snapshot bank should be purged of 0 lamport accounts which are not part of the hash /// calculation and could shield other real accounts. pub fn verify_snapshot_bank(&self) -> bool { + let mut clean_time = Measure::start("clean"); if self.slot() > 0 { self.clean_accounts(true); + } + clean_time.stop(); + + let mut shrink_all_slots_time = Measure::start("shrink_all_slots"); + if self.slot() > 0 { self.shrink_all_slots(); } + shrink_all_slots_time.stop(); + + let mut verify_time = Measure::start("verify_bank_hash"); + let mut verify = self.verify_bank_hash(); + verify_time.stop(); + + let mut verify2_time = Measure::start("verify_hash"); // Order and short-circuiting is significant; verify_hash requires a valid bank hash - self.verify_bank_hash() && self.verify_hash() + verify = verify && self.verify_hash(); + verify2_time.stop(); + + datapoint_info!( + "verify_snapshot_bank", + ("clean_us", clean_time.as_us(), i64), + ("shrink_all_slots_us", shrink_all_slots_time.as_us(), i64), + ("verify_bank_hash_us", verify_time.as_us(), i64), + ("verify_hash_us", verify2_time.as_us(), i64), + ); + + verify } /// Return the number of hashes per tick