aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_db/lmdb/db_lmdb.h
diff options
context:
space:
mode:
authorwarptangent <warptangent@inbox.com>2015-07-11 22:46:16 -0700
committerwarptangent <warptangent@inbox.com>2015-07-12 00:51:39 -0700
commitfd73d9cc3a05ca551cdd1c425c664e24e746b152 (patch)
tree3aab685c062a06e9a3d6f66c64cc6e2154c4539c /src/blockchain_db/lmdb/db_lmdb.h
parentblockchain_utilities: Increase debug statement's log level (diff)
downloadmonero-fd73d9cc3a05ca551cdd1c425c664e24e746b152.tar.xz
Check and resize if needed at batch transaction start
This currently only affects blockchain_import and blockchain_converter. When the number of blocks expected for the batch transaction is provided, make an estimate of the DB space needed. If not enough free space remains, resize the DB. The estimate is made based on: - the average size of the last 500 blocks, or if larger, a min. block size of 4k - a factor for the expanded size a block occupies in the DB across the sub-dbs/tables - a safety factor (1.7) to allow for a "reasonable" average block size increase over the batch Increase the DB size by whichever is greater: the estimated size needed or a minimum increase size, currently 128 MB. The conservative factors in the estimate help in testing that the resize occurs when needed, and without gratuitous size increases. For common use, the safety factor and minimum increase size could reasonably be increased. For testing, setting DEFAULT_MAPSIZE (blockchain_db/lmdb/db_lmdb.h) to 1 << 27 (128 MB) and recompiling will ensure DB resizes take place sooner and more frequently.
Diffstat (limited to 'src/blockchain_db/lmdb/db_lmdb.h')
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.h b/src/blockchain_db/lmdb/db_lmdb.h
index 6c82939c8..6f2262546 100644
--- a/src/blockchain_db/lmdb/db_lmdb.h
+++ b/src/blockchain_db/lmdb/db_lmdb.h
@@ -199,9 +199,11 @@ public:
virtual void pop_block(block& blk, std::vector<transaction>& txs);
private:
- void do_resize();
+ void do_resize(uint64_t size_increase=0);
- bool need_resize() const;
+ bool need_resize(uint64_t threshold_size=0) const;
+ void check_and_resize_for_batch(uint64_t batch_num_blocks);
+ uint64_t get_estimated_batch_size(uint64_t batch_num_blocks) const;
virtual void add_block( const block& blk
, const size_t& block_size