revision-id: 1ec5d0e1234f8deda4d135e2d48d0ed7406ea513 (v5.8-3393-g1ec5d0e12) parent(s): 0f8c041ea7bb458caa5ec0dbeef9fa42d0b97482 author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2021-06-14 22:14:24 +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();