[Commits] a6f155555: Basic return-early optimization in RangeTreeLockManager::TryLock

psergey sergey at mariadb.com
Mon Nov 8 21:01:23 EET 2021


revision-id: a6f155555ce451d855ab4617cf7bc00991ac2c62 (v5.8-3686-ga6f155555)
parent(s): c04a86a0e9a28ef3e02d5fe74928dfd5e8fdd910
author: Sergei Petrunia
committer: Sergei Petrunia
timestamp: 2021-11-08 22:01:23 +0300
message:

Basic return-early optimization in RangeTreeLockManager::TryLock

Do not call lock_request::wait when lock acquisition has succeeded.

---
 .../lock/range/range_tree/range_tree_lock_manager.cc           | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/utilities/transactions/lock/range/range_tree/range_tree_lock_manager.cc b/utilities/transactions/lock/range/range_tree/range_tree_lock_manager.cc
index 6dfb78d3f..55a66bc59 100644
--- a/utilities/transactions/lock/range/range_tree/range_tree_lock_manager.cc
+++ b/utilities/transactions/lock/range/range_tree/range_tree_lock_manager.cc
@@ -115,11 +115,13 @@ Status RangeTreeLockManager::TryLock(PessimisticTransaction* txn,
                        std::move(end)});
   };
 
-  request.start();
+  int r = request.start();
 
-  const int r = request.wait(wait_time_msec, killed_time_msec,
-                             nullptr,  // killed_callback
-                             wait_callback_for_locktree, nullptr);
+  if (r) {
+    r = request.wait(wait_time_msec, killed_time_msec,
+                     nullptr,  // killed_callback
+                     wait_callback_for_locktree, nullptr);
+  }
 
   // Inform the txn that we are no longer waiting:
   txn->ClearWaitingTxn();


More information about the commits mailing list