This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push: new 6fb91777b3 [performance](load) remove unnecessary lock in TabletsChannel::add_batch (#22703) (#22843) 6fb91777b3 is described below commit 6fb91777b3a1ba861adb541b9a326158fbdde5d9 Author: Kaijie Chen <c...@apache.org> AuthorDate: Thu Aug 10 18:59:01 2023 +0800 [performance](load) remove unnecessary lock in TabletsChannel::add_batch (#22703) (#22843) This lock was introduced by lazy open in #18874. It's unnecessary and costly to hold a lock while writing data to DeltaWriter in the first place. However, since lazy open is reverted in #21821, we can completely omit this lock. _tablet_writers is not supposed to be changed once we've reached TabletsChannel::add_batch. --- be/src/runtime/tablets_channel.cpp | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/be/src/runtime/tablets_channel.cpp b/be/src/runtime/tablets_channel.cpp index 134cba2ae5..fb35c57a9a 100644 --- a/be/src/runtime/tablets_channel.cpp +++ b/be/src/runtime/tablets_channel.cpp @@ -473,26 +473,23 @@ Status TabletsChannel::add_batch(const PTabletWriterAddBlockRequest& request, std::function<Status(DeltaWriter * writer)> write_func) { google::protobuf::RepeatedPtrField<PTabletError>* tablet_errors = response->mutable_tablet_errors(); - { - std::lock_guard<SpinLock> l(_tablet_writers_lock); - auto tablet_writer_it = _tablet_writers.find(tablet_id); - if (tablet_writer_it == _tablet_writers.end()) { - return Status::InternalError("unknown tablet to append data, tablet={}", tablet_id); - } - Status st = write_func(tablet_writer_it->second); - if (!st.ok()) { - auto err_msg = - fmt::format("tablet writer write failed, tablet_id={}, txn_id={}, err={}", - tablet_id, _txn_id, st.to_string()); - LOG(WARNING) << err_msg; - PTabletError* error = tablet_errors->Add(); - error->set_tablet_id(tablet_id); - error->set_msg(err_msg); - tablet_writer_it->second->cancel_with_status(st); - _add_broken_tablet(tablet_id); - // continue write to other tablet. - // the error will return back to sender. - } + auto tablet_writer_it = _tablet_writers.find(tablet_id); + if (tablet_writer_it == _tablet_writers.end()) { + return Status::InternalError("unknown tablet to append data, tablet={}", tablet_id); + } + Status st = write_func(tablet_writer_it->second); + if (!st.ok()) { + auto err_msg = + fmt::format("tablet writer write failed, tablet_id={}, txn_id={}, err={}", + tablet_id, _txn_id, st.to_string()); + LOG(WARNING) << err_msg; + PTabletError* error = tablet_errors->Add(); + error->set_tablet_id(tablet_id); + error->set_msg(err_msg); + tablet_writer_it->second->cancel_with_status(st); + _add_broken_tablet(tablet_id); + // continue write to other tablet. + // the error will return back to sender. } return Status::OK(); }; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org