aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_db/lmdb
diff options
context:
space:
mode:
authorHoward Chu <hyc@symas.com>2017-02-18 17:27:33 +0000
committerHoward Chu <hyc@symas.com>2017-02-18 21:01:24 +0000
commitdc53e9eef22531902b8bbad7d9ec33cefc211e84 (patch)
treef07006248f4197ea5c8b400967f58f2fd3b4b904 /src/blockchain_db/lmdb
parenttests: fixup include paths after cryptonote_core split (diff)
downloadmonero-dc53e9eef22531902b8bbad7d9ec33cefc211e84.tar.xz
Add a few read txns to streamline
Slight perf gain, but mainly to reduce spam at loglevel 3
Diffstat (limited to 'src/blockchain_db/lmdb')
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.cpp8
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.h2
2 files changed, 7 insertions, 3 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp
index 0a35325e4..a1b837b6f 100644
--- a/src/blockchain_db/lmdb/db_lmdb.cpp
+++ b/src/blockchain_db/lmdb/db_lmdb.cpp
@@ -561,7 +561,7 @@ uint64_t BlockchainLMDB::get_estimated_batch_size(uint64_t batch_num_blocks) con
{
LOG_PRINT_L1("No existing blocks to check for average block size");
}
- else if (m_cum_count)
+ else if (m_cum_count >= num_prev_blocks)
{
avg_block_size = m_cum_size / m_cum_count;
LOG_PRINT_L1("average block size across recent " << m_cum_count << " blocks: " << avg_block_size);
@@ -570,6 +570,9 @@ uint64_t BlockchainLMDB::get_estimated_batch_size(uint64_t batch_num_blocks) con
}
else
{
+ MDB_txn *rtxn;
+ mdb_txn_cursors *rcurs;
+ block_rtxn_start(&rtxn, &rcurs);
for (uint64_t block_num = block_start; block_num <= block_stop; ++block_num)
{
uint32_t block_size = get_block_size(block_num);
@@ -578,6 +581,7 @@ uint64_t BlockchainLMDB::get_estimated_batch_size(uint64_t batch_num_blocks) con
// some blocks were to be skipped for being outliers.
++num_blocks_used;
}
+ block_rtxn_stop();
avg_block_size = total_block_size / num_blocks_used;
LOG_PRINT_L1("average block size across recent " << num_blocks_used << " blocks: " << avg_block_size);
}
@@ -1000,7 +1004,7 @@ tx_out BlockchainLMDB::output_from_blob(const blobdata& blob) const
void BlockchainLMDB::check_open() const
{
- LOG_PRINT_L3("BlockchainLMDB::" << __func__);
+// LOG_PRINT_L3("BlockchainLMDB::" << __func__);
if (!m_open)
throw0(DB_ERROR("DB operation attempted on a not-open DB instance"));
}
diff --git a/src/blockchain_db/lmdb/db_lmdb.h b/src/blockchain_db/lmdb/db_lmdb.h
index e7faf8cdc..57c2a5e39 100644
--- a/src/blockchain_db/lmdb/db_lmdb.h
+++ b/src/blockchain_db/lmdb/db_lmdb.h
@@ -372,7 +372,7 @@ private:
uint64_t m_num_txs;
uint64_t m_num_outputs;
mutable uint64_t m_cum_size; // used in batch size estimation
- mutable int m_cum_count;
+ mutable unsigned int m_cum_count;
std::string m_folder;
mdb_txn_safe* m_write_txn; // may point to either a short-lived txn or a batch txn
mdb_txn_safe* m_write_batch_txn; // persist batch txn outside of BlockchainLMDB