Skip to content

Commit

Permalink
BlockchainDB, BlockchainLMDB: Add profiling for DB commits
Browse files Browse the repository at this point in the history
  • Loading branch information
warptangent committed Feb 23, 2015
1 parent 7a66b8b commit 8529c0e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/cryptonote_core/BlockchainDB_impl/db_lmdb.cpp
Expand Up @@ -33,6 +33,7 @@

#include "cryptonote_core/cryptonote_format_utils.h"
#include "crypto/crypto.h"
#include "profile_tools.h"

using epee::string_tools::pod_to_hex;

Expand Down Expand Up @@ -1666,7 +1667,10 @@ void BlockchainLMDB::batch_commit()
throw0(DB_ERROR("batch transaction not in progress"));
check_open();
LOG_PRINT_L3("batch transaction: committing...");
TIME_MEASURE_START(time1);
m_write_txn->commit();
TIME_MEASURE_FINISH(time1);
time_commit1 += time1;
LOG_PRINT_L3("batch transaction: committed");

if (mdb_txn_begin(m_env, NULL, 0, m_write_batch_txn))
Expand All @@ -1685,7 +1689,10 @@ void BlockchainLMDB::batch_stop()
throw0(DB_ERROR("batch transaction not in progress"));
check_open();
LOG_PRINT_L3("batch transaction: committing...");
TIME_MEASURE_START(time1);
m_write_txn->commit();
TIME_MEASURE_FINISH(time1);
time_commit1 += time1;
// for destruction of batch transaction
m_write_txn = nullptr;
m_batch_active = false;
Expand Down Expand Up @@ -1741,7 +1748,10 @@ uint64_t BlockchainLMDB::add_block( const block& blk
{
m_write_txn = NULL;

TIME_MEASURE_START(time1);
txn.commit();
TIME_MEASURE_FINISH(time1);
time_commit1 += time1;
}
}
catch (...)
Expand Down
3 changes: 3 additions & 0 deletions src/cryptonote_core/blockchain_db.cpp
Expand Up @@ -151,6 +151,7 @@ void BlockchainDB::reset_stats()
time_blk_hash = 0;
time_add_block1 = 0;
time_add_transaction = 0;
time_commit1 = 0;
}

void BlockchainDB::show_stats()
Expand All @@ -166,6 +167,8 @@ void BlockchainDB::show_stats()
<< ENDL
<< "time_add_transaction: " << time_add_transaction << "ms"
<< ENDL
<< "time_commit1: " << time_commit1 << "ms"
<< ENDL
<< "*********************************"
<< ENDL
);
Expand Down
5 changes: 5 additions & 0 deletions src/cryptonote_core/blockchain_db.h
Expand Up @@ -308,6 +308,11 @@ class BlockchainDB
uint64_t time_add_transaction = 0;


protected:

uint64_t time_commit1 = 0;


public:

// virtual dtor
Expand Down

0 comments on commit 8529c0e

Please sign in to comment.