kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [2/5] kudu git commit: compaction: fix rowblock size in compaction output
Date Thu, 23 Mar 2017 04:18:58 GMT
compaction: fix rowblock size in compaction output

In compaction, we let the compaction input return fewer rows at a time
than the maximum (100). In this case, we resize the rowblock down to
match the number of returned rows before feeding it into the DiskRowSet
write path.

However, we weren't resetting it back _up_ to the maximum capacity
before fetching the next batch of rows. This meant that after any
"small" batch from the underlying rowsets, all future batches would be
limited to that same size.

In practice this was causing most calls to the write path to use very
small batches, causing a lot of extra function calls, hurting CPU cache
locality, etc.

This improved an end-to-end bulk-write workload about 12% (see [1] under
the "After fixing compaction bug" section). I also measured the
improvement using the compaction-test benchmark:

before:
  Time spent compacting without overlap: real 0.837s  user 0.505s     sys 0.084s
  Time spent compacting without overlap: real 0.850s  user 0.507s     sys 0.080s
  Time spent compacting without overlap: real 0.864s  user 0.493s     sys 0.086s
  Time spent compacting without overlap: real 0.946s  user 0.491s     sys 0.069s
  Time spent compacting without overlap: real 1.005s  user 0.489s     sys 0.086s
  Time spent compacting with overlap: real 1.026s     user 0.678s     sys 0.107s
  Time spent compacting with overlap: real 1.091s     user 0.683s     sys 0.083s
  Time spent compacting with overlap: real 1.117s     user 0.691s     sys 0.085s
  Time spent compacting with overlap: real 1.133s     user 0.705s     sys 0.078s
  Time spent compacting with overlap: real 1.220s     user 0.695s     sys 0.097s

after:
  Time spent compacting without overlap: real 0.790s  user 0.492s     sys 0.067s
  Time spent compacting without overlap: real 0.816s  user 0.484s     sys 0.101s
  Time spent compacting without overlap: real 0.831s  user 0.498s     sys 0.081s
  Time spent compacting without overlap: real 0.833s  user 0.497s     sys 0.079s
  Time spent compacting without overlap: real 0.846s  user 0.507s     sys 0.083s
  Time spent compacting with overlap: real 0.835s     user 0.548s     sys 0.080s
  Time spent compacting with overlap: real 0.839s     user 0.552s     sys 0.077s
  Time spent compacting with overlap: real 0.861s     user 0.556s     sys 0.080s
  Time spent compacting with overlap: real 0.871s     user 0.533s     sys 0.079s
  Time spent compacting with overlap: real 0.891s     user 0.546s     sys 0.083s

The "with overlap" case is 20-30% improved in terms of user-CPU.

I also ran perf-stat on the 'WithOverlap' case:

Before:
 Performance counter stats for './build/latest/bin/compaction-test --gtest_filter=TestCompaction.BenchmarkMergeWithOverlap*'
(10 runs):

       2556.524929 task-clock                #    0.904 CPUs utilized            ( +-  0.52%
)
               241 context-switches          #    0.094 K/sec                    ( +-  1.95%
)
                29 cpu-migrations            #    0.011 K/sec                    ( +- 12.97%
)
            55,860 page-faults               #    0.022 M/sec                    ( +-  0.19%
)
     8,317,627,473 cycles                    #    3.253 GHz                      ( +-  0.51%
)
   <not supported> stalled-cycles-frontend
   <not supported> stalled-cycles-backend
    16,685,733,672 instructions              #    2.01  insns per cycle          ( +-  0.01%
)
     2,973,888,033 branches                  # 1163.254 M/sec                    ( +-  0.01%
)
        12,123,206 branch-misses             #    0.41% of all branches          ( +-  0.15%
)

       2.827881785 seconds time elapsed                                          ( +-  1.04%
)

After:
       2397.755099 task-clock                #    0.909 CPUs utilized            ( +-  0.29%
)
               250 context-switches          #    0.104 K/sec                    ( +-  3.79%
)
                23 cpu-migrations            #    0.010 K/sec                    ( +- 11.43%
)
            56,062 page-faults               #    0.023 M/sec                    ( +-  0.11%
)
     7,793,443,483 cycles                    #    3.250 GHz                      ( +-  0.29%
)
   <not supported> stalled-cycles-frontend
   <not supported> stalled-cycles-backend
    15,852,415,910 instructions              #    2.03  insns per cycle          ( +-  0.01%
)
     2,836,337,368 branches                  # 1182.914 M/sec                    ( +-  0.01%
)
        10,362,726 branch-misses             #    0.37% of all branches          ( +-  0.17%
)

       2.638284381 seconds time elapsed                                          ( +-  1.03%
)

The number of branch-misses is substantially reduced.

[1] https://docs.google.com/document/d/1U1IXS1XD2erZyq8_qG81A1gZaCeHcq2i0unea_eEf5c/edit#heading=h.b98m0h4dgd3w

Change-Id: I6fc4002fb84a33e0032577055fa2cdc947ce4191
Reviewed-on: http://gerrit.cloudera.org:8080/6430
Reviewed-by: David Ribeiro Alves <dralves@apache.org>
Tested-by: Kudu Jenkins
Reviewed-by: Andrew Wong <awong@cloudera.com>


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

Branch: refs/heads/master
Commit: 4f51c66c56457955cbedec0d7ba5f8de785a6280
Parents: fd90897
Author: Todd Lipcon <todd@apache.org>
Authored: Tue Mar 14 21:13:31 2017 -0700
Committer: Todd Lipcon <todd@apache.org>
Committed: Wed Mar 22 07:22:54 2017 +0000

----------------------------------------------------------------------
 src/kudu/tablet/compaction.cc | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/4f51c66c/src/kudu/tablet/compaction.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/compaction.cc b/src/kudu/tablet/compaction.cc
index afe4b88..a851c10 100644
--- a/src/kudu/tablet/compaction.cc
+++ b/src/kudu/tablet/compaction.cc
@@ -1131,6 +1131,7 @@ Status FlushCompactionInput(CompactionInput* input,
     if (n > 0) {
       block.Resize(n);
       RETURN_NOT_OK(out->AppendBlock(block));
+      block.Resize(block.row_capacity());
     }
 
     RETURN_NOT_OK(input->FinishBlock());


Mime
View raw message