From d0932f1ea4d19eba8a57ea58edd9ad65570d7fda Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 17 Jun 2021 01:47:35 +0200 Subject: [PATCH] added mixins into monitoring --- src/connectivity_tool/conn_tool.cpp | 1 + src/currency_core/blockchain_storage.cpp | 15 ++++--- src/currency_core/blockchain_storage.h | 50 ++++++++++++------------ src/rpc/core_rpc_server.cpp | 1 + src/rpc/core_rpc_server_commands_defs.h | 3 ++ utils/munin_plugins/tx_mixins_count | 17 ++++++++ 6 files changed, 58 insertions(+), 29 deletions(-) create mode 100644 utils/munin_plugins/tx_mixins_count diff --git a/src/connectivity_tool/conn_tool.cpp b/src/connectivity_tool/conn_tool.cpp index ce3143e9..b14125ad 100644 --- a/src/connectivity_tool/conn_tool.cpp +++ b/src/connectivity_tool/conn_tool.cpp @@ -593,6 +593,7 @@ bool handle_get_daemon_info(po::variables_map& vm) PRINT_FIELD_NAME(res.performance_data, "", tx_append_time) PRINT_FIELD_NAME(res.performance_data, "", tx_append_rl_wait) PRINT_FIELD_NAME(res.performance_data, "", tx_append_is_expired) + PRINT_FIELD_NAME(res.performance_data, "", tx_mixin_count) PRINT_FIELD_NAME(res.performance_data, "", tx_check_inputs_prefix_hash) PRINT_FIELD_NAME(res.performance_data, "", tx_check_inputs_attachment_check) PRINT_FIELD_NAME(res.performance_data, "", tx_check_inputs_loop) diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index e60e5b6f..fd2b4d3e 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -3816,12 +3816,14 @@ namespace currency const crypto::hash& m_tx_id; const crypto::hash& m_bl_id; const uint64_t m_bl_height; - add_transaction_input_visitor(blockchain_storage& bcs, blockchain_storage::key_images_container& m_db_spent_keys, const crypto::hash& tx_id, const crypto::hash& bl_id, const uint64_t bl_height) : + uint64_t &m_mixins_count; + add_transaction_input_visitor(blockchain_storage& bcs, blockchain_storage::key_images_container& m_db_spent_keys, const crypto::hash& tx_id, const crypto::hash& bl_id, const uint64_t bl_height, uint64_t& mixins_count) : m_bcs(bcs), m_db_spent_keys(m_db_spent_keys), m_tx_id(tx_id), m_bl_id(bl_id), - m_bl_height(bl_height) + m_bl_height(bl_height), + m_mixins_count(mixins_count) {} bool operator()(const txin_to_key& in) const { @@ -3846,7 +3848,8 @@ namespace currency return false; } } - + if (m_mixins_count < in.key_offsets.size()) + m_mixins_count = in.key_offsets.size(); return true; } bool operator()(const txin_htlc& in) const @@ -3896,11 +3899,11 @@ bool blockchain_storage::add_transaction_from_block(const transaction& tx, const process_blockchain_tx_attachments(tx, bl_height, bl_id, timestamp); TIME_MEASURE_FINISH_PD_COND(need_to_profile, tx_process_attachment); - + uint64_t mixins_count = 0; TIME_MEASURE_START_PD(tx_process_inputs); for(const txin_v& in : tx.vin) { - if(!boost::apply_visitor(add_transaction_input_visitor(*this, m_db_spent_keys, tx_id, bl_id, bl_height), in)) + if(!boost::apply_visitor(add_transaction_input_visitor(*this, m_db_spent_keys, tx_id, bl_id, bl_height, mixins_count), in)) { LOG_ERROR("critical internal error: add_transaction_input_visitor failed. but key_images should be already checked"); purge_transaction_keyimages_from_blockchain(tx, false); @@ -3913,6 +3916,8 @@ bool blockchain_storage::add_transaction_from_block(const transaction& tx, const } } TIME_MEASURE_FINISH_PD_COND(need_to_profile, tx_process_inputs); + if(need_to_profile && mixins_count > 0) + m_performance_data.tx_mixin_count.push(mixins_count); //check if there is already transaction with this hash TIME_MEASURE_START_PD(tx_check_exist); diff --git a/src/currency_core/blockchain_storage.h b/src/currency_core/blockchain_storage.h index 5c3b995f..7cb02c41 100644 --- a/src/currency_core/blockchain_storage.h +++ b/src/currency_core/blockchain_storage.h @@ -73,33 +73,35 @@ namespace currency epee::math_helper::average target_calculating_calc; //tx processing zone - epee::math_helper::average tx_check_inputs_time; - epee::math_helper::average tx_add_one_tx_time; - epee::math_helper::average tx_process_extra; - epee::math_helper::average tx_process_attachment; - epee::math_helper::average tx_process_inputs ; - epee::math_helper::average tx_push_global_index; - epee::math_helper::average tx_check_exist; - epee::math_helper::average tx_print_log; - epee::math_helper::average tx_prapare_append; + epee::math_helper::average tx_check_inputs_time; + epee::math_helper::average tx_add_one_tx_time; + epee::math_helper::average tx_process_extra; + epee::math_helper::average tx_process_attachment; + epee::math_helper::average tx_process_inputs ; + epee::math_helper::average tx_push_global_index; + epee::math_helper::average tx_check_exist; + epee::math_helper::average tx_print_log; + epee::math_helper::average tx_prapare_append; - epee::math_helper::average tx_append_time; - epee::math_helper::average tx_append_rl_wait; - epee::math_helper::average tx_append_is_expired; + epee::math_helper::average tx_append_time; + epee::math_helper::average tx_append_rl_wait; + epee::math_helper::average tx_append_is_expired; - epee::math_helper::average tx_store_db; + epee::math_helper::average tx_store_db; - epee::math_helper::average tx_check_inputs_prefix_hash; - epee::math_helper::average tx_check_inputs_attachment_check; - epee::math_helper::average tx_check_inputs_loop; - epee::math_helper::average tx_check_inputs_loop_kimage_check; - epee::math_helper::average tx_check_inputs_loop_ch_in_val_sig; - epee::math_helper::average tx_check_inputs_loop_scan_outputkeys_get_item_size; - epee::math_helper::average tx_check_inputs_loop_scan_outputkeys_relative_to_absolute; - epee::math_helper::average tx_check_inputs_loop_scan_outputkeys_loop; - epee::math_helper::average tx_check_inputs_loop_scan_outputkeys_loop_get_subitem; - epee::math_helper::average tx_check_inputs_loop_scan_outputkeys_loop_find_tx; - epee::math_helper::average tx_check_inputs_loop_scan_outputkeys_loop_handle_output; + epee::math_helper::average tx_check_inputs_prefix_hash; + epee::math_helper::average tx_check_inputs_attachment_check; + epee::math_helper::average tx_check_inputs_loop; + epee::math_helper::average tx_check_inputs_loop_kimage_check; + epee::math_helper::average tx_check_inputs_loop_ch_in_val_sig; + epee::math_helper::average tx_check_inputs_loop_scan_outputkeys_get_item_size; + epee::math_helper::average tx_check_inputs_loop_scan_outputkeys_relative_to_absolute; + epee::math_helper::average tx_check_inputs_loop_scan_outputkeys_loop; + epee::math_helper::average tx_check_inputs_loop_scan_outputkeys_loop_get_subitem; + epee::math_helper::average tx_check_inputs_loop_scan_outputkeys_loop_find_tx; + epee::math_helper::average tx_check_inputs_loop_scan_outputkeys_loop_handle_output; + + epee::math_helper::average tx_mixin_count; //TODO: move this to suitable place or remove it all diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 6238bed6..2c287ed7 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -210,6 +210,7 @@ namespace currency res.performance_data.tx_append_time = pd.tx_append_time.get_avg(); res.performance_data.tx_append_rl_wait = pd.tx_append_rl_wait.get_avg(); res.performance_data.tx_append_is_expired = pd.tx_append_is_expired.get_avg(); + res.performance_data.tx_mixin_count = pd.tx_mixin_count.get_avg(); res.performance_data.tx_store_db = pd.tx_store_db.get_avg(); diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h index 2ef811ac..531cbe74 100644 --- a/src/rpc/core_rpc_server_commands_defs.h +++ b/src/rpc/core_rpc_server_commands_defs.h @@ -500,6 +500,8 @@ namespace currency uint64_t tx_print_log; uint64_t tx_prapare_append; + uint64_t tx_mixin_count; + uint64_t tx_store_db; @@ -547,6 +549,7 @@ namespace currency KV_SERIALIZE(tx_store_db) KV_SERIALIZE(tx_print_log) KV_SERIALIZE(tx_prapare_append) + KV_SERIALIZE(tx_mixin_count) KV_SERIALIZE(tx_check_inputs_prefix_hash) KV_SERIALIZE(tx_check_inputs_attachment_check) diff --git a/utils/munin_plugins/tx_mixins_count b/utils/munin_plugins/tx_mixins_count new file mode 100644 index 00000000..434c5cb3 --- /dev/null +++ b/utils/munin_plugins/tx_mixins_count @@ -0,0 +1,17 @@ +#!/bin/bash + +case $1 in + config) + cat <<'EOM' +graph_args --alt-autoscale +graph_title mixins +graph_vlabel mixins +graph_category daemon +mixins.label mixins + +EOM + exit 0;; +esac + +printf "mixins.value " +connectivity_tool --ip=127.0.0.1 --rpc-port=$ZANO_RPC_PORT --timeout=1000 --rpc-get-daemon-info --getinfo-flags-hex="0x0000000000010000" | grep tx_mixin_count | cut -d ' ' -f2