From 8406b67a9792b921fedaa0090cad6f626205d737 Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Tue, 29 Nov 2016 16:38:39 -0500 Subject: [PATCH] Print free memory #635 --- libraries/chain/database.cpp | 10 +++++++++- libraries/chain/include/steemit/chain/database.hpp | 2 ++ libraries/chainbase | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/libraries/chain/database.cpp b/libraries/chain/database.cpp index e6accb012d..60989d949d 100644 --- a/libraries/chain/database.cpp +++ b/libraries/chain/database.cpp @@ -171,7 +171,8 @@ void database::reindex( const fc::path& data_dir, const fc::path& shared_mem_dir { auto cur_block_num = itr.first.block_num(); if( cur_block_num % 100000 == 0 ) - std::cerr << " " << double( cur_block_num * 100 ) / last_block_num << "% " << cur_block_num << " of " << last_block_num << " \n"; + std::cerr << " " << double( cur_block_num * 100 ) / last_block_num << "% " << cur_block_num << " of " << last_block_num << + " (" << (get_free_memory() / (1024*1024)) << "M free)\n"; apply_block( itr.first, skip_flags ); itr = _block_log.read_block( itr.second ); } @@ -2959,6 +2960,13 @@ void database::apply_block( const signed_block& next_block, uint32_t skip ) } } + uint32_t free_gb = uint32_t(get_free_memory() / (1024*1024*1024)); + if( (free_gb < _last_free_gb_printed) || (free_gb > _last_free_gb_printed+1) ) + { + ilog( "Free memory is now ${n}G", ("n", free_gb) ); + _last_free_gb_printed = free_gb; + } + } FC_CAPTURE_AND_RETHROW( (next_block) ) } void database::_apply_block( const signed_block& next_block ) diff --git a/libraries/chain/include/steemit/chain/database.hpp b/libraries/chain/include/steemit/chain/database.hpp index dd5c0cae11..da6cbcb0f8 100644 --- a/libraries/chain/include/steemit/chain/database.hpp +++ b/libraries/chain/include/steemit/chain/database.hpp @@ -475,6 +475,8 @@ namespace steemit { namespace chain { uint32_t _flush_blocks = 0; uint32_t _next_flush_block = 0; + uint32_t _last_free_gb_printed = 0; + flat_map< std::string, std::shared_ptr< custom_operation_interpreter > > _custom_operation_interpreters; std::string _json_schema; }; diff --git a/libraries/chainbase b/libraries/chainbase index 4de0d495e6..a1ca930951 160000 --- a/libraries/chainbase +++ b/libraries/chainbase @@ -1 +1 @@ -Subproject commit 4de0d495e624a30f4b1cbf200e59716837886103 +Subproject commit a1ca93095197bbe9e2eb6716c28ee351cd95b174