You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by da...@apache.org on 2024/09/03 08:13:34 UTC

(doris) 09/11: [Fix](load) Lower lock granularity to reduce loading CPU pressure (#40134)

This is an automated email from the ASF dual-hosted git repository.

dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 6d4eb9b7e0fff249b33c0e96cecd83eb3260095d
Author: zclllhhjj <zh...@selectdb.com>
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: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org