This is an automated email from the ASF dual-hosted git repository.
yiguolei 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 eae7cf0e991 [Fix](load) Lower lock granularity to reduce loading CPU
pressure (#40134)
eae7cf0e991 is described below
commit eae7cf0e991fa3dd54d4fbf7803edd398f8df5e6
Author: zclllhhjj <[email protected]>
AuthorDate: Thu Aug 29 23:52:05 2024 +0800
[Fix](load) Lower lock granularity to reduce loading CPU pressure (#40134)
## Proposed changes
Issue Number: close #xxx
before when writing block, we have a lock to protect the whole process.
now reduced it
---
be/src/runtime/tablets_channel.cpp | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/be/src/runtime/tablets_channel.cpp
b/be/src/runtime/tablets_channel.cpp
index eac9693d839..329366766f8 100644
--- a/be/src/runtime/tablets_channel.cpp
+++ b/be/src/runtime/tablets_channel.cpp
@@ -582,12 +582,15 @@ Status BaseTabletsChannel::_write_block_data(
// add_batch may concurrency with inc_open but not under _lock.
// so need to protect it with _tablet_writers_lock.
- 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);
+ decltype(_tablet_writers.find(tablet_id)) tablet_writer_it;
+ {
+ std::lock_guard<SpinLock> l(_tablet_writers_lock);
+ 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.get());
if (!st.ok()) {
auto err_msg =
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]