This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.1 by this push:
new 4750b1c988f branch-4.1: [improve](profile) Skip _init_profile in
load_v1 when enable_profile is false #61131 (#62801)
4750b1c988f is described below
commit 4750b1c988fd6acca403f2211c6882941f74d902
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Sep 29 10:00:41 2026 +0800
branch-4.1: [improve](profile) Skip _init_profile in load_v1 when
enable_profile is false #61131 (#62801)
Cherry-picked from #61131
Co-authored-by: 黄瑞鑫 <[email protected]>
---
be/src/cloud/cloud_tablets_channel.cpp | 4 +++-
be/src/load/channel/load_channel.cpp | 19 ++++++++++++++-----
be/src/load/channel/tablets_channel.cpp | 10 ++++++++--
be/src/load/delta_writer/delta_writer.cpp | 6 +++++-
be/src/load/memtable/memtable_writer.cpp | 3 +++
be/src/storage/rowset_builder.cpp | 6 +++++-
6 files changed, 38 insertions(+), 10 deletions(-)
diff --git a/be/src/cloud/cloud_tablets_channel.cpp
b/be/src/cloud/cloud_tablets_channel.cpp
index 7b74e9b1e07..3efedcc6b16 100644
--- a/be/src/cloud/cloud_tablets_channel.cpp
+++ b/be/src/cloud/cloud_tablets_channel.cpp
@@ -46,7 +46,9 @@ Status CloudTabletsChannel::add_batch(const
PTabletWriterAddBlockRequest& reques
// FIXME(plat1ko): Too many duplicate code with `TabletsChannel`
SCOPED_TIMER(_add_batch_timer);
int64_t cur_seq = 0;
- _add_batch_number_counter->update(1);
+ if (_add_batch_number_counter != nullptr) {
+ _add_batch_number_counter->update(1);
+ }
auto status = _get_current_seq(cur_seq, request);
if (UNLIKELY(!status.ok())) {
diff --git a/be/src/load/channel/load_channel.cpp
b/be/src/load/channel/load_channel.cpp
index 4a76d1a5697..1b6af15240c 100644
--- a/be/src/load/channel/load_channel.cpp
+++ b/be/src/load/channel/load_channel.cpp
@@ -72,7 +72,9 @@ LoadChannel::LoadChannel(const UniqueId& load_id, int64_t
timeout_s, bool is_hig
// _load_channels in load_channel_mgr, or it may be erased
// immediately by gc thread.
_last_updated_time.store(time(nullptr));
- _init_profile();
+ if (enable_profile) {
+ _init_profile();
+ }
}
LoadChannel::~LoadChannel() {
@@ -88,6 +90,7 @@ LoadChannel::~LoadChannel() {
}
void LoadChannel::_init_profile() {
+ DCHECK(_enable_profile);
_profile = std::make_unique<RuntimeProfile>("LoadChannels");
_mgr_add_batch_timer = ADD_TIMER(_profile, "LoadChannelMgrAddBatchTime");
_handle_mem_limit_timer = ADD_TIMER(_profile, "HandleMemLimitTime");
@@ -179,7 +182,9 @@ Status LoadChannel::add_batch(const
PTabletWriterAddBlockRequest& request,
DBUG_EXECUTE_IF("LoadChannel.add_batch.failed",
{ return Status::InternalError("fault injection"); });
SCOPED_TIMER(_add_batch_timer);
- COUNTER_UPDATE(_add_batch_times, 1);
+ if (_enable_profile) {
+ COUNTER_UPDATE(_add_batch_times, 1);
+ }
SCOPED_ATTACH_TASK(_resource_ctx);
int64_t index_id = request.index_id();
// 1. get tablets channel
@@ -193,7 +198,9 @@ Status LoadChannel::add_batch(const
PTabletWriterAddBlockRequest& request,
// 2. add block to tablets channel
if (request.has_block()) {
RETURN_IF_ERROR(channel->add_batch(request, response));
- _add_batch_number_counter->update(1);
+ if (_enable_profile) {
+ _add_batch_number_counter->update(1);
+ }
}
// 3. handle eos
@@ -204,7 +211,7 @@ Status LoadChannel::add_batch(const
PTabletWriterAddBlockRequest& request,
if (!st.ok()) {
return st;
}
- } else if (_add_batch_number_counter->value() % 100 == 1) {
+ } else if (_enable_profile && _add_batch_number_counter->value() % 100 ==
1) {
_report_profile(response);
}
_last_updated_time.store(time(nullptr));
@@ -214,7 +221,9 @@ Status LoadChannel::add_batch(const
PTabletWriterAddBlockRequest& request,
Status LoadChannel::_handle_eos(BaseTabletsChannel* channel,
const PTabletWriterAddBlockRequest& request,
PTabletWriterAddBlockResult* response) {
- _self_profile->add_info_string("EosHost", fmt::format("{}",
request.backend_id()));
+ if (_enable_profile) {
+ _self_profile->add_info_string("EosHost", fmt::format("{}",
request.backend_id()));
+ }
bool finished = false;
auto index_id = request.index_id();
diff --git a/be/src/load/channel/tablets_channel.cpp
b/be/src/load/channel/tablets_channel.cpp
index 10ffb91ed1e..708ca52bff0 100644
--- a/be/src/load/channel/tablets_channel.cpp
+++ b/be/src/load/channel/tablets_channel.cpp
@@ -66,7 +66,9 @@ BaseTabletsChannel::BaseTabletsChannel(const
TabletsChannelKey& key, const Uniqu
_closed_senders(64),
_is_high_priority(is_high_priority) {
static std::once_flag once_flag;
- _init_profile(profile);
+ if (profile != nullptr) {
+ _init_profile(profile);
+ }
std::call_once(once_flag, [] {
REGISTER_HOOK_METRIC(tablet_writer_count, [&]() { return
_s_tablet_writer_count.load(); });
});
@@ -102,6 +104,7 @@ Status BaseTabletsChannel::_get_current_seq(int64_t&
cur_seq,
}
void BaseTabletsChannel::_init_profile(RuntimeProfile* profile) {
+ DCHECK(profile != nullptr);
_profile =
profile->create_child(fmt::format("TabletsChannel {}",
_key.to_string()), true, true);
_add_batch_number_counter = ADD_COUNTER(_profile, "NumberBatchAdded",
TUnit::UNIT);
@@ -122,6 +125,7 @@ void BaseTabletsChannel::_init_profile(RuntimeProfile*
profile) {
}
void TabletsChannel::_init_profile(RuntimeProfile* profile) {
+ DCHECK(profile != nullptr);
BaseTabletsChannel::_init_profile(profile);
_slave_replica_timer = ADD_TIMER(_profile, "SlaveReplicaTime");
}
@@ -847,7 +851,9 @@ Status TabletsChannel::add_batch(const
PTabletWriterAddBlockRequest& request,
PTabletWriterAddBlockResult* response) {
SCOPED_TIMER(_add_batch_timer);
int64_t cur_seq = 0;
- _add_batch_number_counter->update(1);
+ if (_add_batch_number_counter) {
+ _add_batch_number_counter->update(1);
+ }
auto status = _get_current_seq(cur_seq, request);
if (UNLIKELY(!status.ok())) {
diff --git a/be/src/load/delta_writer/delta_writer.cpp
b/be/src/load/delta_writer/delta_writer.cpp
index 16aae6bb0ca..184f22f9624 100644
--- a/be/src/load/delta_writer/delta_writer.cpp
+++ b/be/src/load/delta_writer/delta_writer.cpp
@@ -64,7 +64,9 @@ using namespace ErrorCode;
BaseDeltaWriter::BaseDeltaWriter(const WriteRequest& req, RuntimeProfile*
profile,
const UniqueId& load_id)
: _req(req), _memtable_writer(new MemTableWriter(req)) {
- _init_profile(profile);
+ if (profile != nullptr) {
+ _init_profile(profile);
+ }
}
DeltaWriter::DeltaWriter(StorageEngine& engine, const WriteRequest& req,
RuntimeProfile* profile,
@@ -74,12 +76,14 @@ DeltaWriter::DeltaWriter(StorageEngine& engine, const
WriteRequest& req, Runtime
}
void BaseDeltaWriter::_init_profile(RuntimeProfile* profile) {
+ DCHECK(profile != nullptr);
_profile = profile->create_child(fmt::format("DeltaWriter {}",
_req.tablet_id), true, true);
_close_wait_timer = ADD_TIMER(_profile, "CloseWaitTime");
_wait_flush_limit_timer = ADD_TIMER(_profile, "WaitFlushLimitTime");
}
void DeltaWriter::_init_profile(RuntimeProfile* profile) {
+ DCHECK(profile != nullptr);
BaseDeltaWriter::_init_profile(profile);
_commit_txn_timer = ADD_TIMER(_profile, "CommitTxnTime");
}
diff --git a/be/src/load/memtable/memtable_writer.cpp
b/be/src/load/memtable/memtable_writer.cpp
index d0edf0bf6dc..a000206990b 100644
--- a/be/src/load/memtable/memtable_writer.cpp
+++ b/be/src/load/memtable/memtable_writer.cpp
@@ -303,6 +303,9 @@ Status MemTableWriter::_do_close_wait() {
}
void MemTableWriter::_update_profile(RuntimeProfile* profile) {
+ if (!profile) {
+ return;
+ }
// NOTE: MemTableWriter may be accessed when profile is out of scope, in
MemTableMemoryLimiter.
// To avoid accessing dangling pointers, we cannot make profile as a
member of MemTableWriter.
auto child =
diff --git a/be/src/storage/rowset_builder.cpp
b/be/src/storage/rowset_builder.cpp
index c62ccfd6f6d..3db62d12dd9 100644
--- a/be/src/storage/rowset_builder.cpp
+++ b/be/src/storage/rowset_builder.cpp
@@ -66,7 +66,9 @@ using namespace ErrorCode;
BaseRowsetBuilder::BaseRowsetBuilder(const WriteRequest& req, RuntimeProfile*
profile)
: _req(req), _tablet_schema(std::make_shared<TabletSchema>()) {
- _init_profile(profile);
+ if (profile != nullptr) {
+ _init_profile(profile);
+ }
}
RowsetBuilder::RowsetBuilder(StorageEngine& engine, const WriteRequest& req,
@@ -74,6 +76,7 @@ RowsetBuilder::RowsetBuilder(StorageEngine& engine, const
WriteRequest& req,
: BaseRowsetBuilder(req, profile), _engine(engine) {}
void BaseRowsetBuilder::_init_profile(RuntimeProfile* profile) {
+ DCHECK(profile != nullptr);
_profile = profile->create_child(fmt::format("RowsetBuilder {}",
_req.tablet_id), true, true);
_build_rowset_timer = ADD_TIMER(_profile, "BuildRowsetTime");
_submit_delete_bitmap_timer = ADD_TIMER(_profile,
"DeleteBitmapSubmitTime");
@@ -81,6 +84,7 @@ void BaseRowsetBuilder::_init_profile(RuntimeProfile*
profile) {
}
void RowsetBuilder::_init_profile(RuntimeProfile* profile) {
+ DCHECK(profile != nullptr);
BaseRowsetBuilder::_init_profile(profile);
_commit_txn_timer = ADD_TIMER(_profile, "CommitTxnTime");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]