You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by al...@apache.org on 2020/03/20 22:55:45 UTC
[kudu] 01/03: tserver: avoid spinlock in scanners hot path
This is an automated email from the ASF dual-hosted git repository.
alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
commit 9d2ae8b2114f0add8e63c6ccd63ac0b9a49079d6
Author: Todd Lipcon <to...@apache.org>
AuthorDate: Mon Mar 2 23:12:37 2020 -0800
tserver: avoid spinlock in scanners hot path
This replaces a spinlock protection of the scanner "rows_returned"
counter to just be an atomic integer instead. This saved some CPU cycles
in the TSBS benchmark.
Change-Id: If3c32e94ada847076580e20571440833a8544c57
Reviewed-on: http://gerrit.cloudera.org:8080/15502
Reviewed-by: Adar Dembo <ad...@cloudera.com>
Tested-by: Kudu Jenkins
---
src/kudu/tserver/scanners.h | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/kudu/tserver/scanners.h b/src/kudu/tserver/scanners.h
index b30bcb9..5f81763 100644
--- a/src/kudu/tserver/scanners.h
+++ b/src/kudu/tserver/scanners.h
@@ -16,6 +16,7 @@
// under the License.
#pragma once
+#include <atomic>
#include <cstddef>
#include <cstdint>
#include <memory>
@@ -299,13 +300,11 @@ class Scanner {
}
void add_num_rows_returned(int64_t num_rows_added) {
- std::lock_guard<simple_spinlock> l(lock_);
num_rows_returned_ += num_rows_added;
DCHECK_LE(num_rows_added, num_rows_returned_);
}
int64_t num_rows_returned() const {
- std::lock_guard<simple_spinlock> l(lock_);
return num_rows_returned_;
}
@@ -347,8 +346,7 @@ class Scanner {
// The current call sequence ID.
uint32_t call_seq_id_;
- // Protects last_access_time_ call_seq_id_, iter_, spec_, and
- // num_rows_returned_.
+ // Protects last_access_time_ call_seq_id_, iter_, spec_
mutable simple_spinlock lock_;
// The time the scanner was started.
@@ -383,7 +381,7 @@ class Scanner {
// The number of rows that have been serialized and sent over the wire by
// this scanner.
- int64_t num_rows_returned_;
+ std::atomic<int64_t> num_rows_returned_;
// The cumulative amounts of wall, user cpu, and system cpu time spent on
// this scanner, in seconds.