Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change replay percentage to total block size processed #1289 #1335

Merged
merged 5 commits into from
Oct 2, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions libraries/chain/block_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,4 +271,16 @@ optional<block_id_type> block_database::last_id()const
return optional<block_id_type>();
}

uint64_t block_database::total_processed_block_size()const
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is misleading. The method returns the current position in the file. During replay, this is in fact what we interpret as total_processed_block_size, but during normal operation it isn't.

{
_blocks.seekg( 0, _blocks.cur );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is superfluous.

return (uint64_t)_blocks.tellg();
}

uint64_t block_database::total_block_size()const
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both these methods should return size_t.

{
_blocks.seekg( 0, _blocks.end );
return (uint64_t)_blocks.tellg();
}

} }
13 changes: 12 additions & 1 deletion libraries/chain/db_management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,20 @@ void database::reindex( fc::path data_dir )
skip_tapos_check |
skip_witness_schedule_check |
skip_authority_check;

uint64_t total_processed_block_size;
uint64_t total_block_size;
for( uint32_t i = head_block_num() + 1; i <= last_block_num; ++i )
{
if( i % 10000 == 0 ) std::cerr << " " << double(i*100)/last_block_num << "% "<<i << " of " <<last_block_num<<" \n";
if( i % 10000 == 0 )
{
total_processed_block_size = _block_id_to_block.total_processed_block_size();
total_block_size = _block_id_to_block.total_block_size();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

total_block_size doesn't change during replay, you should fetch that once before entering the loop.


std::cerr << " "
<< double(total_processed_block_size*100) / total_block_size << "% "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this won't overflow? Still a bit uncomfortable with it.

By the way, perhaps better to show the block number as well?

<< total_processed_block_size << " of " << total_block_size << " \n";
}
if( i == flush_point )
{
ilog( "Writing database to disk at block ${i}", ("i",i) );
Expand Down
2 changes: 2 additions & 0 deletions libraries/chain/include/graphene/chain/block_database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ namespace graphene { namespace chain {
optional<signed_block> fetch_by_number( uint32_t block_num )const;
optional<signed_block> last()const;
optional<block_id_type> last_id()const;
uint64_t total_processed_block_size()const;
uint64_t total_block_size()const;
private:
optional<index_entry> last_index_entry()const;
fc::path _index_filename;
Expand Down