This is an automated email from the ASF dual-hosted git repository.
lihaopeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new bb3205c4931 [Improvement](scanner) Include open() time in
PerScannerRunningTime (#61042)
bb3205c4931 is described below
commit bb3205c493198002cb8f2eee6b777ea972435a2c
Author: HappenLee <[email protected]>
AuthorDate: Fri Mar 6 13:18:51 2026 +0800
[Improvement](scanner) Include open() time in PerScannerRunningTime (#61042)
Use NVI (Non-Virtual Interface) pattern for Scanner::open(), similar to
Scanner::get_block() / _get_block_impl(). Add SCOPED_RAW_TIMER in the
base class open() method to include scanner initialization time
(ReaderInitTime, BlockReaderBuildHeapInitTimer, etc.) in
PerScannerRunningTime profile counter.
This fixes the issue where PerScannerRunningTime showed only
microseconds while ReaderInitTime showed several seconds, making the
profile misleading.
Changes:
- scanner.h: Change open() to non-virtual NVI, add _open_impl() virtual
- 5 subclasses: Rename open() to _open_impl() and call
base::_open_impl() (OlapScanner, FileScanner, MetaScanner, JdbcScanner,
EsScanner)
---
be/src/vec/exec/scan/es_scanner.cpp | 4 ++--
be/src/vec/exec/scan/es_scanner.h | 2 +-
be/src/vec/exec/scan/file_scanner.cpp | 4 ++--
be/src/vec/exec/scan/file_scanner.h | 2 +-
be/src/vec/exec/scan/jdbc_scanner.cpp | 4 ++--
be/src/vec/exec/scan/jdbc_scanner.h | 2 +-
be/src/vec/exec/scan/meta_scanner.cpp | 4 ++--
be/src/vec/exec/scan/meta_scanner.h | 2 +-
be/src/vec/exec/scan/olap_scanner.cpp | 4 ++--
be/src/vec/exec/scan/olap_scanner.h | 2 +-
be/src/vec/exec/scan/scanner.h | 12 +++++++++---
11 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/be/src/vec/exec/scan/es_scanner.cpp
b/be/src/vec/exec/scan/es_scanner.cpp
index 224ba085f03..464ded65c68 100644
--- a/be/src/vec/exec/scan/es_scanner.cpp
+++ b/be/src/vec/exec/scan/es_scanner.cpp
@@ -78,7 +78,7 @@ Status EsScanner::init(RuntimeState* state, const
VExprContextSPtrs& conjuncts)
return Status::OK();
}
-Status EsScanner::open(RuntimeState* state) {
+Status EsScanner::_open_impl(RuntimeState* state) {
VLOG_CRITICAL << NEW_SCANNER_TYPE << "::open";
if (nullptr == state) {
@@ -90,7 +90,7 @@ Status EsScanner::open(RuntimeState* state) {
}
RETURN_IF_CANCELLED(state);
- RETURN_IF_ERROR(Scanner::open(state));
+ RETURN_IF_ERROR(Scanner::_open_impl(state));
RETURN_IF_ERROR(_es_reader->open());
diff --git a/be/src/vec/exec/scan/es_scanner.h
b/be/src/vec/exec/scan/es_scanner.h
index 05ee6663baa..14c2b017f24 100644
--- a/be/src/vec/exec/scan/es_scanner.h
+++ b/be/src/vec/exec/scan/es_scanner.h
@@ -54,7 +54,7 @@ public:
const std::map<std::string, std::string>& docvalue_context, bool
doc_value_mode,
RuntimeProfile* profile);
- Status open(RuntimeState* state) override;
+ Status _open_impl(RuntimeState* state) override;
Status close(RuntimeState* state) override;
Status init(RuntimeState* state, const VExprContextSPtrs& conjuncts)
override;
diff --git a/be/src/vec/exec/scan/file_scanner.cpp
b/be/src/vec/exec/scan/file_scanner.cpp
index 97c622cedc2..fdca7b1957f 100644
--- a/be/src/vec/exec/scan/file_scanner.cpp
+++ b/be/src/vec/exec/scan/file_scanner.cpp
@@ -379,9 +379,9 @@ void FileScanner::_get_slot_ids(VExpr* expr,
std::vector<int>* slot_ids) {
}
}
-Status FileScanner::open(RuntimeState* state) {
+Status FileScanner::_open_impl(RuntimeState* state) {
RETURN_IF_CANCELLED(state);
- RETURN_IF_ERROR(Scanner::open(state));
+ RETURN_IF_ERROR(Scanner::_open_impl(state));
RETURN_IF_ERROR(_split_source->get_next(&_first_scan_range,
&_current_range));
if (_first_scan_range) {
RETURN_IF_ERROR(_init_expr_ctxes());
diff --git a/be/src/vec/exec/scan/file_scanner.h
b/be/src/vec/exec/scan/file_scanner.h
index 24c5d0d03b0..f42cf4c0372 100644
--- a/be/src/vec/exec/scan/file_scanner.h
+++ b/be/src/vec/exec/scan/file_scanner.h
@@ -70,7 +70,7 @@ public:
RuntimeProfile* profile, ShardedKVCache* kv_cache,
const std::unordered_map<std::string, int>*
colname_to_slot_id);
- Status open(RuntimeState* state) override;
+ Status _open_impl(RuntimeState* state) override;
Status close(RuntimeState* state) override;
diff --git a/be/src/vec/exec/scan/jdbc_scanner.cpp
b/be/src/vec/exec/scan/jdbc_scanner.cpp
index dc26f103a64..dcbee91827e 100644
--- a/be/src/vec/exec/scan/jdbc_scanner.cpp
+++ b/be/src/vec/exec/scan/jdbc_scanner.cpp
@@ -101,7 +101,7 @@ Status JdbcScanner::init(RuntimeState* state, const
VExprContextSPtrs& conjuncts
return Status::OK();
}
-Status JdbcScanner::open(RuntimeState* state) {
+Status JdbcScanner::_open_impl(RuntimeState* state) {
VLOG_CRITICAL << "JdbcScanner::open";
if (state == nullptr) {
return Status::InternalError("input pointer is NULL of
VJdbcScanNode::open.");
@@ -111,7 +111,7 @@ Status JdbcScanner::open(RuntimeState* state) {
return Status::InternalError("used before initialize of
VJdbcScanNode::open.");
}
RETURN_IF_CANCELLED(state);
- RETURN_IF_ERROR(Scanner::open(state));
+ RETURN_IF_ERROR(Scanner::_open_impl(state));
RETURN_IF_ERROR(_jdbc_connector->open(state, true));
RETURN_IF_ERROR(_jdbc_connector->query());
return Status::OK();
diff --git a/be/src/vec/exec/scan/jdbc_scanner.h
b/be/src/vec/exec/scan/jdbc_scanner.h
index 31f7b9abee3..f19d8f9098d 100644
--- a/be/src/vec/exec/scan/jdbc_scanner.h
+++ b/be/src/vec/exec/scan/jdbc_scanner.h
@@ -48,7 +48,7 @@ public:
JdbcScanner(RuntimeState* state, doris::pipeline::JDBCScanLocalState*
parent, int64_t limit,
const TupleId& tuple_id, const std::string& query_string,
TOdbcTableType::type table_type, bool is_tvf, RuntimeProfile*
profile);
- Status open(RuntimeState* state) override;
+ Status _open_impl(RuntimeState* state) override;
Status close(RuntimeState* state) override;
Status init(RuntimeState* state, const VExprContextSPtrs& conjuncts)
override;
diff --git a/be/src/vec/exec/scan/meta_scanner.cpp
b/be/src/vec/exec/scan/meta_scanner.cpp
index 6031c72b07c..a90a6a98cda 100644
--- a/be/src/vec/exec/scan/meta_scanner.cpp
+++ b/be/src/vec/exec/scan/meta_scanner.cpp
@@ -64,9 +64,9 @@ MetaScanner::MetaScanner(RuntimeState* state,
pipeline::ScanLocalStateBase* loca
_user_identity(user_identity),
_scan_range(scan_range.scan_range) {}
-Status MetaScanner::open(RuntimeState* state) {
+Status MetaScanner::_open_impl(RuntimeState* state) {
VLOG_CRITICAL << "MetaScanner::open";
- RETURN_IF_ERROR(Scanner::open(state));
+ RETURN_IF_ERROR(Scanner::_open_impl(state));
if (_scan_range.meta_scan_range.metadata_type == TMetadataType::ICEBERG) {
// TODO: refactor this code
auto reader =
IcebergSysTableJniReader::create_unique(_tuple_desc->slots(), state, _profile,
diff --git a/be/src/vec/exec/scan/meta_scanner.h
b/be/src/vec/exec/scan/meta_scanner.h
index 8d62ef95bd2..1ea3b0f5d48 100644
--- a/be/src/vec/exec/scan/meta_scanner.h
+++ b/be/src/vec/exec/scan/meta_scanner.h
@@ -54,7 +54,7 @@ public:
const TScanRangeParams& scan_range, int64_t limit,
RuntimeProfile* profile,
TUserIdentity user_identity);
- Status open(RuntimeState* state) override;
+ Status _open_impl(RuntimeState* state) override;
Status close(RuntimeState* state) override;
Status init(RuntimeState* state, const VExprContextSPtrs& conjuncts)
override;
diff --git a/be/src/vec/exec/scan/olap_scanner.cpp
b/be/src/vec/exec/scan/olap_scanner.cpp
index 48e7ac34d85..729fa755611 100644
--- a/be/src/vec/exec/scan/olap_scanner.cpp
+++ b/be/src/vec/exec/scan/olap_scanner.cpp
@@ -306,8 +306,8 @@ Status OlapScanner::prepare() {
return Status::OK();
}
-Status OlapScanner::open(RuntimeState* state) {
- RETURN_IF_ERROR(Scanner::open(state));
+Status OlapScanner::_open_impl(RuntimeState* state) {
+ RETURN_IF_ERROR(Scanner::_open_impl(state));
SCOPED_TIMER(_local_state->cast<pipeline::OlapScanLocalState>()._reader_init_timer);
auto res = _tablet_reader->init(_tablet_reader_params);
diff --git a/be/src/vec/exec/scan/olap_scanner.h
b/be/src/vec/exec/scan/olap_scanner.h
index 4b8d866ba25..8870cc9d7a1 100644
--- a/be/src/vec/exec/scan/olap_scanner.h
+++ b/be/src/vec/exec/scan/olap_scanner.h
@@ -75,7 +75,7 @@ public:
Status prepare() override;
- Status open(RuntimeState* state) override;
+ Status _open_impl(RuntimeState* state) override;
Status close(RuntimeState* state) override;
diff --git a/be/src/vec/exec/scan/scanner.h b/be/src/vec/exec/scan/scanner.h
index 88b51f7d915..8d5682eb82c 100644
--- a/be/src/vec/exec/scan/scanner.h
+++ b/be/src/vec/exec/scan/scanner.h
@@ -79,9 +79,10 @@ public:
_has_prepared = true;
return Status::OK();
}
- virtual Status open(RuntimeState* state) {
- _block_avg_bytes = state->batch_size() * 8;
- return Status::OK();
+
+ Status open(RuntimeState* state) {
+ SCOPED_RAW_TIMER(&_per_scanner_timer);
+ return _open_impl(state);
}
Status get_block(RuntimeState* state, Block* block, bool* eos);
@@ -99,6 +100,11 @@ public:
virtual std::string get_current_scan_range_name() { return "not
implemented"; }
protected:
+ virtual Status _open_impl(RuntimeState* state) {
+ _block_avg_bytes = state->batch_size() * 8;
+ return Status::OK();
+ }
+
// Subclass should implement this to return data.
virtual Status _get_block_impl(RuntimeState* state, Block* block, bool*
eof) = 0;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]