You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@kudu.apache.org by "Todd Lipcon (Code Review)" <ge...@cloudera.org> on 2019/06/11 23:35:24 UTC

[kudu-CR] KUDU-2846 (part 1): optimize predicate evaluation for primitives

Hello Andrew Wong,

I'd like you to do a code review. Please visit

    http://gerrit.cloudera.org:8080/13591

to review the following change.


Change subject: KUDU-2846 (part 1): optimize predicate evaluation for primitives
......................................................................

KUDU-2846 (part 1): optimize predicate evaluation for primitives

This changes to an optimized unrolled-by-8 predicate evaluation for
primitive columns.

Performance is improved by 1.6-2.5x depending on the particular
predicate, type, and nullability (average around 2x). Branches are
reduced by about 7.5x and branch-misses by about 19.6x.

Looking at the "after" perf-stat results, the instructions-per-cycle are
way down, which indicates we're probably stalled on instruction
dependencies or port saturation. This is also indicated by the fact that
the smaller ints don't seem to run any faster than the large ints (which
wouldn't be the case if we were limited by load/store bandwidth). Likely
the next fix here is to use SIMD to do comparisons in parallel as
suggested in the JIRA.  Unfortunately, the compiler doesn't seem to
auto-vectorize these loops, so if we want further gain, we'll have to
add some more hand-written vectorization code. So, we'll start with this
easy win.

perf-stat before:
 Performance counter stats for 'build/latest/bin/column_predicate-test --gtest_filter=*Bench*':

      82185.366028      task-clock (msec)         #    0.997 CPUs utilized
   288,909,311,749      cycles                    #    3.515 GHz
   956,410,925,173      instructions              #    3.31  insn per cycle
   149,468,823,714      branches                  # 1818.679 M/sec
     1,237,139,955      branch-misses             #    0.83% of all branches

      82.398392581 seconds time elapsed

      82.132012000 seconds user
       0.055937000 seconds sys

perf-stat after:
 Performance counter stats for 'build/latest/bin/column_predicate-test --gtest_filter=*Bench*':

      42626.067916      task-clock (msec)         #    0.996 CPUs utilized
   149,363,412,476      cycles                    #    3.504 GHz
   190,514,045,889      instructions              #    1.28  insn per cycle
    19,902,815,659      branches                  #  466.917 M/sec
        63,130,874      branch-misses             #    0.32% of all branches

Detailed results before:
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int8 NOT NULL: real 1.730s	user 1.730s	sys 0.002s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int8 NULL: real 2.097s	user 2.096s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int8 NOT NULL: real 1.755s	user 1.756s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int8 NULL: real 2.631s	user 2.632s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int8 NOT NULL: real 1.850s	user 1.848s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int8 NULL: real 2.808s	user 2.808s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int16 NOT NULL: real 1.753s	user 1.752s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int16 NULL: real 2.248s	user 2.244s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int16 NOT NULL: real 1.750s	user 1.752s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int16 NULL: real 2.420s	user 2.416s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int16 NOT NULL: real 1.811s	user 1.808s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int16 NULL: real 5.321s	user 5.313s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int32 NOT NULL: real 1.834s	user 1.824s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int32 NULL: real 2.233s	user 2.232s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int32 NOT NULL: real 1.797s	user 1.793s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int32 NULL: real 2.791s	user 2.774s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int32 NOT NULL: real 1.873s	user 1.869s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int32 NULL: real 3.104s	user 3.071s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int64 NOT NULL: real 1.781s	user 1.779s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int64 NULL: real 2.209s	user 2.203s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int64 NOT NULL: real 1.741s	user 1.739s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int64 NULL: real 2.374s	user 2.374s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int64 NOT NULL: real 1.769s	user 1.767s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int64 NULL: real 3.113s	user 3.099s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type float NOT NULL: real 1.766s	user 1.765s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type float NULL: real 2.305s	user 2.299s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type float NOT NULL: real 1.755s	user 1.752s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type float NULL: real 2.685s	user 2.678s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type float NOT NULL: real 1.777s	user 1.771s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type float NULL: real 2.940s	user 2.929s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type double NOT NULL: real 1.756s	user 1.749s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type double NULL: real 2.443s	user 2.438s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type double NOT NULL: real 1.819s	user 1.819s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type double NULL: real 2.744s	user 2.724s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type double NOT NULL: real 1.753s	user 1.746s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type double NULL: real 2.481s	user 2.460s	sys 0.004s

Detailed results after:
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int8 NOT NULL: real 1.082s	user 1.073s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int8 NULL: real 1.069s	user 1.063s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int8 NOT NULL: real 1.085s	user 1.076s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int8 NULL: real 1.071s	user 1.068s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int8 NOT NULL: real 1.191s	user 1.191s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int8 NULL: real 1.209s	user 1.206s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int16 NOT NULL: real 1.099s	user 1.099s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int16 NULL: real 1.123s	user 1.106s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int16 NOT NULL: real 1.100s	user 1.100s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int16 NULL: real 1.070s	user 1.068s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int16 NOT NULL: real 1.211s	user 1.212s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int16 NULL: real 1.220s	user 1.220s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int32 NOT NULL: real 1.104s	user 1.104s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int32 NULL: real 1.105s	user 1.104s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int32 NOT NULL: real 1.107s	user 1.108s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int32 NULL: real 1.081s	user 1.080s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int32 NOT NULL: real 1.230s	user 1.228s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int32 NULL: real 1.219s	user 1.220s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int64 NOT NULL: real 1.071s	user 1.072s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int64 NULL: real 1.090s	user 1.088s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int64 NOT NULL: real 1.069s	user 1.067s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int64 NULL: real 1.083s	user 1.084s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int64 NOT NULL: real 1.253s	user 1.252s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int64 NULL: real 1.248s	user 1.248s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type float NOT NULL: real 1.144s	user 1.144s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type float NULL: real 1.144s	user 1.144s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type float NOT NULL: real 1.159s	user 1.160s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type float NULL: real 1.214s	user 1.216s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type float NOT NULL: real 1.439s	user 1.436s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type float NULL: real 1.457s	user 1.458s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type double NOT NULL: real 1.196s	user 1.195s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type double NULL: real 1.213s	user 1.212s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type double NOT NULL: real 1.232s	user 1.230s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type double NULL: real 1.256s	user 1.241s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type double NOT NULL: real 1.419s	user 1.418s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type double NULL: real 1.430s	user 1.426s	sys 0.000s

Change-Id: I9dd062961a3cd2c892997d6aba12684e603628a1
---
M src/kudu/common/column_predicate-test.cc
M src/kudu/common/column_predicate.cc
2 files changed, 135 insertions(+), 12 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/91/13591/1
-- 
To view, visit http://gerrit.cloudera.org:8080/13591
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9dd062961a3cd2c892997d6aba12684e603628a1
Gerrit-Change-Number: 13591
Gerrit-PatchSet: 1
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Andrew Wong <an...@cloudera.com>

[kudu-CR] KUDU-2846 (part 1): optimize predicate evaluation for primitives

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Hello Tidy Bot, Andrew Wong, Kudu Jenkins, Adar Dembo, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/13591

to look at the new patch set (#3).

Change subject: KUDU-2846 (part 1): optimize predicate evaluation for primitives
......................................................................

KUDU-2846 (part 1): optimize predicate evaluation for primitives

This changes to an optimized unrolled-by-8 predicate evaluation for
primitive columns.

Performance is improved by 1.6-2.5x depending on the particular
predicate, type, and nullability (average around 2x). Branches are
reduced by about 7.5x and branch-misses by about 19.6x.

Looking at the "after" perf-stat results, the instructions-per-cycle are
way down, which indicates we're probably stalled on instruction
dependencies or port saturation. This is also indicated by the fact that
the smaller ints don't seem to run any faster than the large ints (which
wouldn't be the case if we were limited by load/store bandwidth). Likely
the next fix here is to use SIMD to do comparisons in parallel as
suggested in the JIRA.  Unfortunately, the compiler doesn't seem to
auto-vectorize these loops, so if we want further gain, we'll have to
add some more hand-written vectorization code. So, we'll start with this
easy win.

perf-stat before:
 Performance counter stats for 'build/latest/bin/column_predicate-test --gtest_filter=*Bench*':

      82185.366028      task-clock (msec)         #    0.997 CPUs utilized
   288,909,311,749      cycles                    #    3.515 GHz
   956,410,925,173      instructions              #    3.31  insn per cycle
   149,468,823,714      branches                  # 1818.679 M/sec
     1,237,139,955      branch-misses             #    0.83% of all branches

perf-stat after:
 Performance counter stats for 'build/latest/bin/column_predicate-test --gtest_filter=*Bench*':

      42626.067916      task-clock (msec)         #    0.996 CPUs utilized
   149,363,412,476      cycles                    #    3.504 GHz
   190,514,045,889      instructions              #    1.28  insn per cycle
    19,902,815,659      branches                  #  466.917 M/sec
        63,130,874      branch-misses             #    0.32% of all branches

Detailed results before:
  int8   NOT NULL   (c = 0) 573.9M evals/sec	4.78 cycles/eval
  int8   NULL       (c = 0) 456.2M evals/sec	6.14 cycles/eval
  int8   NOT NULL   (c >= 0) 573.5M evals/sec	4.79 cycles/eval
  int8   NULL       (c >= 0) 420.3M evals/sec	6.71 cycles/eval
  int8   NOT NULL   (c >= 0 AND c < 2) 565.1M evals/sec	4.87 cycles/eval
  int8   NULL       (c >= 0 AND c < 2) 372.0M evals/sec	7.53 cycles/eval
  int16  NOT NULL   (c = 0) 577.0M evals/sec	4.75 cycles/eval
  int16  NULL       (c = 0) 460.5M evals/sec	6.06 cycles/eval
  int16  NOT NULL   (c >= 0) 568.9M evals/sec	4.80 cycles/eval
  int16  NULL       (c >= 0) 400.4M evals/sec	6.96 cycles/eval
  int16  NOT NULL   (c >= 0 AND c < 2) 577.9M evals/sec	4.73 cycles/eval
  int16  NULL       (c >= 0 AND c < 2) 299.4M evals/sec	9.40 cycles/eval
  int32  NOT NULL   (c = 0) 543.8M evals/sec	5.05 cycles/eval
  int32  NULL       (c = 0) 446.2M evals/sec	6.21 cycles/eval
  int32  NOT NULL   (c >= 0) 565.5M evals/sec	4.84 cycles/eval
  int32  NULL       (c >= 0) 380.4M evals/sec	7.36 cycles/eval
  int32  NOT NULL   (c >= 0 AND c < 2) 561.8M evals/sec	4.91 cycles/eval
  int32  NULL       (c >= 0 AND c < 2) 308.6M evals/sec	9.18 cycles/eval
  int64  NOT NULL   (c = 0) 566.6M evals/sec	4.88 cycles/eval
  int64  NULL       (c = 0) 463.9M evals/sec	6.07 cycles/eval
  int64  NOT NULL   (c >= 0) 555.5M evals/sec	4.97 cycles/eval
  int64  NULL       (c >= 0) 385.3M evals/sec	7.28 cycles/eval
  int64  NOT NULL   (c >= 0 AND c < 2) 567.1M evals/sec	4.83 cycles/eval
  int64  NULL       (c >= 0 AND c < 2) 194.7M evals/sec	14.61 cycles/eval
  float  NOT NULL   (c = 0) 584.5M evals/sec	4.68 cycles/eval
  float  NULL       (c = 0) 441.4M evals/sec	6.29 cycles/eval
  float  NOT NULL   (c >= 0) 576.6M evals/sec	4.74 cycles/eval
  float  NULL       (c >= 0) 361.1M evals/sec	7.74 cycles/eval
  float  NOT NULL   (c >= 0 AND c < 2) 577.9M evals/sec	4.73 cycles/eval
  float  NULL       (c >= 0 AND c < 2) 301.5M evals/sec	9.34 cycles/eval
  double NOT NULL   (c = 0) 589.9M evals/sec	4.64 cycles/eval
  double NULL       (c = 0) 450.0M evals/sec	6.15 cycles/eval
  double NOT NULL   (c >= 0) 571.5M evals/sec	4.78 cycles/eval
  double NULL       (c >= 0) 367.8M evals/sec	7.60 cycles/eval
  double NOT NULL   (c >= 0 AND c < 2) 577.8M evals/sec	4.77 cycles/eval
  double NULL       (c >= 0 AND c < 2) 429.5M evals/sec	6.49 cycles/eval

Detailed results after:
  int8   NOT NULL   (c = 0) 926.7M evals/sec	3.01 cycles/eval
  int8   NULL       (c = 0) 935.2M evals/sec	2.98 cycles/eval
  int8   NOT NULL   (c >= 0) 913.6M evals/sec	3.03 cycles/eval
  int8   NULL       (c >= 0) 903.2M evals/sec	3.08 cycles/eval
  int8   NOT NULL   (c >= 0 AND c < 2) 824.3M evals/sec	3.35 cycles/eval
  int8   NULL       (c >= 0 AND c < 2) 814.5M evals/sec	3.38 cycles/eval
  int16  NOT NULL   (c = 0) 900.6M evals/sec	3.07 cycles/eval
  int16  NULL       (c = 0) 946.9M evals/sec	2.93 cycles/eval
  int16  NOT NULL   (c >= 0) 925.8M evals/sec	2.99 cycles/eval
  int16  NULL       (c >= 0) 922.6M evals/sec	3.00 cycles/eval
  int16  NOT NULL   (c >= 0 AND c < 2) 819.7M evals/sec	3.35 cycles/eval
  int16  NULL       (c >= 0 AND c < 2) 822.8M evals/sec	3.34 cycles/eval
  int32  NOT NULL   (c = 0) 894.0M evals/sec	3.09 cycles/eval
  int32  NULL       (c = 0) 916.3M evals/sec	3.01 cycles/eval
  int32  NOT NULL   (c >= 0) 916.2M evals/sec	3.02 cycles/eval
  int32  NULL       (c >= 0) 933.2M evals/sec	2.97 cycles/eval
  int32  NOT NULL   (c >= 0 AND c < 2) 863.5M evals/sec	3.17 cycles/eval
  int32  NULL       (c >= 0 AND c < 2) 866.4M evals/sec	3.16 cycles/eval
  int64  NOT NULL   (c = 0) 949.9M evals/sec	2.92 cycles/eval
  int64  NULL       (c = 0) 936.2M evals/sec	2.96 cycles/eval
  int64  NOT NULL   (c >= 0) 950.2M evals/sec	2.92 cycles/eval
  int64  NULL       (c >= 0) 926.0M evals/sec	2.99 cycles/eval
  int64  NOT NULL   (c >= 0 AND c < 2) 835.5M evals/sec	3.29 cycles/eval
  int64  NULL       (c >= 0 AND c < 2) 835.6M evals/sec	3.30 cycles/eval
  float  NOT NULL   (c = 0) 936.5M evals/sec	2.95 cycles/eval
  float  NULL       (c = 0) 933.0M evals/sec	2.97 cycles/eval
  float  NOT NULL   (c >= 0) 852.2M evals/sec	3.27 cycles/eval
  float  NULL       (c >= 0) 838.3M evals/sec	3.32 cycles/eval
  float  NOT NULL   (c >= 0 AND c < 2) 691.9M evals/sec	3.97 cycles/eval
  float  NULL       (c >= 0 AND c < 2) 705.3M evals/sec	3.90 cycles/eval
  double NOT NULL   (c = 0) 898.3M evals/sec	3.08 cycles/eval
  double NULL       (c = 0) 879.7M evals/sec	3.14 cycles/eval
  double NOT NULL   (c >= 0) 800.0M evals/sec	3.46 cycles/eval
  double NULL       (c >= 0) 836.6M evals/sec	3.32 cycles/eval
  double NOT NULL   (c >= 0 AND c < 2) 719.2M evals/sec	3.83 cycles/eval
  double NULL       (c >= 0 AND c < 2) 721.1M evals/sec	3.82 cycles/eval

Change-Id: I9dd062961a3cd2c892997d6aba12684e603628a1
---
M src/kudu/common/CMakeLists.txt
M src/kudu/common/column_predicate-test.cc
M src/kudu/common/column_predicate.cc
3 files changed, 146 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/91/13591/3
-- 
To view, visit http://gerrit.cloudera.org:8080/13591
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I9dd062961a3cd2c892997d6aba12684e603628a1
Gerrit-Change-Number: 13591
Gerrit-PatchSet: 3
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <an...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] KUDU-2846 (part 1): optimize predicate evaluation for primitives

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Hello Tidy Bot, Andrew Wong, Kudu Jenkins, Adar Dembo, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/13591

to look at the new patch set (#2).

Change subject: KUDU-2846 (part 1): optimize predicate evaluation for primitives
......................................................................

KUDU-2846 (part 1): optimize predicate evaluation for primitives

This changes to an optimized unrolled-by-8 predicate evaluation for
primitive columns.

Performance is improved by 1.6-2.5x depending on the particular
predicate, type, and nullability (average around 2x). Branches are
reduced by about 7.5x and branch-misses by about 19.6x.

Looking at the "after" perf-stat results, the instructions-per-cycle are
way down, which indicates we're probably stalled on instruction
dependencies or port saturation. This is also indicated by the fact that
the smaller ints don't seem to run any faster than the large ints (which
wouldn't be the case if we were limited by load/store bandwidth). Likely
the next fix here is to use SIMD to do comparisons in parallel as
suggested in the JIRA.  Unfortunately, the compiler doesn't seem to
auto-vectorize these loops, so if we want further gain, we'll have to
add some more hand-written vectorization code. So, we'll start with this
easy win.

perf-stat before:
 Performance counter stats for 'build/latest/bin/column_predicate-test --gtest_filter=*Bench*':

      82185.366028      task-clock (msec)         #    0.997 CPUs utilized
   288,909,311,749      cycles                    #    3.515 GHz
   956,410,925,173      instructions              #    3.31  insn per cycle
   149,468,823,714      branches                  # 1818.679 M/sec
     1,237,139,955      branch-misses             #    0.83% of all branches

perf-stat after:
 Performance counter stats for 'build/latest/bin/column_predicate-test --gtest_filter=*Bench*':

      42626.067916      task-clock (msec)         #    0.996 CPUs utilized
   149,363,412,476      cycles                    #    3.504 GHz
   190,514,045,889      instructions              #    1.28  insn per cycle
    19,902,815,659      branches                  #  466.917 M/sec
        63,130,874      branch-misses             #    0.32% of all branches

Detailed results before:
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int8 NOT NULL: real 1.730s	user 1.730s	sys 0.002s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int8 NULL: real 2.097s	user 2.096s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int8 NOT NULL: real 1.755s	user 1.756s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int8 NULL: real 2.631s	user 2.632s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int8 NOT NULL: real 1.850s	user 1.848s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int8 NULL: real 2.808s	user 2.808s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int16 NOT NULL: real 1.753s	user 1.752s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int16 NULL: real 2.248s	user 2.244s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int16 NOT NULL: real 1.750s	user 1.752s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int16 NULL: real 2.420s	user 2.416s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int16 NOT NULL: real 1.811s	user 1.808s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int16 NULL: real 5.321s	user 5.313s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int32 NOT NULL: real 1.834s	user 1.824s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int32 NULL: real 2.233s	user 2.232s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int32 NOT NULL: real 1.797s	user 1.793s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int32 NULL: real 2.791s	user 2.774s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int32 NOT NULL: real 1.873s	user 1.869s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int32 NULL: real 3.104s	user 3.071s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int64 NOT NULL: real 1.781s	user 1.779s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int64 NULL: real 2.209s	user 2.203s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int64 NOT NULL: real 1.741s	user 1.739s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int64 NULL: real 2.374s	user 2.374s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int64 NOT NULL: real 1.769s	user 1.767s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int64 NULL: real 3.113s	user 3.099s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type float NOT NULL: real 1.766s	user 1.765s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type float NULL: real 2.305s	user 2.299s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type float NOT NULL: real 1.755s	user 1.752s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type float NULL: real 2.685s	user 2.678s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type float NOT NULL: real 1.777s	user 1.771s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type float NULL: real 2.940s	user 2.929s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type double NOT NULL: real 1.756s	user 1.749s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type double NULL: real 2.443s	user 2.438s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type double NOT NULL: real 1.819s	user 1.819s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type double NULL: real 2.744s	user 2.724s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type double NOT NULL: real 1.753s	user 1.746s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type double NULL: real 2.481s	user 2.460s	sys 0.004s

Detailed results after:
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int8 NOT NULL: real 1.082s	user 1.073s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int8 NULL: real 1.069s	user 1.063s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int8 NOT NULL: real 1.085s	user 1.076s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int8 NULL: real 1.071s	user 1.068s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int8 NOT NULL: real 1.191s	user 1.191s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int8 NULL: real 1.209s	user 1.206s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int16 NOT NULL: real 1.099s	user 1.099s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int16 NULL: real 1.123s	user 1.106s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int16 NOT NULL: real 1.100s	user 1.100s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int16 NULL: real 1.070s	user 1.068s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int16 NOT NULL: real 1.211s	user 1.212s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int16 NULL: real 1.220s	user 1.220s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int32 NOT NULL: real 1.104s	user 1.104s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int32 NULL: real 1.105s	user 1.104s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int32 NOT NULL: real 1.107s	user 1.108s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int32 NULL: real 1.081s	user 1.080s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int32 NOT NULL: real 1.230s	user 1.228s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int32 NULL: real 1.219s	user 1.220s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int64 NOT NULL: real 1.071s	user 1.072s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type int64 NULL: real 1.090s	user 1.088s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int64 NOT NULL: real 1.069s	user 1.067s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type int64 NULL: real 1.083s	user 1.084s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int64 NOT NULL: real 1.253s	user 1.252s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type int64 NULL: real 1.248s	user 1.248s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type float NOT NULL: real 1.144s	user 1.144s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type float NULL: real 1.144s	user 1.144s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type float NOT NULL: real 1.159s	user 1.160s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type float NULL: real 1.214s	user 1.216s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type float NOT NULL: real 1.439s	user 1.436s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type float NULL: real 1.457s	user 1.458s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type double NOT NULL: real 1.196s	user 1.195s	sys 0.000s
  Time spent evaluating c = 0: 1000000 batches of 1024 rows for type double NULL: real 1.213s	user 1.212s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type double NOT NULL: real 1.232s	user 1.230s	sys 0.000s
  Time spent evaluating c >= 0: 1000000 batches of 1024 rows for type double NULL: real 1.256s	user 1.241s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type double NOT NULL: real 1.419s	user 1.418s	sys 0.000s
  Time spent evaluating c >= 0 AND c < 2: 1000000 batches of 1024 rows for type double NULL: real 1.430s	user 1.426s	sys 0.000s

Change-Id: I9dd062961a3cd2c892997d6aba12684e603628a1
---
M src/kudu/common/CMakeLists.txt
M src/kudu/common/column_predicate-test.cc
M src/kudu/common/column_predicate.cc
3 files changed, 136 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/91/13591/2
-- 
To view, visit http://gerrit.cloudera.org:8080/13591
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I9dd062961a3cd2c892997d6aba12684e603628a1
Gerrit-Change-Number: 13591
Gerrit-PatchSet: 2
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <an...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] KUDU-2846: optimize predicate evaluation for primitives

Posted by "Andrew Wong (Code Review)" <ge...@cloudera.org>.
Andrew Wong has posted comments on this change. ( http://gerrit.cloudera.org:8080/13591 )

Change subject: KUDU-2846: optimize predicate evaluation for primitives
......................................................................


Patch Set 6:

(2 comments)

http://gerrit.cloudera.org:8080/#/c/13591/6//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/13591/6//COMMIT_MSG@8
PS6, Line 8: 
           : This changes to an optimized unrolled-by-8 predicate evaluation for
           : primitive columns.
> for AVX2 there aren't any parallel compare operations that can do more than
Thanks for the explanation! SGTM


http://gerrit.cloudera.org:8080/#/c/13591/3/src/kudu/common/column_predicate-test.cc
File src/kudu/common/column_predicate-test.cc:

http://gerrit.cloudera.org:8080/#/c/13591/3/src/kudu/common/column_predicate-test.cc@1538
PS3, Line 1538: pred.Evaluate(b, &selvec);
> I just had this 'num_ret' bit to try to avoid the compiler completely optim
Ack



-- 
To view, visit http://gerrit.cloudera.org:8080/13591
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I9dd062961a3cd2c892997d6aba12684e603628a1
Gerrit-Change-Number: 13591
Gerrit-PatchSet: 6
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Grant Henke <gr...@apache.org>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-Comment-Date: Thu, 13 Jun 2019 16:22:55 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-2846: optimize predicate evaluation for primitives

Posted by "Andrew Wong (Code Review)" <ge...@cloudera.org>.
Andrew Wong has posted comments on this change. ( http://gerrit.cloudera.org:8080/13591 )

Change subject: KUDU-2846: optimize predicate evaluation for primitives
......................................................................


Patch Set 6: Code-Review+2

(1 comment)

http://gerrit.cloudera.org:8080/#/c/13591/6//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/13591/6//COMMIT_MSG@8
PS6, Line 8: 
           : This changes to an optimized unrolled-by-8 predicate evaluation for
           : primitive columns.
Any reason to stop at 8 vs 16 or 32?



-- 
To view, visit http://gerrit.cloudera.org:8080/13591
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I9dd062961a3cd2c892997d6aba12684e603628a1
Gerrit-Change-Number: 13591
Gerrit-PatchSet: 6
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Grant Henke <gr...@apache.org>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-Comment-Date: Wed, 12 Jun 2019 23:52:45 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-2846 (part 1): optimize predicate evaluation for primitives

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Hello Tidy Bot, Kudu Jenkins, Andrew Wong, Adar Dembo, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/13591

to look at the new patch set (#4).

Change subject: KUDU-2846 (part 1): optimize predicate evaluation for primitives
......................................................................

KUDU-2846 (part 1): optimize predicate evaluation for primitives

This changes to an optimized unrolled-by-8 predicate evaluation for
primitive columns.

Performance is improved by 1.6-2.5x depending on the particular
predicate, type, and nullability (average around 2x). Branches are
reduced by about 7.5x and branch-misses by about 19.6x.

Looking at the "after" perf-stat results, the instructions-per-cycle are
way down, which indicates we're probably stalled on instruction
dependencies or port saturation. This is also indicated by the fact that
the smaller ints don't seem to run any faster than the large ints (which
wouldn't be the case if we were limited by load/store bandwidth). Likely
the next fix here is to use SIMD to do comparisons in parallel as
suggested in the JIRA.  Unfortunately, the compiler doesn't seem to
auto-vectorize these loops, so if we want further gain, we'll have to
add some more hand-written vectorization code. So, we'll start with this
easy win.

perf-stat before:
 Performance counter stats for 'build/latest/bin/column_predicate-test --gtest_filter=*Bench*':
      73905.379627      task-clock (msec)         #    0.997 CPUs utilized
               504      context-switches          #    0.007 K/sec
                19      cpu-migrations            #    0.000 K/sec
             1,296      page-faults               #    0.018 K/sec
   272,810,081,028      cycles                    #    3.691 GHz
   938,488,388,743      instructions              #    3.44  insn per cycle
   148,052,698,322      branches                  # 2003.274 M/sec
       882,311,138      branch-misses             #    0.60% of all branches

perf-stat after:
 Performance counter stats for 'build/latest/bin/column_predicate-test --gtest_filter=*Bench*':

      38024.082495      task-clock (msec)         #    0.996 CPUs utilized
               252      context-switches          #    0.007 K/sec
                 7      cpu-migrations            #    0.000 K/sec
             1,295      page-faults               #    0.034 K/sec
   142,231,469,257      cycles                    #    3.741 GHz
   172,437,810,470      instructions              #    1.21  insn per cycle
    18,460,117,439      branches                  #  485.485 M/sec
        60,960,125      branch-misses             #    0.33% of all branches

Detailed results before:
  int8   NOT NULL   (c = 0) 632.1M evals/sec	4.44 cycles/eval
  int8   NULL       (c = 0) 515.6M evals/sec	5.48 cycles/eval
  int8   NOT NULL   (c >= 0) 630.8M evals/sec	4.45 cycles/eval
  int8   NULL       (c >= 0) 426.8M evals/sec	6.64 cycles/eval
  int8   NOT NULL   (c >= 0 AND c < 2) 632.6M evals/sec	4.44 cycles/eval
  int8   NULL       (c >= 0 AND c < 2) 384.7M evals/sec	7.38 cycles/eval
  int16  NOT NULL   (c = 0) 644.4M evals/sec	4.34 cycles/eval
  int16  NULL       (c = 0) 524.6M evals/sec	5.37 cycles/eval
  int16  NOT NULL   (c >= 0) 638.4M evals/sec	4.37 cycles/eval
  int16  NULL       (c >= 0) 458.8M evals/sec	6.17 cycles/eval
  int16  NOT NULL   (c >= 0 AND c < 2) 635.3M evals/sec	4.40 cycles/eval
  int16  NULL       (c >= 0 AND c < 2) 335.1M evals/sec	8.50 cycles/eval
  int32  NOT NULL   (c = 0) 645.2M evals/sec	4.34 cycles/eval
  int32  NULL       (c = 0) 492.6M evals/sec	5.77 cycles/eval
  int32  NOT NULL   (c >= 0) 608.6M evals/sec	4.64 cycles/eval
  int32  NULL       (c >= 0) 440.7M evals/sec	6.48 cycles/eval
  int32  NOT NULL   (c >= 0 AND c < 2) 637.8M evals/sec	4.43 cycles/eval
  int32  NULL       (c >= 0 AND c < 2) 348.0M evals/sec	8.22 cycles/eval
  int64  NOT NULL   (c = 0) 642.7M evals/sec	4.36 cycles/eval
  int64  NULL       (c = 0) 505.3M evals/sec	5.60 cycles/eval
  int64  NOT NULL   (c >= 0) 643.5M evals/sec	4.34 cycles/eval
  int64  NULL       (c >= 0) 472.8M evals/sec	6.00 cycles/eval
  int64  NOT NULL   (c >= 0 AND c < 2) 634.2M evals/sec	4.43 cycles/eval
  int64  NULL       (c >= 0 AND c < 2) 396.7M evals/sec	7.21 cycles/eval
  float  NOT NULL   (c = 0) 604.6M evals/sec	4.63 cycles/eval
  float  NULL       (c = 0) 406.7M evals/sec	7.05 cycles/eval
  float  NOT NULL   (c >= 0) 545.3M evals/sec	5.20 cycles/eval
  float  NULL       (c >= 0) 384.4M evals/sec	7.39 cycles/eval
  float  NOT NULL   (c >= 0 AND c < 2) 583.2M evals/sec	4.80 cycles/eval
  float  NULL       (c >= 0 AND c < 2) 312.2M evals/sec	9.12 cycles/eval
  double NOT NULL   (c = 0) 614.0M evals/sec	4.56 cycles/eval
  double NULL       (c = 0) 471.5M evals/sec	5.99 cycles/eval
  double NOT NULL   (c >= 0) 623.0M evals/sec	4.48 cycles/eval
  double NULL       (c >= 0) 379.9M evals/sec	7.47 cycles/eval
  double NOT NULL   (c >= 0 AND c < 2) 599.5M evals/sec	4.67 cycles/eval
  double NULL       (c >= 0 AND c < 2) 415.2M evals/sec	6.82 cycles/eval

Detailed results after:
  int8   NOT NULL   (c = 0) 1053.2M evals/sec	2.74 cycles/eval
  int8   NULL       (c = 0) 1044.6M evals/sec	2.77 cycles/eval
  int8   NOT NULL   (c >= 0) 1044.6M evals/sec	2.77 cycles/eval
  int8   NULL       (c >= 0) 1045.0M evals/sec	2.76 cycles/eval
  int8   NOT NULL   (c >= 0 AND c < 2) 943.8M evals/sec	3.03 cycles/eval
  int8   NULL       (c >= 0 AND c < 2) 933.9M evals/sec	3.07 cycles/eval
  int16  NOT NULL   (c = 0) 1039.2M evals/sec	2.78 cycles/eval
  int16  NULL       (c = 0) 1037.2M evals/sec	2.79 cycles/eval
  int16  NOT NULL   (c >= 0) 1041.2M evals/sec	2.78 cycles/eval
  int16  NULL       (c >= 0) 1049.2M evals/sec	2.76 cycles/eval
  int16  NOT NULL   (c >= 0 AND c < 2) 948.3M evals/sec	3.00 cycles/eval
  int16  NULL       (c >= 0 AND c < 2) 951.1M evals/sec	2.99 cycles/eval
  int32  NOT NULL   (c = 0) 1049.5M evals/sec	2.74 cycles/eval
  int32  NULL       (c = 0) 1050.3M evals/sec	2.74 cycles/eval
  int32  NOT NULL   (c >= 0) 1040.9M evals/sec	2.76 cycles/eval
  int32  NULL       (c >= 0) 1050.1M evals/sec	2.75 cycles/eval
  int32  NOT NULL   (c >= 0 AND c < 2) 944.7M evals/sec	2.99 cycles/eval
  int32  NULL       (c >= 0 AND c < 2) 931.0M evals/sec	3.03 cycles/eval
  int64  NOT NULL   (c = 0) 1040.7M evals/sec	2.75 cycles/eval
  int64  NULL       (c = 0) 1040.8M evals/sec	2.76 cycles/eval
  int64  NOT NULL   (c >= 0) 1036.6M evals/sec	2.77 cycles/eval
  int64  NULL       (c >= 0) 1044.9M evals/sec	2.75 cycles/eval
  int64  NOT NULL   (c >= 0 AND c < 2) 941.2M evals/sec	3.02 cycles/eval
  int64  NULL       (c >= 0 AND c < 2) 930.9M evals/sec	3.04 cycles/eval
  float  NOT NULL   (c = 0) 1040.6M evals/sec	2.77 cycles/eval
  float  NULL       (c = 0) 1035.7M evals/sec	2.78 cycles/eval
  float  NOT NULL   (c >= 0) 960.5M evals/sec	3.00 cycles/eval
  float  NULL       (c >= 0) 955.2M evals/sec	3.01 cycles/eval
  float  NOT NULL   (c >= 0 AND c < 2) 797.5M evals/sec	3.56 cycles/eval
  float  NULL       (c >= 0 AND c < 2) 797.6M evals/sec	3.56 cycles/eval
  double NOT NULL   (c = 0) 1036.4M evals/sec	2.77 cycles/eval
  double NULL       (c = 0) 988.7M evals/sec	2.91 cycles/eval
  double NOT NULL   (c >= 0) 924.2M evals/sec	3.11 cycles/eval
  double NULL       (c >= 0) 930.9M evals/sec	3.10 cycles/eval
  double NOT NULL   (c >= 0 AND c < 2) 800.0M evals/sec	3.55 cycles/eval
  double NULL       (c >= 0 AND c < 2) 802.5M evals/sec	3.52 cycles/eval

Change-Id: I9dd062961a3cd2c892997d6aba12684e603628a1
---
M src/kudu/common/CMakeLists.txt
M src/kudu/common/column_predicate-test.cc
M src/kudu/common/column_predicate.cc
3 files changed, 152 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/91/13591/4
-- 
To view, visit http://gerrit.cloudera.org:8080/13591
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I9dd062961a3cd2c892997d6aba12684e603628a1
Gerrit-Change-Number: 13591
Gerrit-PatchSet: 4
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] KUDU-2846 (part 1): optimize predicate evaluation for primitives

Posted by "Andrew Wong (Code Review)" <ge...@cloudera.org>.
Andrew Wong has posted comments on this change. ( http://gerrit.cloudera.org:8080/13591 )

Change subject: KUDU-2846 (part 1): optimize predicate evaluation for primitives
......................................................................


Patch Set 3:

(3 comments)

Code looks fine but the tests seem angry.

http://gerrit.cloudera.org:8080/#/c/13591/3/src/kudu/common/column_predicate-test.cc
File src/kudu/common/column_predicate-test.cc:

http://gerrit.cloudera.org:8080/#/c/13591/3/src/kudu/common/column_predicate-test.cc@1538
PS3, Line 1538: num_ret += selvec.CountSelected();
Should probably check the final value of num_ret.


http://gerrit.cloudera.org:8080/#/c/13591/3/src/kudu/common/column_predicate.cc
File src/kudu/common/column_predicate.cc:

http://gerrit.cloudera.org:8080/#/c/13591/3/src/kudu/common/column_predicate.cc@654
PS3, Line 654:   return 0x8040201008040201 * t >> 56;
:exploding_head:


http://gerrit.cloudera.org:8080/#/c/13591/3/src/kudu/common/column_predicate.cc@686
PS3, Line 686:   return n_chunks * 8;
nit: Could you doc the return value?



-- 
To view, visit http://gerrit.cloudera.org:8080/13591
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I9dd062961a3cd2c892997d6aba12684e603628a1
Gerrit-Change-Number: 13591
Gerrit-PatchSet: 3
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-Comment-Date: Wed, 12 Jun 2019 02:36:22 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-2846 (part 1): optimize predicate evaluation for primitives

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Hello Tidy Bot, Kudu Jenkins, Andrew Wong, Adar Dembo, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/13591

to look at the new patch set (#5).

Change subject: KUDU-2846 (part 1): optimize predicate evaluation for primitives
......................................................................

KUDU-2846 (part 1): optimize predicate evaluation for primitives

This changes to an optimized unrolled-by-8 predicate evaluation for
primitive columns.

Performance is improved by up to 7.2x depending on the particular
predicate, type, and nullability (average around 4.8x). Branches are
reduced by about 6.5x and branch-misses by about 22x.

It's possible that hand-coded SIMD could improve on this a little bit
but likely not worth the effort.

perf-stat before:
 Performance counter stats for 'build/latest/bin/column_predicate-test --gtest_filter=*Bench*':
      73905.379627      task-clock (msec)         #    0.997 CPUs utilized
   272,810,081,028      cycles                    #    3.691 GHz
   938,488,388,743      instructions              #    3.44  insn per cycle
   148,052,698,322      branches                  # 2003.274 M/sec
       882,311,138      branch-misses             #    0.60% of all branches

perf-stat after:
 Performance counter stats for 'build/latest/bin/column_predicate-test --gtest_filter=*Bench*':
      15354.077654      task-clock (msec)         #    0.992 CPUs utilized
    56,850,629,856      cycles                    #    3.703 GHz
   181,599,095,960      instructions              #    3.19  insn per cycle
    22,496,453,160      branches                  # 1465.178 M/sec
        38,662,626      branch-misses             #    0.17% of all branches

Detailed results before:
  int8   NOT NULL   (c = 0) 632.1M evals/sec	4.44 cycles/eval
  int8   NULL       (c = 0) 515.6M evals/sec	5.48 cycles/eval
  int8   NOT NULL   (c >= 0) 630.8M evals/sec	4.45 cycles/eval
  int8   NULL       (c >= 0) 426.8M evals/sec	6.64 cycles/eval
  int8   NOT NULL   (c >= 0 AND c < 2) 632.6M evals/sec	4.44 cycles/eval
  int8   NULL       (c >= 0 AND c < 2) 384.7M evals/sec	7.38 cycles/eval
  int16  NOT NULL   (c = 0) 644.4M evals/sec	4.34 cycles/eval
  int16  NULL       (c = 0) 524.6M evals/sec	5.37 cycles/eval
  int16  NOT NULL   (c >= 0) 638.4M evals/sec	4.37 cycles/eval
  int16  NULL       (c >= 0) 458.8M evals/sec	6.17 cycles/eval
  int16  NOT NULL   (c >= 0 AND c < 2) 635.3M evals/sec	4.40 cycles/eval
  int16  NULL       (c >= 0 AND c < 2) 335.1M evals/sec	8.50 cycles/eval
  int32  NOT NULL   (c = 0) 645.2M evals/sec	4.34 cycles/eval
  int32  NULL       (c = 0) 492.6M evals/sec	5.77 cycles/eval
  int32  NOT NULL   (c >= 0) 608.6M evals/sec	4.64 cycles/eval
  int32  NULL       (c >= 0) 440.7M evals/sec	6.48 cycles/eval
  int32  NOT NULL   (c >= 0 AND c < 2) 637.8M evals/sec	4.43 cycles/eval
  int32  NULL       (c >= 0 AND c < 2) 348.0M evals/sec	8.22 cycles/eval
  int64  NOT NULL   (c = 0) 642.7M evals/sec	4.36 cycles/eval
  int64  NULL       (c = 0) 505.3M evals/sec	5.60 cycles/eval
  int64  NOT NULL   (c >= 0) 643.5M evals/sec	4.34 cycles/eval
  int64  NULL       (c >= 0) 472.8M evals/sec	6.00 cycles/eval
  int64  NOT NULL   (c >= 0 AND c < 2) 634.2M evals/sec	4.43 cycles/eval
  int64  NULL       (c >= 0 AND c < 2) 396.7M evals/sec	7.21 cycles/eval
  float  NOT NULL   (c = 0) 604.6M evals/sec	4.63 cycles/eval
  float  NULL       (c = 0) 406.7M evals/sec	7.05 cycles/eval
  float  NOT NULL   (c >= 0) 545.3M evals/sec	5.20 cycles/eval
  float  NULL       (c >= 0) 384.4M evals/sec	7.39 cycles/eval
  float  NOT NULL   (c >= 0 AND c < 2) 583.2M evals/sec	4.80 cycles/eval
  float  NULL       (c >= 0 AND c < 2) 312.2M evals/sec	9.12 cycles/eval
  double NOT NULL   (c = 0) 614.0M evals/sec	4.56 cycles/eval
  double NULL       (c = 0) 471.5M evals/sec	5.99 cycles/eval
  double NOT NULL   (c >= 0) 623.0M evals/sec	4.48 cycles/eval
  double NULL       (c >= 0) 379.9M evals/sec	7.47 cycles/eval
  double NOT NULL   (c >= 0 AND c < 2) 599.5M evals/sec	4.67 cycles/eval
  double NULL       (c >= 0 AND c < 2) 415.2M evals/sec	6.82 cycles/eval

Detailed results after:
  int8   NOT NULL   (c = 0) 3660.3M evals/sec	0.76 cycles/eval
  int8   NULL       (c = 0) 3657.1M evals/sec	0.76 cycles/eval
  int8   NOT NULL   (c >= 0) 3712.0M evals/sec	0.75 cycles/eval
  int8   NULL       (c >= 0) 3618.9M evals/sec	0.78 cycles/eval
  int8   NOT NULL   (c >= 0 AND c < 2) 1661.9M evals/sec	1.73 cycles/eval
  int8   NULL       (c >= 0 AND c < 2) 1663.4M evals/sec	1.77 cycles/eval
  int16  NOT NULL   (c = 0) 3781.4M evals/sec	0.73 cycles/eval
  int16  NULL       (c = 0) 3738.3M evals/sec	0.74 cycles/eval
  int16  NOT NULL   (c >= 0) 3672.9M evals/sec	0.76 cycles/eval
  int16  NULL       (c >= 0) 3767.4M evals/sec	0.75 cycles/eval
  int16  NOT NULL   (c >= 0 AND c < 2) 1654.3M evals/sec	1.77 cycles/eval
  int16  NULL       (c >= 0 AND c < 2) 1651.6M evals/sec	1.72 cycles/eval
  int32  NOT NULL   (c = 0) 2925.1M evals/sec	0.97 cycles/eval
  int32  NULL       (c = 0) 2844.4M evals/sec	0.97 cycles/eval
  int32  NOT NULL   (c >= 0) 2942.7M evals/sec	0.95 cycles/eval
  int32  NULL       (c >= 0) 2900.8M evals/sec	0.98 cycles/eval
  int32  NOT NULL   (c >= 0 AND c < 2) 1641.1M evals/sec	1.73 cycles/eval
  int32  NULL       (c >= 0 AND c < 2) 1638.8M evals/sec	1.75 cycles/eval
  int64  NOT NULL   (c = 0) 3878.6M evals/sec	0.71 cycles/eval
  int64  NULL       (c = 0) 3763.9M evals/sec	0.76 cycles/eval
  int64  NOT NULL   (c >= 0) 2784.4M evals/sec	1.01 cycles/eval
  int64  NULL       (c >= 0) 2782.6M evals/sec	1.01 cycles/eval
  int64  NOT NULL   (c >= 0 AND c < 2) 1671.4M evals/sec	1.71 cycles/eval
  int64  NULL       (c >= 0 AND c < 2) 1741.5M evals/sec	1.64 cycles/eval
  float  NOT NULL   (c = 0) 3940.8M evals/sec	0.72 cycles/eval
  float  NULL       (c = 0) 3820.9M evals/sec	0.72 cycles/eval
  float  NOT NULL   (c >= 0) 4571.4M evals/sec	0.60 cycles/eval
  float  NULL       (c >= 0) 4741.3M evals/sec	0.58 cycles/eval
  float  NOT NULL   (c >= 0 AND c < 2) 1318.0M evals/sec	2.18 cycles/eval
  float  NULL       (c >= 0 AND c < 2) 1262.3M evals/sec	2.28 cycles/eval
  double NOT NULL   (c = 0) 2813.4M evals/sec	1.01 cycles/eval
  double NULL       (c = 0) 2664.6M evals/sec	1.06 cycles/eval
  double NOT NULL   (c >= 0) 3620.8M evals/sec	0.77 cycles/eval
  double NULL       (c >= 0) 3657.2M evals/sec	0.76 cycles/eval
  double NOT NULL   (c >= 0 AND c < 2) 1248.8M evals/sec	2.30 cycles/eval
  double NULL       (c >= 0 AND c < 2) 1253.7M evals/sec	2.28 cycles/eval

Change-Id: I9dd062961a3cd2c892997d6aba12684e603628a1
---
M src/kudu/common/CMakeLists.txt
M src/kudu/common/column_predicate-test.cc
M src/kudu/common/column_predicate.cc
3 files changed, 148 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/91/13591/5
-- 
To view, visit http://gerrit.cloudera.org:8080/13591
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I9dd062961a3cd2c892997d6aba12684e603628a1
Gerrit-Change-Number: 13591
Gerrit-PatchSet: 5
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] KUDU-2846: optimize predicate evaluation for primitives

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Hello Tidy Bot, Kudu Jenkins, Andrew Wong, Adar Dembo, Grant Henke, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/13591

to look at the new patch set (#6).

Change subject: KUDU-2846: optimize predicate evaluation for primitives
......................................................................

KUDU-2846: optimize predicate evaluation for primitives

This changes to an optimized unrolled-by-8 predicate evaluation for
primitive columns.

Performance is improved by up to 7.2x depending on the particular
predicate, type, and nullability (average around 4.8x). Branches are
reduced by about 6.5x and branch-misses by about 22x.

It's possible that hand-coded SIMD could improve on this a little bit
but likely not worth the effort.

perf-stat before:
 Performance counter stats for 'build/latest/bin/column_predicate-test --gtest_filter=*Bench*':
      73905.379627      task-clock (msec)         #    0.997 CPUs utilized
   272,810,081,028      cycles                    #    3.691 GHz
   938,488,388,743      instructions              #    3.44  insn per cycle
   148,052,698,322      branches                  # 2003.274 M/sec
       882,311,138      branch-misses             #    0.60% of all branches

perf-stat after:
 Performance counter stats for 'build/latest/bin/column_predicate-test --gtest_filter=*Bench*':
      15354.077654      task-clock (msec)         #    0.992 CPUs utilized
    56,850,629,856      cycles                    #    3.703 GHz
   181,599,095,960      instructions              #    3.19  insn per cycle
    22,496,453,160      branches                  # 1465.178 M/sec
        38,662,626      branch-misses             #    0.17% of all branches

Detailed results before:
  int8   NOT NULL   (c = 0) 632.1M evals/sec	4.44 cycles/eval
  int8   NULL       (c = 0) 515.6M evals/sec	5.48 cycles/eval
  int8   NOT NULL   (c >= 0) 630.8M evals/sec	4.45 cycles/eval
  int8   NULL       (c >= 0) 426.8M evals/sec	6.64 cycles/eval
  int8   NOT NULL   (c >= 0 AND c < 2) 632.6M evals/sec	4.44 cycles/eval
  int8   NULL       (c >= 0 AND c < 2) 384.7M evals/sec	7.38 cycles/eval
  int16  NOT NULL   (c = 0) 644.4M evals/sec	4.34 cycles/eval
  int16  NULL       (c = 0) 524.6M evals/sec	5.37 cycles/eval
  int16  NOT NULL   (c >= 0) 638.4M evals/sec	4.37 cycles/eval
  int16  NULL       (c >= 0) 458.8M evals/sec	6.17 cycles/eval
  int16  NOT NULL   (c >= 0 AND c < 2) 635.3M evals/sec	4.40 cycles/eval
  int16  NULL       (c >= 0 AND c < 2) 335.1M evals/sec	8.50 cycles/eval
  int32  NOT NULL   (c = 0) 645.2M evals/sec	4.34 cycles/eval
  int32  NULL       (c = 0) 492.6M evals/sec	5.77 cycles/eval
  int32  NOT NULL   (c >= 0) 608.6M evals/sec	4.64 cycles/eval
  int32  NULL       (c >= 0) 440.7M evals/sec	6.48 cycles/eval
  int32  NOT NULL   (c >= 0 AND c < 2) 637.8M evals/sec	4.43 cycles/eval
  int32  NULL       (c >= 0 AND c < 2) 348.0M evals/sec	8.22 cycles/eval
  int64  NOT NULL   (c = 0) 642.7M evals/sec	4.36 cycles/eval
  int64  NULL       (c = 0) 505.3M evals/sec	5.60 cycles/eval
  int64  NOT NULL   (c >= 0) 643.5M evals/sec	4.34 cycles/eval
  int64  NULL       (c >= 0) 472.8M evals/sec	6.00 cycles/eval
  int64  NOT NULL   (c >= 0 AND c < 2) 634.2M evals/sec	4.43 cycles/eval
  int64  NULL       (c >= 0 AND c < 2) 396.7M evals/sec	7.21 cycles/eval
  float  NOT NULL   (c = 0) 604.6M evals/sec	4.63 cycles/eval
  float  NULL       (c = 0) 406.7M evals/sec	7.05 cycles/eval
  float  NOT NULL   (c >= 0) 545.3M evals/sec	5.20 cycles/eval
  float  NULL       (c >= 0) 384.4M evals/sec	7.39 cycles/eval
  float  NOT NULL   (c >= 0 AND c < 2) 583.2M evals/sec	4.80 cycles/eval
  float  NULL       (c >= 0 AND c < 2) 312.2M evals/sec	9.12 cycles/eval
  double NOT NULL   (c = 0) 614.0M evals/sec	4.56 cycles/eval
  double NULL       (c = 0) 471.5M evals/sec	5.99 cycles/eval
  double NOT NULL   (c >= 0) 623.0M evals/sec	4.48 cycles/eval
  double NULL       (c >= 0) 379.9M evals/sec	7.47 cycles/eval
  double NOT NULL   (c >= 0 AND c < 2) 599.5M evals/sec	4.67 cycles/eval
  double NULL       (c >= 0 AND c < 2) 415.2M evals/sec	6.82 cycles/eval

Detailed results after:
  int8   NOT NULL   (c = 0) 3660.3M evals/sec	0.76 cycles/eval
  int8   NULL       (c = 0) 3657.1M evals/sec	0.76 cycles/eval
  int8   NOT NULL   (c >= 0) 3712.0M evals/sec	0.75 cycles/eval
  int8   NULL       (c >= 0) 3618.9M evals/sec	0.78 cycles/eval
  int8   NOT NULL   (c >= 0 AND c < 2) 1661.9M evals/sec	1.73 cycles/eval
  int8   NULL       (c >= 0 AND c < 2) 1663.4M evals/sec	1.77 cycles/eval
  int16  NOT NULL   (c = 0) 3781.4M evals/sec	0.73 cycles/eval
  int16  NULL       (c = 0) 3738.3M evals/sec	0.74 cycles/eval
  int16  NOT NULL   (c >= 0) 3672.9M evals/sec	0.76 cycles/eval
  int16  NULL       (c >= 0) 3767.4M evals/sec	0.75 cycles/eval
  int16  NOT NULL   (c >= 0 AND c < 2) 1654.3M evals/sec	1.77 cycles/eval
  int16  NULL       (c >= 0 AND c < 2) 1651.6M evals/sec	1.72 cycles/eval
  int32  NOT NULL   (c = 0) 2925.1M evals/sec	0.97 cycles/eval
  int32  NULL       (c = 0) 2844.4M evals/sec	0.97 cycles/eval
  int32  NOT NULL   (c >= 0) 2942.7M evals/sec	0.95 cycles/eval
  int32  NULL       (c >= 0) 2900.8M evals/sec	0.98 cycles/eval
  int32  NOT NULL   (c >= 0 AND c < 2) 1641.1M evals/sec	1.73 cycles/eval
  int32  NULL       (c >= 0 AND c < 2) 1638.8M evals/sec	1.75 cycles/eval
  int64  NOT NULL   (c = 0) 3878.6M evals/sec	0.71 cycles/eval
  int64  NULL       (c = 0) 3763.9M evals/sec	0.76 cycles/eval
  int64  NOT NULL   (c >= 0) 2784.4M evals/sec	1.01 cycles/eval
  int64  NULL       (c >= 0) 2782.6M evals/sec	1.01 cycles/eval
  int64  NOT NULL   (c >= 0 AND c < 2) 1671.4M evals/sec	1.71 cycles/eval
  int64  NULL       (c >= 0 AND c < 2) 1741.5M evals/sec	1.64 cycles/eval
  float  NOT NULL   (c = 0) 3940.8M evals/sec	0.72 cycles/eval
  float  NULL       (c = 0) 3820.9M evals/sec	0.72 cycles/eval
  float  NOT NULL   (c >= 0) 4571.4M evals/sec	0.60 cycles/eval
  float  NULL       (c >= 0) 4741.3M evals/sec	0.58 cycles/eval
  float  NOT NULL   (c >= 0 AND c < 2) 1318.0M evals/sec	2.18 cycles/eval
  float  NULL       (c >= 0 AND c < 2) 1262.3M evals/sec	2.28 cycles/eval
  double NOT NULL   (c = 0) 2813.4M evals/sec	1.01 cycles/eval
  double NULL       (c = 0) 2664.6M evals/sec	1.06 cycles/eval
  double NOT NULL   (c >= 0) 3620.8M evals/sec	0.77 cycles/eval
  double NULL       (c >= 0) 3657.2M evals/sec	0.76 cycles/eval
  double NOT NULL   (c >= 0 AND c < 2) 1248.8M evals/sec	2.30 cycles/eval
  double NULL       (c >= 0 AND c < 2) 1253.7M evals/sec	2.28 cycles/eval

Change-Id: I9dd062961a3cd2c892997d6aba12684e603628a1
---
M src/kudu/common/CMakeLists.txt
M src/kudu/common/column_predicate-test.cc
M src/kudu/common/column_predicate.cc
3 files changed, 147 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/91/13591/6
-- 
To view, visit http://gerrit.cloudera.org:8080/13591
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I9dd062961a3cd2c892997d6aba12684e603628a1
Gerrit-Change-Number: 13591
Gerrit-PatchSet: 6
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Grant Henke <gr...@apache.org>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] KUDU-2846 (part 1): optimize predicate evaluation for primitives

Posted by "Adar Dembo (Code Review)" <ge...@cloudera.org>.
Adar Dembo has posted comments on this change. ( http://gerrit.cloudera.org:8080/13591 )

Change subject: KUDU-2846 (part 1): optimize predicate evaluation for primitives
......................................................................


Patch Set 1:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/13591/1//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/13591/1//COMMIT_MSG@41
PS1, Line 41: perf-stat after:
Could you include the time elapsed for 'after' too?



-- 
To view, visit http://gerrit.cloudera.org:8080/13591
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I9dd062961a3cd2c892997d6aba12684e603628a1
Gerrit-Change-Number: 13591
Gerrit-PatchSet: 1
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <an...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Comment-Date: Tue, 11 Jun 2019 23:42:20 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-2846 (part 1): optimize predicate evaluation for primitives

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Todd Lipcon has posted comments on this change. ( http://gerrit.cloudera.org:8080/13591 )

Change subject: KUDU-2846 (part 1): optimize predicate evaluation for primitives
......................................................................


Patch Set 1:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/13591/1//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/13591/1//COMMIT_MSG@41
PS1, Line 41: perf-stat after:
> Could you include the time elapsed for 'after' too?
oh, I meant to actually remove it from 'before' because 'task-clock' is the same thing (it's a single-threaded CPU bound workload)



-- 
To view, visit http://gerrit.cloudera.org:8080/13591
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I9dd062961a3cd2c892997d6aba12684e603628a1
Gerrit-Change-Number: 13591
Gerrit-PatchSet: 1
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <an...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-Comment-Date: Tue, 11 Jun 2019 23:50:32 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-2846: optimize predicate evaluation for primitives

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Todd Lipcon has posted comments on this change. ( http://gerrit.cloudera.org:8080/13591 )

Change subject: KUDU-2846: optimize predicate evaluation for primitives
......................................................................


Patch Set 6:

(4 comments)

http://gerrit.cloudera.org:8080/#/c/13591/6//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/13591/6//COMMIT_MSG@8
PS6, Line 8: 
           : This changes to an optimized unrolled-by-8 predicate evaluation for
           : primitive columns.
> Any reason to stop at 8 vs 16 or 32?
for AVX2 there aren't any parallel compare operations that can do more than 8 lanes (there are operations for 8x16, 4x32, 2x64 on a 128-bit vector register, and 8x32 in a 256-bit register). There might be clever ways to get 16x8 to work for some operations but it wasn't obvious so I didn't explore it much. OK with committing this for now and coming back to further optimize later based on whether this still shows up in any profiles?


http://gerrit.cloudera.org:8080/#/c/13591/3/src/kudu/common/column_predicate-test.cc
File src/kudu/common/column_predicate-test.cc:

http://gerrit.cloudera.org:8080/#/c/13591/3/src/kudu/common/column_predicate-test.cc@1538
PS3, Line 1538: pred.Evaluate(b, &selvec);
> Should probably check the final value of num_ret.
I just had this 'num_ret' bit to try to avoid the compiler completely optimizing out the loop, but I think now that I have CycleClock::Now() calls, and given Evaluate is not defined inline, it'll already ensure that the pred.Evaluate() function actually gets called. I'll just remove it.

Actually validating the result would add a fair bit of complexity to the test, considering we use random datasets. I think the AllTypesScanCorrectnessTest already has good coverage (as we saw by the wall of red tests in the first iteration here)


http://gerrit.cloudera.org:8080/#/c/13591/3/src/kudu/common/column_predicate.cc
File src/kudu/common/column_predicate.cc:

http://gerrit.cloudera.org:8080/#/c/13591/3/src/kudu/common/column_predicate.cc@654
PS3, Line 654: // For primitives, it's safe to evaluate a predicate even if the cell is
> :exploding_head:
you and UBSAN both


http://gerrit.cloudera.org:8080/#/c/13591/3/src/kudu/common/column_predicate.cc@686
PS3, Line 686:   return n_chunks * 8;
> nit: Could you doc the return value?
Done



-- 
To view, visit http://gerrit.cloudera.org:8080/13591
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I9dd062961a3cd2c892997d6aba12684e603628a1
Gerrit-Change-Number: 13591
Gerrit-PatchSet: 6
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Grant Henke <gr...@apache.org>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-Comment-Date: Thu, 13 Jun 2019 15:41:04 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-2846 (part 1): optimize predicate evaluation for primitives

Posted by "Andrew Wong (Code Review)" <ge...@cloudera.org>.
Andrew Wong has removed Andrew Wong from this change.  ( http://gerrit.cloudera.org:8080/13591 )

Change subject: KUDU-2846 (part 1): optimize predicate evaluation for primitives
......................................................................


Removed reviewer Andrew Wong.
-- 
To view, visit http://gerrit.cloudera.org:8080/13591
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: deleteReviewer
Gerrit-Change-Id: I9dd062961a3cd2c892997d6aba12684e603628a1
Gerrit-Change-Number: 13591
Gerrit-PatchSet: 3
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] KUDU-2846: optimize predicate evaluation for primitives

Posted by "Andrew Wong (Code Review)" <ge...@cloudera.org>.
Andrew Wong has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/13591 )

Change subject: KUDU-2846: optimize predicate evaluation for primitives
......................................................................

KUDU-2846: optimize predicate evaluation for primitives

This changes to an optimized unrolled-by-8 predicate evaluation for
primitive columns.

Performance is improved by up to 7.2x depending on the particular
predicate, type, and nullability (average around 4.8x). Branches are
reduced by about 6.5x and branch-misses by about 22x.

It's possible that hand-coded SIMD could improve on this a little bit
but likely not worth the effort.

perf-stat before:
 Performance counter stats for 'build/latest/bin/column_predicate-test --gtest_filter=*Bench*':
      73905.379627      task-clock (msec)         #    0.997 CPUs utilized
   272,810,081,028      cycles                    #    3.691 GHz
   938,488,388,743      instructions              #    3.44  insn per cycle
   148,052,698,322      branches                  # 2003.274 M/sec
       882,311,138      branch-misses             #    0.60% of all branches

perf-stat after:
 Performance counter stats for 'build/latest/bin/column_predicate-test --gtest_filter=*Bench*':
      15354.077654      task-clock (msec)         #    0.992 CPUs utilized
    56,850,629,856      cycles                    #    3.703 GHz
   181,599,095,960      instructions              #    3.19  insn per cycle
    22,496,453,160      branches                  # 1465.178 M/sec
        38,662,626      branch-misses             #    0.17% of all branches

Detailed results before:
  int8   NOT NULL   (c = 0) 632.1M evals/sec	4.44 cycles/eval
  int8   NULL       (c = 0) 515.6M evals/sec	5.48 cycles/eval
  int8   NOT NULL   (c >= 0) 630.8M evals/sec	4.45 cycles/eval
  int8   NULL       (c >= 0) 426.8M evals/sec	6.64 cycles/eval
  int8   NOT NULL   (c >= 0 AND c < 2) 632.6M evals/sec	4.44 cycles/eval
  int8   NULL       (c >= 0 AND c < 2) 384.7M evals/sec	7.38 cycles/eval
  int16  NOT NULL   (c = 0) 644.4M evals/sec	4.34 cycles/eval
  int16  NULL       (c = 0) 524.6M evals/sec	5.37 cycles/eval
  int16  NOT NULL   (c >= 0) 638.4M evals/sec	4.37 cycles/eval
  int16  NULL       (c >= 0) 458.8M evals/sec	6.17 cycles/eval
  int16  NOT NULL   (c >= 0 AND c < 2) 635.3M evals/sec	4.40 cycles/eval
  int16  NULL       (c >= 0 AND c < 2) 335.1M evals/sec	8.50 cycles/eval
  int32  NOT NULL   (c = 0) 645.2M evals/sec	4.34 cycles/eval
  int32  NULL       (c = 0) 492.6M evals/sec	5.77 cycles/eval
  int32  NOT NULL   (c >= 0) 608.6M evals/sec	4.64 cycles/eval
  int32  NULL       (c >= 0) 440.7M evals/sec	6.48 cycles/eval
  int32  NOT NULL   (c >= 0 AND c < 2) 637.8M evals/sec	4.43 cycles/eval
  int32  NULL       (c >= 0 AND c < 2) 348.0M evals/sec	8.22 cycles/eval
  int64  NOT NULL   (c = 0) 642.7M evals/sec	4.36 cycles/eval
  int64  NULL       (c = 0) 505.3M evals/sec	5.60 cycles/eval
  int64  NOT NULL   (c >= 0) 643.5M evals/sec	4.34 cycles/eval
  int64  NULL       (c >= 0) 472.8M evals/sec	6.00 cycles/eval
  int64  NOT NULL   (c >= 0 AND c < 2) 634.2M evals/sec	4.43 cycles/eval
  int64  NULL       (c >= 0 AND c < 2) 396.7M evals/sec	7.21 cycles/eval
  float  NOT NULL   (c = 0) 604.6M evals/sec	4.63 cycles/eval
  float  NULL       (c = 0) 406.7M evals/sec	7.05 cycles/eval
  float  NOT NULL   (c >= 0) 545.3M evals/sec	5.20 cycles/eval
  float  NULL       (c >= 0) 384.4M evals/sec	7.39 cycles/eval
  float  NOT NULL   (c >= 0 AND c < 2) 583.2M evals/sec	4.80 cycles/eval
  float  NULL       (c >= 0 AND c < 2) 312.2M evals/sec	9.12 cycles/eval
  double NOT NULL   (c = 0) 614.0M evals/sec	4.56 cycles/eval
  double NULL       (c = 0) 471.5M evals/sec	5.99 cycles/eval
  double NOT NULL   (c >= 0) 623.0M evals/sec	4.48 cycles/eval
  double NULL       (c >= 0) 379.9M evals/sec	7.47 cycles/eval
  double NOT NULL   (c >= 0 AND c < 2) 599.5M evals/sec	4.67 cycles/eval
  double NULL       (c >= 0 AND c < 2) 415.2M evals/sec	6.82 cycles/eval

Detailed results after:
  int8   NOT NULL   (c = 0) 3660.3M evals/sec	0.76 cycles/eval
  int8   NULL       (c = 0) 3657.1M evals/sec	0.76 cycles/eval
  int8   NOT NULL   (c >= 0) 3712.0M evals/sec	0.75 cycles/eval
  int8   NULL       (c >= 0) 3618.9M evals/sec	0.78 cycles/eval
  int8   NOT NULL   (c >= 0 AND c < 2) 1661.9M evals/sec	1.73 cycles/eval
  int8   NULL       (c >= 0 AND c < 2) 1663.4M evals/sec	1.77 cycles/eval
  int16  NOT NULL   (c = 0) 3781.4M evals/sec	0.73 cycles/eval
  int16  NULL       (c = 0) 3738.3M evals/sec	0.74 cycles/eval
  int16  NOT NULL   (c >= 0) 3672.9M evals/sec	0.76 cycles/eval
  int16  NULL       (c >= 0) 3767.4M evals/sec	0.75 cycles/eval
  int16  NOT NULL   (c >= 0 AND c < 2) 1654.3M evals/sec	1.77 cycles/eval
  int16  NULL       (c >= 0 AND c < 2) 1651.6M evals/sec	1.72 cycles/eval
  int32  NOT NULL   (c = 0) 2925.1M evals/sec	0.97 cycles/eval
  int32  NULL       (c = 0) 2844.4M evals/sec	0.97 cycles/eval
  int32  NOT NULL   (c >= 0) 2942.7M evals/sec	0.95 cycles/eval
  int32  NULL       (c >= 0) 2900.8M evals/sec	0.98 cycles/eval
  int32  NOT NULL   (c >= 0 AND c < 2) 1641.1M evals/sec	1.73 cycles/eval
  int32  NULL       (c >= 0 AND c < 2) 1638.8M evals/sec	1.75 cycles/eval
  int64  NOT NULL   (c = 0) 3878.6M evals/sec	0.71 cycles/eval
  int64  NULL       (c = 0) 3763.9M evals/sec	0.76 cycles/eval
  int64  NOT NULL   (c >= 0) 2784.4M evals/sec	1.01 cycles/eval
  int64  NULL       (c >= 0) 2782.6M evals/sec	1.01 cycles/eval
  int64  NOT NULL   (c >= 0 AND c < 2) 1671.4M evals/sec	1.71 cycles/eval
  int64  NULL       (c >= 0 AND c < 2) 1741.5M evals/sec	1.64 cycles/eval
  float  NOT NULL   (c = 0) 3940.8M evals/sec	0.72 cycles/eval
  float  NULL       (c = 0) 3820.9M evals/sec	0.72 cycles/eval
  float  NOT NULL   (c >= 0) 4571.4M evals/sec	0.60 cycles/eval
  float  NULL       (c >= 0) 4741.3M evals/sec	0.58 cycles/eval
  float  NOT NULL   (c >= 0 AND c < 2) 1318.0M evals/sec	2.18 cycles/eval
  float  NULL       (c >= 0 AND c < 2) 1262.3M evals/sec	2.28 cycles/eval
  double NOT NULL   (c = 0) 2813.4M evals/sec	1.01 cycles/eval
  double NULL       (c = 0) 2664.6M evals/sec	1.06 cycles/eval
  double NOT NULL   (c >= 0) 3620.8M evals/sec	0.77 cycles/eval
  double NULL       (c >= 0) 3657.2M evals/sec	0.76 cycles/eval
  double NOT NULL   (c >= 0 AND c < 2) 1248.8M evals/sec	2.30 cycles/eval
  double NULL       (c >= 0 AND c < 2) 1253.7M evals/sec	2.28 cycles/eval

Change-Id: I9dd062961a3cd2c892997d6aba12684e603628a1
Reviewed-on: http://gerrit.cloudera.org:8080/13591
Tested-by: Kudu Jenkins
Reviewed-by: Andrew Wong <aw...@cloudera.com>
---
M src/kudu/common/CMakeLists.txt
M src/kudu/common/column_predicate-test.cc
M src/kudu/common/column_predicate.cc
3 files changed, 147 insertions(+), 13 deletions(-)

Approvals:
  Kudu Jenkins: Verified
  Andrew Wong: Looks good to me, approved

-- 
To view, visit http://gerrit.cloudera.org:8080/13591
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I9dd062961a3cd2c892997d6aba12684e603628a1
Gerrit-Change-Number: 13591
Gerrit-PatchSet: 7
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Grant Henke <gr...@apache.org>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>