extra performance while reindexing

This commit is contained in:
Daniel Larimer 2015-08-24 18:50:09 -04:00
parent 2464b788ad
commit 0532661937
4 changed files with 21 additions and 7 deletions

View file

@ -557,13 +557,18 @@ const witness_object& database::validate_block_header( uint32_t skip, const sign
const witness_object& witness = next_block.witness(*this);
FC_ASSERT( secret_hash_type::hash( next_block.previous_secret ) == witness.next_secret_hash, "",
("previous_secret", next_block.previous_secret)("next_secret_hash", witness.next_secret_hash));
if( !(skip&skip_witness_signature) ) FC_ASSERT( next_block.validate_signee( witness.signing_key ) );
uint32_t slot_num = get_slot_at_time( next_block.timestamp );
FC_ASSERT( slot_num > 0 );
if( !(skip&skip_witness_signature) )
FC_ASSERT( next_block.validate_signee( witness.signing_key ) );
witness_id_type scheduled_witness = get_scheduled_witness( slot_num ).first;
FC_ASSERT( next_block.witness == scheduled_witness );
if( !skip_witness_schedule_check )
{
uint32_t slot_num = get_slot_at_time( next_block.timestamp );
FC_ASSERT( slot_num > 0 );
witness_id_type scheduled_witness = get_scheduled_witness( slot_num ).first;
FC_ASSERT( next_block.witness == scheduled_witness );
}
return witness;
}

View file

@ -53,11 +53,12 @@ void database::reindex(fc::path data_dir, const genesis_state_type& initial_allo
_undo_db.disable();
for( uint32_t i = 1; i <= last_block_num; ++i )
{
if( i % 1000 == 0 ) std::cerr << " " << double(i*100)/last_block_num << "% \r";
if( i % 2000 == 0 ) std::cerr << " " << double(i*100)/last_block_num << "% "<<i << " of " <<last_block_num<<" \n";
apply_block(*_block_id_to_block.fetch_by_number(i), skip_witness_signature |
skip_transaction_signatures |
skip_transaction_dupe_check |
skip_tapos_check |
skip_witness_schedule_check |
skip_authority_check);
}
_undo_db.enable();

View file

@ -115,6 +115,7 @@ vector<witness_id_type> database::get_near_witness_schedule()const
void database::update_witness_schedule(const signed_block& next_block)
{
auto start = fc::time_point::now();
const global_property_object& gpo = get_global_properties();
const witness_schedule_object& wso = get(witness_schedule_id_type());
uint32_t schedule_needs_filled = gpo.active_witnesses.size();
@ -168,6 +169,12 @@ void database::update_witness_schedule(const signed_block& next_block)
(_wso.recent_slots_filled << 1)
+ 1) << (schedule_slot - 1);
});
auto end = fc::time_point::now();
static uint64_t total_time = 0;
static uint64_t calls = 0;
total_time += (end - start).count();
if( ++calls % 1000 == 0 )
idump( ( double(total_time/1000000.0)/calls) );
}
uint32_t database::witness_participation_rate()const

View file

@ -89,7 +89,8 @@ namespace graphene { namespace chain {
skip_authority_check = 1 << 6, ///< used while reindexing -- disables any checking of authority on transactions
skip_merkle_check = 1 << 7, ///< used while reindexing
skip_assert_evaluation = 1 << 8, ///< used while reindexing
skip_undo_history_check = 1 << 9 ///< used while reindexing
skip_undo_history_check = 1 << 9, ///< used while reindexing
skip_witness_schedule_check = 1 << 10 ///< used whiel reindexing
};
/**