@@ -72,7 +72,9 @@ LoadChannel::LoadChannel(const UniqueId& load_id, int64_t timeout_s, bool is_hig
7272 // _load_channels in load_channel_mgr, or it may be erased
7373 // immediately by gc thread.
7474 _last_updated_time.store (time (nullptr ));
75- _init_profile ();
75+ if (enable_profile) {
76+ _init_profile ();
77+ }
7678}
7779
7880LoadChannel::~LoadChannel () {
@@ -88,6 +90,7 @@ LoadChannel::~LoadChannel() {
8890}
8991
9092void LoadChannel::_init_profile () {
93+ DCHECK (_enable_profile);
9194 _profile = std::make_unique<RuntimeProfile>(" LoadChannels" );
9295 _mgr_add_batch_timer = ADD_TIMER (_profile, " LoadChannelMgrAddBatchTime" );
9396 _handle_mem_limit_timer = ADD_TIMER (_profile, " HandleMemLimitTime" );
@@ -179,7 +182,9 @@ Status LoadChannel::add_batch(const PTabletWriterAddBlockRequest& request,
179182 DBUG_EXECUTE_IF (" LoadChannel.add_batch.failed" ,
180183 { return Status::InternalError (" fault injection" ); });
181184 SCOPED_TIMER (_add_batch_timer);
182- COUNTER_UPDATE (_add_batch_times, 1 );
185+ if (_enable_profile) {
186+ COUNTER_UPDATE (_add_batch_times, 1 );
187+ }
183188 SCOPED_ATTACH_TASK (_resource_ctx);
184189 int64_t index_id = request.index_id ();
185190 // 1. get tablets channel
@@ -193,7 +198,9 @@ Status LoadChannel::add_batch(const PTabletWriterAddBlockRequest& request,
193198 // 2. add block to tablets channel
194199 if (request.has_block ()) {
195200 RETURN_IF_ERROR (channel->add_batch (request, response));
196- _add_batch_number_counter->update (1 );
201+ if (_enable_profile) {
202+ _add_batch_number_counter->update (1 );
203+ }
197204 }
198205
199206 // 3. handle eos
@@ -204,7 +211,7 @@ Status LoadChannel::add_batch(const PTabletWriterAddBlockRequest& request,
204211 if (!st.ok ()) {
205212 return st;
206213 }
207- } else if (_add_batch_number_counter->value () % 100 == 1 ) {
214+ } else if (_enable_profile && _add_batch_number_counter->value () % 100 == 1 ) {
208215 _report_profile (response);
209216 }
210217 _last_updated_time.store (time (nullptr ));
@@ -214,7 +221,9 @@ Status LoadChannel::add_batch(const PTabletWriterAddBlockRequest& request,
214221Status LoadChannel::_handle_eos (BaseTabletsChannel* channel,
215222 const PTabletWriterAddBlockRequest& request,
216223 PTabletWriterAddBlockResult* response) {
217- _self_profile->add_info_string (" EosHost" , fmt::format (" {}" , request.backend_id ()));
224+ if (_enable_profile) {
225+ _self_profile->add_info_string (" EosHost" , fmt::format (" {}" , request.backend_id ()));
226+ }
218227 bool finished = false ;
219228 auto index_id = request.index_id ();
220229
0 commit comments