Focus bench on squash and fix log errors (#9759)
* Focus bench on squash Squash performance does not depend on adding a small number accounts. It mainly depends on total number of accounts that need to be hashed during freeze operation. New bank means a clone of accounts db, so we don't get previous errors in log. * Fix fmt and add slot counter
This commit is contained in:
		@@ -42,28 +42,24 @@ fn test_accounts_create(bencher: &mut Bencher) {
 | 
				
			|||||||
#[bench]
 | 
					#[bench]
 | 
				
			||||||
fn test_accounts_squash(bencher: &mut Bencher) {
 | 
					fn test_accounts_squash(bencher: &mut Bencher) {
 | 
				
			||||||
    let (genesis_config, _) = create_genesis_config(100_000);
 | 
					    let (genesis_config, _) = create_genesis_config(100_000);
 | 
				
			||||||
    let mut banks: Vec<Arc<Bank>> = Vec::with_capacity(10);
 | 
					    let bank1 = Arc::new(Bank::new_with_paths(
 | 
				
			||||||
    banks.push(Arc::new(Bank::new_with_paths(
 | 
					 | 
				
			||||||
        &genesis_config,
 | 
					        &genesis_config,
 | 
				
			||||||
        vec![PathBuf::from("bench_a1")],
 | 
					        vec![PathBuf::from("bench_a1")],
 | 
				
			||||||
        &[],
 | 
					        &[],
 | 
				
			||||||
    )));
 | 
					    ));
 | 
				
			||||||
    let mut pubkeys: Vec<Pubkey> = vec![];
 | 
					    let mut pubkeys: Vec<Pubkey> = vec![];
 | 
				
			||||||
    deposit_many(&banks[0], &mut pubkeys, 250000);
 | 
					    deposit_many(&bank1, &mut pubkeys, 250000);
 | 
				
			||||||
    banks[0].freeze();
 | 
					    bank1.freeze();
 | 
				
			||||||
    // Measures the performance of the squash operation merging the accounts
 | 
					
 | 
				
			||||||
    // with the majority of the accounts present in the parent bank that is
 | 
					    // Measures the performance of the squash operation.
 | 
				
			||||||
    // moved over to this bank.
 | 
					    // This mainly consists of the freeze operation which calculates the
 | 
				
			||||||
 | 
					    // merkle hash of the account state and distribution of fees and rent
 | 
				
			||||||
 | 
					    let mut slot = 1u64;
 | 
				
			||||||
    bencher.iter(|| {
 | 
					    bencher.iter(|| {
 | 
				
			||||||
        banks.push(Arc::new(Bank::new_from_parent(
 | 
					        let bank2 = Arc::new(Bank::new_from_parent(&bank1, &Pubkey::default(), slot));
 | 
				
			||||||
            &banks[0],
 | 
					        bank2.deposit(&pubkeys[0], 1);
 | 
				
			||||||
            &Pubkey::default(),
 | 
					        bank2.squash();
 | 
				
			||||||
            1u64,
 | 
					        slot += 1;
 | 
				
			||||||
        )));
 | 
					 | 
				
			||||||
        for accounts in 0..10000 {
 | 
					 | 
				
			||||||
            banks[1].deposit(&pubkeys[accounts], (accounts + 1) as u64);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        banks[1].squash();
 | 
					 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user