kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [3/3] incubator-kudu git commit: cbtree: some optimizations to make back ground since gcc 4.4
Date Fri, 22 Jan 2016 01:19:05 GMT
cbtree: some optimizations to make back ground since gcc 4.4

Benchmarks indicated that cbtree-test got slower when we upgraded to gcc
4.9:

4.4 (pre-C++11):
I0120 14:04:21.391079  1982 cbtree-test.cc:730] Time spent Insert 4000000 keys: real 2.934s
    user 2.868s     sys 0.064s
I0120 14:04:25.186092  1982 cbtree-test.cc:730] Time spent Insert 4000000 keys: real 2.856s
    user 2.852s     sys 0.004s
I0120 14:04:28.971114  1982 cbtree-test.cc:730] Time spent Insert 4000000 keys: real 2.852s
    user 2.856s     sys 0.000s
I0120 14:04:32.786329  1982 cbtree-test.cc:730] Time spent Insert 4000000 keys: real 2.851s
    user 2.856s     sys 0.000s
I0120 14:04:36.601415  1982 cbtree-test.cc:730] Time spent Insert 4000000 keys: real 2.850s
    user 2.852s     sys 0.000s

4.9.3 (C++11):
I0120 14:31:10.460209  9809 cbtree-test.cc:732] Time spent Insert 4000000 keys: real 3.266s
    user 3.212s     sys 0.028s
I0120 14:31:14.625602  9809 cbtree-test.cc:732] Time spent Insert 4000000 keys: real 3.191s
    user 3.168s     sys 0.000s
I0120 14:31:18.799840  9809 cbtree-test.cc:732] Time spent Insert 4000000 keys: real 3.199s
    user 3.176s     sys 0.004s
I0120 14:31:23.010079  9809 cbtree-test.cc:732] Time spent Insert 4000000 keys: real 3.198s
    user 3.180s     sys 0.000s
I0120 14:31:27.220559  9809 cbtree-test.cc:732] Time spent Insert 4000000 keys: real 3.198s
    user 3.172s     sys 0.004s
I0120 14:31:31.434557  9809 cbtree-test.cc:732] Time spent Insert 4000000 keys: real 3.203s
    user 3.184s     sys 0.000s
I0120 14:31:35.648149  9809 cbtree-test.cc:732] Time spent Insert 4000000 keys: real 3.201s
    user 3.176s     sys 0.004s

Looking at the new assembly code, I found a few easy improvements to win back
some of the performance. With this patch:

I0120 14:31:59.956502  9851 cbtree-test.cc:732] Time spent Insert 4000000 keys: real 3.188s
    user 3.120s     sys 0.044s
I0120 14:32:04.061563  9851 cbtree-test.cc:732] Time spent Insert 4000000 keys: real 3.125s
    user 3.104s     sys 0.000s
I0120 14:32:08.173352  9851 cbtree-test.cc:732] Time spent Insert 4000000 keys: real 3.136s
    user 3.104s     sys 0.012s
I0120 14:32:12.290326  9851 cbtree-test.cc:732] Time spent Insert 4000000 keys: real 3.141s
    user 3.116s     sys 0.004s
I0120 14:32:16.396093  9851 cbtree-test.cc:732] Time spent Insert 4000000 keys: real 3.131s
    user 3.104s     sys 0.004s
I0120 14:32:20.510488  9851 cbtree-test.cc:732] Time spent Insert 4000000 keys: real 3.141s
    user 3.120s     sys 0.000s
I0120 14:32:24.769479  9851 cbtree-test.cc:732] Time spent Insert 4000000 keys: real 3.278s
    user 3.256s     sys 0.000s
I0120 14:32:28.866739  9851 cbtree-test.cc:732] Time spent Insert 4000000 keys: real 3.125s
    user 3.104s     sys 0.000s
I0120 14:32:33.185539  9851 cbtree-test.cc:732] Time spent Insert 4000000 keys: real 3.346s
    user 3.320s     sys 0.000s
I0120 14:32:37.284078  9851 cbtree-test.cc:732] Time spent Insert 4000000 keys: real 3.124s
    user 3.120s     sys 0.000s

which is a few percent gain, but still missing a good chunk.

Change-Id: I63afea81ce9d4ab605ccb27d1d9345637613c06d
Reviewed-on: http://gerrit.cloudera.org:8080/1848
Reviewed-by: Adar Dembo <adar@cloudera.com>
Tested-by: Internal Jenkins


Project: http://git-wip-us.apache.org/repos/asf/incubator-kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kudu/commit/173e1fde
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kudu/tree/173e1fde
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kudu/diff/173e1fde

Branch: refs/heads/master
Commit: 173e1fde4ea9f25a3d3aa9dc39706f0ad31834d0
Parents: 1c26565
Author: Todd Lipcon <todd@apache.org>
Authored: Wed Jan 20 14:50:33 2016 -0800
Committer: Todd Lipcon <todd@apache.org>
Committed: Fri Jan 22 01:17:55 2016 +0000

----------------------------------------------------------------------
 src/kudu/tablet/concurrent_btree.h | 6 +++---
 src/kudu/util/inline_slice.h       | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/173e1fde/src/kudu/tablet/concurrent_btree.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/concurrent_btree.h b/src/kudu/tablet/concurrent_btree.h
index 916b833..1d3be26 100644
--- a/src/kudu/tablet/concurrent_btree.h
+++ b/src/kudu/tablet/concurrent_btree.h
@@ -118,7 +118,7 @@ struct VersionField {
   static AtomicVersion StableVersion(volatile AtomicVersion *version) {
     for (int loop_count = 0; true; loop_count++) {
       AtomicVersion v_acq = base::subtle::Acquire_Load(version);
-      if (!IsLocked(v_acq)) {
+      if (PREDICT_TRUE(!IsLocked(v_acq))) {
         return v_acq;
       }
       boost::detail::yield(loop_count++);
@@ -130,9 +130,9 @@ struct VersionField {
 
     while (true) {
       AtomicVersion v_acq = base::subtle::Acquire_Load(version);
-      if (!IsLocked(v_acq)) {
+      if (PREDICT_TRUE(!IsLocked(v_acq))) {
         AtomicVersion v_locked = SetLockBit(v_acq, 1);
-        if (base::subtle::Acquire_CompareAndSwap(version, v_acq, v_locked) == v_acq) {
+        if (PREDICT_TRUE(base::subtle::Acquire_CompareAndSwap(version, v_acq, v_locked) ==
v_acq)) {
           return;
         }
       }

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/173e1fde/src/kudu/util/inline_slice.h
----------------------------------------------------------------------
diff --git a/src/kudu/util/inline_slice.h b/src/kudu/util/inline_slice.h
index 648862f..aeca370 100644
--- a/src/kudu/util/inline_slice.h
+++ b/src/kudu/util/inline_slice.h
@@ -75,7 +75,7 @@ class InlineSlice {
   InlineSlice() {
   }
 
-  const Slice as_slice() const {
+  inline const Slice as_slice() const ATTRIBUTE_ALWAYS_INLINE {
     DiscriminatedPointer dptr = LoadValue();
 
     if (dptr.is_indirect()) {


Mime
View raw message