Skip to content

Commit

Permalink
Reduce initial mapsize for LMDB, change resizing conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
who-biz committed Jul 22, 2020
1 parent cfed164 commit ba05bbc
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/blockchain_db/lmdb/db_lmdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ void BlockchainLMDB::do_resize(uint64_t increase_size)
{
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
CRITICAL_REGION_LOCAL(m_synchronization_lock);
const uint64_t add_size = 1LL << 30;
const uint64_t add_size = 1LL << 27;

// check disk capacity
try
Expand Down Expand Up @@ -614,6 +614,7 @@ void BlockchainLMDB::add_block(const block& blk, const size_t& block_size, const

m_cum_size += block_size;
m_cum_count++;

}

void BlockchainLMDB::remove_block()
Expand Down Expand Up @@ -1043,7 +1044,7 @@ void BlockchainLMDB::open(const std::string& filename, const int db_flags)
(result = mdb_env_set_maxreaders(m_env, threads+16)))
throw0(DB_ERROR(lmdb_error("Failed to set max number of readers: ", result).c_str()));

size_t mapsize = DEFAULT_MAPSIZE;
size_t mapsize = (1LL << 27);

if (db_flags & DBF_FAST)
mdb_flags |= MDB_NOSYNC;
Expand Down Expand Up @@ -2485,6 +2486,18 @@ bool BlockchainLMDB::batch_start(uint64_t batch_num_blocks, uint64_t batch_bytes
check_open();

m_writer = boost::this_thread::get_id();

MDB_envinfo mei;
mdb_env_info(m_env, &mei);
MDB_stat mst;
mdb_env_stat(m_env, &mst);

uint64_t size_used = mst.ms_psize * mei.me_last_pgno;

if ((mei.me_mapsize - size_used) <= (1LL << 26)) {
do_resize();
}

check_and_resize_for_batch(batch_num_blocks, batch_bytes);

m_write_batch_txn = new mdb_txn_safe();
Expand Down

0 comments on commit ba05bbc

Please sign in to comment.