From d10a708fa2814dc8a9a92857cfcbfb0c5dcc92ef Mon Sep 17 00:00:00 2001 From: zy-kkk Date: Mon, 27 Nov 2023 10:33:39 +0800 Subject: [PATCH] [improve](jdbc catalog) add profile for jdbc scan (#27447) --- be/src/vec/exec/scan/new_jdbc_scanner.cpp | 40 +++++++++-------------- be/src/vec/exec/scan/new_jdbc_scanner.h | 5 +-- be/src/vec/exec/vjdbc_connector.cpp | 2 ++ be/src/vec/exec/vjdbc_connector.h | 4 +-- 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/be/src/vec/exec/scan/new_jdbc_scanner.cpp b/be/src/vec/exec/scan/new_jdbc_scanner.cpp index 89e5d8e5d8..4f90edde3b 100644 --- a/be/src/vec/exec/scan/new_jdbc_scanner.cpp +++ b/be/src/vec/exec/scan/new_jdbc_scanner.cpp @@ -45,17 +45,7 @@ NewJdbcScanner::NewJdbcScanner(RuntimeState* state, NewJdbcScanNode* parent, int _query_string(query_string), _tuple_desc(nullptr), _table_type(table_type) { - _is_init = false; - _load_jar_timer = ADD_TIMER(get_parent()->_scanner_profile, "LoadJarTime"); - _init_connector_timer = ADD_TIMER(get_parent()->_scanner_profile, "InitConnectorTime"); - _check_type_timer = ADD_TIMER(get_parent()->_scanner_profile, "CheckTypeTime"); - _get_data_timer = ADD_TIMER(get_parent()->_scanner_profile, "GetDataTime"); - _call_jni_next_timer = - ADD_CHILD_TIMER(get_parent()->_scanner_profile, "CallJniNextTime", "GetDataTime"); - _convert_batch_timer = - ADD_CHILD_TIMER(get_parent()->_scanner_profile, "ConvertBatchTime", "GetDataTime"); - _execte_read_timer = ADD_TIMER(get_parent()->_scanner_profile, "ExecteReadTime"); - _connector_close_timer = ADD_TIMER(get_parent()->_scanner_profile, "ConnectorCloseTime"); + _init_profile(get_parent()->_scanner_profile); } NewJdbcScanner::NewJdbcScanner(RuntimeState* state, @@ -68,17 +58,7 @@ NewJdbcScanner::NewJdbcScanner(RuntimeState* state, _query_string(query_string), _tuple_desc(nullptr), _table_type(table_type) { - _is_init = false; - _load_jar_timer = ADD_TIMER(local_state->_scanner_profile, "LoadJarTime"); - _init_connector_timer = ADD_TIMER(local_state->_scanner_profile, "InitConnectorTime"); - _check_type_timer = ADD_TIMER(local_state->_scanner_profile, "CheckTypeTime"); - _get_data_timer = ADD_TIMER(local_state->_scanner_profile, "GetDataTime"); - _call_jni_next_timer = - ADD_CHILD_TIMER(local_state->_scanner_profile, "CallJniNextTime", "GetDataTime"); - _convert_batch_timer = - ADD_CHILD_TIMER(local_state->_scanner_profile, "ConvertBatchTime", "GetDataTime"); - _execte_read_timer = ADD_TIMER(local_state->_scanner_profile, "ExecteReadTime"); - _connector_close_timer = ADD_TIMER(local_state->_scanner_profile, "ConnectorCloseTime"); + _init_profile(local_state->_scanner_profile); } Status NewJdbcScanner::prepare(RuntimeState* state, const VExprContextSPtrs& conjuncts) { @@ -192,14 +172,26 @@ Status NewJdbcScanner::_get_block_impl(RuntimeState* state, Block* block, bool* return Status::OK(); } +void NewJdbcScanner::_init_profile(const std::shared_ptr& profile) { + _is_init = false; + _load_jar_timer = ADD_TIMER(profile, "LoadJarTime"); + _init_connector_timer = ADD_TIMER(profile, "InitConnectorTime"); + _check_type_timer = ADD_TIMER(profile, "CheckTypeTime"); + _get_data_timer = ADD_TIMER(profile, "GetDataTime"); + _get_block_address_timer = ADD_CHILD_TIMER(profile, "GetBlockAddressTime", "GetDataTime"); + _fill_block_timer = ADD_CHILD_TIMER(profile, "FillBlockTime", "GetDataTime"); + _execte_read_timer = ADD_TIMER(profile, "ExecteReadTime"); + _connector_close_timer = ADD_TIMER(profile, "ConnectorCloseTime"); +} + void NewJdbcScanner::_update_profile() { JdbcConnector::JdbcStatistic& jdbc_statistic = _jdbc_connector->get_jdbc_statistic(); COUNTER_UPDATE(_load_jar_timer, jdbc_statistic._load_jar_timer); COUNTER_UPDATE(_init_connector_timer, jdbc_statistic._init_connector_timer); COUNTER_UPDATE(_check_type_timer, jdbc_statistic._check_type_timer); COUNTER_UPDATE(_get_data_timer, jdbc_statistic._get_data_timer); - COUNTER_UPDATE(_call_jni_next_timer, jdbc_statistic._call_jni_next_timer); - COUNTER_UPDATE(_convert_batch_timer, jdbc_statistic._convert_batch_timer); + COUNTER_UPDATE(_get_block_address_timer, jdbc_statistic._get_block_address_timer); + COUNTER_UPDATE(_fill_block_timer, jdbc_statistic._fill_block_timer); COUNTER_UPDATE(_execte_read_timer, jdbc_statistic._execte_read_timer); COUNTER_UPDATE(_connector_close_timer, jdbc_statistic._connector_close_timer); } diff --git a/be/src/vec/exec/scan/new_jdbc_scanner.h b/be/src/vec/exec/scan/new_jdbc_scanner.h index cdb9525eb6..cca0a29fe7 100644 --- a/be/src/vec/exec/scan/new_jdbc_scanner.h +++ b/be/src/vec/exec/scan/new_jdbc_scanner.h @@ -63,13 +63,14 @@ protected: RuntimeProfile::Counter* _load_jar_timer = nullptr; RuntimeProfile::Counter* _init_connector_timer = nullptr; RuntimeProfile::Counter* _get_data_timer = nullptr; - RuntimeProfile::Counter* _call_jni_next_timer = nullptr; - RuntimeProfile::Counter* _convert_batch_timer = nullptr; + RuntimeProfile::Counter* _get_block_address_timer = nullptr; + RuntimeProfile::Counter* _fill_block_timer = nullptr; RuntimeProfile::Counter* _check_type_timer = nullptr; RuntimeProfile::Counter* _execte_read_timer = nullptr; RuntimeProfile::Counter* _connector_close_timer = nullptr; private: + void _init_profile(const std::shared_ptr& profile); void _update_profile(); bool _jdbc_eos; diff --git a/be/src/vec/exec/vjdbc_connector.cpp b/be/src/vec/exec/vjdbc_connector.cpp index b28717eafc..d3debc688d 100644 --- a/be/src/vec/exec/vjdbc_connector.cpp +++ b/be/src/vec/exec/vjdbc_connector.cpp @@ -218,6 +218,7 @@ Status JdbcConnector::get_next(bool* eos, Block* block, int batch_size) { auto slots = _tuple_desc->slots(); jobject map = _get_reader_params(block, env, column_size); + SCOPED_RAW_TIMER(&_jdbc_statistic._get_block_address_timer); long address = env->CallLongMethod(_executor_obj, _executor_get_block_address_id, batch_size, map); RETURN_IF_ERROR(JniUtil::GetJniExceptionMsg(env)); @@ -227,6 +228,7 @@ Status JdbcConnector::get_next(bool* eos, Block* block, int batch_size) { for (size_t i = 0; i < column_size; ++i) { all_columns.push_back(i); } + SCOPED_RAW_TIMER(&_jdbc_statistic._fill_block_timer); Status fill_block_status = JniConnector::fill_block(block, all_columns, address); if (!fill_block_status) { return fill_block_status; diff --git a/be/src/vec/exec/vjdbc_connector.h b/be/src/vec/exec/vjdbc_connector.h index 02da0587f7..a62e5e6efa 100644 --- a/be/src/vec/exec/vjdbc_connector.h +++ b/be/src/vec/exec/vjdbc_connector.h @@ -64,8 +64,8 @@ public: int64_t _load_jar_timer = 0; int64_t _init_connector_timer = 0; int64_t _get_data_timer = 0; - int64_t _call_jni_next_timer = 0; - int64_t _convert_batch_timer = 0; + int64_t _get_block_address_timer = 0; + int64_t _fill_block_timer = 0; int64_t _check_type_timer = 0; int64_t _execte_read_timer = 0; int64_t _connector_close_timer = 0;