From 5dec82a2fcdf5b641ca9125b8a4b60f82dfe0cb0 Mon Sep 17 00:00:00 2001 From: "crypro.zoidberg" Date: Wed, 17 Apr 2019 19:22:51 +0200 Subject: [PATCH] added more details on performance monitoring --- src/connectivity_tool/conn_tool.cpp | 2 ++ src/currency_core/blockchain_storage.cpp | 7 +++++- src/currency_core/blockchain_storage.h | 3 +++ src/currency_core/difficulty.cpp | 1 + .../functional_tests/difficulty_analysis.cpp | 22 +++++++++++++++++-- 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/connectivity_tool/conn_tool.cpp b/src/connectivity_tool/conn_tool.cpp index 660de59a..1fb48d26 100644 --- a/src/connectivity_tool/conn_tool.cpp +++ b/src/connectivity_tool/conn_tool.cpp @@ -567,6 +567,8 @@ bool handle_get_daemon_info(po::variables_map& vm) << "longhash_calculating_time_3: " << res.performance_data.longhash_calculating_time_3 << ENDL << "raise_block_core_event: " << res.performance_data.raise_block_core_event << ENDL << "target_calculating_time_2: " << res.performance_data.target_calculating_time_2 << ENDL + << "target_calculating_enum_blocks: " << res.performance_data.target_calculating_enum_blocks << ENDL + << "target_calculating_calc: " << res.performance_data.target_calculating_calc << ENDL << "all_txs_insert_time_5: " << res.performance_data.all_txs_insert_time_5 << ENDL << "tx_add_one_tx_time: " << res.performance_data.tx_add_one_tx_time << ENDL << "tx_check_inputs_time: " << res.performance_data.tx_check_inputs_time << ENDL diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 51c082bd..ad5ee65b 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -932,8 +932,13 @@ wide_difficulty_type blockchain_storage::get_next_diff_conditional2(bool pos, co return false; return true; }; + TIME_MEASURE_START_PD(target_calculating_enum_blocks); enum_blockchain(cb, alt_chain, split_height); - return next_difficulty(timestamps, commulative_difficulties, pos ? DIFFICULTY_POS_TARGET : DIFFICULTY_POW_TARGET); + TIME_MEASURE_FINISH_PD(target_calculating_enum_blocks); + TIME_MEASURE_START_PD(target_calculating_calc); + wide_difficulty_type res = next_difficulty(timestamps, commulative_difficulties, pos ? DIFFICULTY_POS_TARGET : DIFFICULTY_POW_TARGET); + TIME_MEASURE_FINISH_PD(target_calculating_calc); + return res; } //------------------------------------------------------------------ wide_difficulty_type blockchain_storage::get_cached_next_difficulty(bool pos) const diff --git a/src/currency_core/blockchain_storage.h b/src/currency_core/blockchain_storage.h index 960b288b..463a754c 100644 --- a/src/currency_core/blockchain_storage.h +++ b/src/currency_core/blockchain_storage.h @@ -68,6 +68,9 @@ namespace currency epee::math_helper::average etc_stuff_6; epee::math_helper::average insert_time_4; epee::math_helper::average raise_block_core_event; + //target_calculating_time_2 + epee::math_helper::average target_calculating_enum_blocks; + epee::math_helper::average target_calculating_calc; //tx processing zone epee::math_helper::average tx_check_inputs_time; diff --git a/src/currency_core/difficulty.cpp b/src/currency_core/difficulty.cpp index 21d7d339..b5d90356 100644 --- a/src/currency_core/difficulty.cpp +++ b/src/currency_core/difficulty.cpp @@ -239,6 +239,7 @@ namespace currency { wide_difficulty_type next_difficulty(vector& timestamps, vector& cumulative_difficulties, size_t target_seconds) { + TIME_MEASURE_START_PD(target_calculating_enum_blocks); // timestamps - first is latest, back - is oldest timestamps if (timestamps.size() > DIFFICULTY_WINDOW) { diff --git a/tests/functional_tests/difficulty_analysis.cpp b/tests/functional_tests/difficulty_analysis.cpp index b784a88b..ef1e840b 100644 --- a/tests/functional_tests/difficulty_analysis.cpp +++ b/tests/functional_tests/difficulty_analysis.cpp @@ -12,6 +12,7 @@ using namespace epee; #include "wallet/wallet2.h" #include "currency_core/blockchain_storage.h" +#include "currency_core/basic_pow_helpers.h" using std::size_t; @@ -321,8 +322,25 @@ void run_emulation(const std::string& path) void run_difficulty_analysis(const std::string& path) { - //hash_rate_analysis(path); - run_emulation(path); +// currency::block b = AUTO_VAL_INIT(b); +// std::string s("sdsccasc"); +// b.miner_tx.extra.push_back(s); +// +// crypto::hash mining_hash = currency::null_hash; +// bool r = string_tools::parse_tpod_from_hex_string("7759031ee0f014fe45476724df268f61c890b4a4637df1489a6c94c0135efbd8", mining_hash); +// uint64_t nonce = 13704307308123612296; +// crypto::hash pow_hash = currency::get_block_longhash(6, mining_hash, nonce); +// +// std::cout << mining_hash << ENDL; +// std::cout << pow_hash << ENDL; + + //crypto::hash mining_hash = currency::get_block_header_mining_hash(b); + crypto::hash id_hash = currency::get_block_hash(b); + + + + hash_rate_analysis(path); + //run_emulation(path); }