Use actual batch size for resize estimates

And optimize import startup:

Remember start_height position during initial count_blocks pass
to avoid having to reread entire file again to arrive at start_height
This commit is contained in:
Howard Chu 2017-09-17 00:12:42 +01:00
parent 7abdba0a5c
commit d2d8a41c47
No known key found for this signature in database
GPG key ID: FD2A70B44AB11BA7
8 changed files with 135 additions and 67 deletions

View file

@ -3666,6 +3666,7 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::list<block_complete_e
MTRACE("Blockchain::" << __func__);
TIME_MEASURE_START(prepare);
bool stop_batch;
uint64_t bytes = 0;
// Order of locking must be:
// m_incoming_tx_lock (optional)
@ -3687,7 +3688,15 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::list<block_complete_e
if(blocks_entry.size() == 0)
return false;
while (!(stop_batch = m_db->batch_start(blocks_entry.size()))) {
for (const auto &entry : blocks_entry)
{
bytes += entry.block.size();
for (const auto &tx_blob : entry.txs)
{
bytes += tx_blob.size();
}
}
while (!(stop_batch = m_db->batch_start(blocks_entry.size(), bytes))) {
m_blockchain_lock.unlock();
m_tx_pool.unlock();
epee::misc_utils::sleep_no_w(1000);