forked from apache/kudu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Import Impala's multi-bit RLE: - Updated the fixed-size buffer code to use faststring - Re-implemented single-bit RLE APIs introduced in Kudu - Templatize RleEncoder/Decoder (not all APIs are passed the type, also allows the compiler to generate type-specific code. NB: buffered values remain uint64_t for performance) - Remove BitWriter#Finish as we no longer write partially-populated bytes - Import bit-util.h & test from Impala, should merge with bitmap.h later - Fix some lint warnings * Add bit stream read/write and RLE microbenchmark, performance on release builds is preserved. Benchmark results before: BooleanBitStream(Prealloc) 35.791540 task-clock # 0.986 CPUs utilized 3 context-switches # 0.000 M/sec 0 CPU-migrations # 0.000 M/sec 983 page-faults # 0.027 M/sec 64,126,619 cycles # 1.792 GHz [77.75%] 30,326,772 stalled-cycles-frontend # 47.29% frontend cycles idle [77.64%] 6,513,738 stalled-cycles-backend # 10.16% backend cycles idle [75.74%] 112,617,774 instructions # 1.76 insns per cycle # 0.27 stalled cycles per insn [88.85%] 30,659,968 branches # 856.626 M/sec [88.84%] 30,433 branch-misses # 0.10% of all branches [86.20%] 0.036281802 seconds time elapsed BooleanRLE(Prealloc) 1034.815160 task-clock # 0.998 CPUs utilized 87 context-switches # 0.000 M/sec 3 CPU-migrations # 0.000 M/sec 743 page-faults # 0.001 M/sec 3,016,920,461 cycles # 2.915 GHz [83.37%] 61,362,300 stalled-cycles-frontend # 2.03% frontend cycles idle [83.39%] 234,655,764 stalled-cycles-backend # 7.78% backend cycles idle [66.78%] 7,886,418,908 instructions # 2.61 insns per cycle # 0.03 stalled cycles per insn [83.36%] 2,960,156,594 branches # 2860.566 M/sec [83.43%] 68,001 branch-misses # 0.00% of all branches [83.31%] 1.036906394 seconds time elapsed Benchmark results after: BooleanBitStream(Prealloc) 30.804692 task-clock # 0.984 CPUs utilized 3 context-switches # 0.000 M/sec 0 CPU-migrations # 0.000 M/sec 983 page-faults # 0.032 M/sec 70,225,460 cycles # 2.280 GHz [74.17%] 8,950,196 stalled-cycles-frontend # 12.74% frontend cycles idle [86.58%] 5,749,925 stalled-cycles-backend # 8.19% backend cycles idle [74.19%] 169,178,749 instructions # 2.41 insns per cycle # 0.05 stalled cycles per insn [87.09%] 37,462,695 branches # 1216.136 M/sec [86.92%] 25,178 branch-misses # 0.07% of all branches [81.07%] 0.031313790 seconds time elapsed BooleanRLE(Prealloc) 1019.328238 task-clock # 0.998 CPUs utilized 86 context-switches # 0.000 M/sec 1 CPU-migrations # 0.000 M/sec 743 page-faults # 0.001 M/sec 2,988,429,141 cycles # 2.932 GHz [83.16%] 22,229,870 stalled-cycles-frontend # 0.74% frontend cycles idle [83.10%] 154,395,031 stalled-cycles-backend # 5.17% backend cycles idle [67.00%] 7,902,188,553 instructions # 2.64 insns per cycle # 0.02 stalled cycles per insn [83.54%] 2,951,981,394 branches # 2896.007 M/sec [83.57%] 51,824 branch-misses # 0.00% of all branches [83.35%] 1.021079053 seconds time elapsed Change-Id: Id442121b6bc169ac51f73d626be4139de44d29a0 Reviewed-on: http://gerrit.ent.cloudera.com:8080/151 Tested-by: Todd Lipcon <[email protected]> Reviewed-by: Todd Lipcon <[email protected]>
- Loading branch information
1 parent
044360f
commit a268c03
Showing
12 changed files
with
586 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ oprofile_data | |
*.proxy.h | ||
protoc-gen-krpc | ||
tpch1 | ||
rle | ||
cfile-dump | ||
rwlock-perf | ||
rpc-bench |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// Copyright (c) 2013, Cloudera, inc. | ||
// | ||
// Micro benchmark for writing/reading bit streams and Kudu specific | ||
// run-length encoding (RLE) APIs. Currently only covers booleans and | ||
// the most performance sensitive APIs. NB: Impala contains a RLE | ||
// micro benchmark (rle-benchmark.cc). | ||
// | ||
|
||
#include <glog/logging.h> | ||
|
||
#include "util/bit-stream-utils.h" | ||
#include "util/rle-encoding.h" | ||
#include "util/stopwatch.h" | ||
|
||
namespace kudu { | ||
|
||
// Measure writing and reading single-bit streams | ||
void BooleanBitStream() { | ||
const int num_iters = 1024 * 1024; | ||
|
||
faststring buffer(1024 * 1024); | ||
BitWriter writer(&buffer); | ||
|
||
// Write alternating strings of repeating 0's and 1's | ||
for (int i = 0; i < num_iters; ++i) { | ||
writer.PutValue(i % 2, 1); | ||
writer.PutValue(i % 2, 1); | ||
writer.PutValue(i % 2, 1); | ||
writer.PutValue(i % 2, 1); | ||
writer.PutValue(i % 2, 1); | ||
writer.PutValue(i % 2, 1); | ||
writer.PutValue(i % 2, 1); | ||
writer.PutValue(i % 2, 1); | ||
} | ||
writer.Flush(); | ||
|
||
LOG(INFO) << "Wrote " << writer.bytes_written() << " bytes"; | ||
|
||
BitReader reader(buffer.data(), writer.bytes_written()); | ||
for (int i = 0; i < num_iters; ++i) { | ||
bool val; | ||
reader.GetValue(1, &val); | ||
reader.GetValue(1, &val); | ||
reader.GetValue(1, &val); | ||
reader.GetValue(1, &val); | ||
reader.GetValue(1, &val); | ||
reader.GetValue(1, &val); | ||
reader.GetValue(1, &val); | ||
reader.GetValue(1, &val); | ||
} | ||
} | ||
|
||
// Measure bulk puts and decoding runs of RLE bools | ||
void BooleanRLE() { | ||
const int num_iters = 3 * 1024; | ||
|
||
faststring buffer(45 * 1024); | ||
RleEncoder<bool> encoder(&buffer, 1); | ||
|
||
for (int i = 0; i < num_iters; i++) { | ||
encoder.Put(false, 100 * 1024); | ||
encoder.Put(true, 3); | ||
encoder.Put(false, 3); | ||
encoder.Put(true, 213 * 1024); | ||
encoder.Put(false, 300); | ||
encoder.Put(true, 8); | ||
encoder.Put(false, 4); | ||
} | ||
|
||
LOG(INFO) << "Wrote " << encoder.len() << " bytes"; | ||
|
||
RleDecoder<bool> decoder(buffer.data(), encoder.len(), 1); | ||
bool val = false; | ||
size_t run_length; | ||
for (int i = 0; i < num_iters; i++) { | ||
decoder.GetNextRun(&val, &run_length); | ||
decoder.GetNextRun(&val, &run_length); | ||
decoder.GetNextRun(&val, &run_length); | ||
decoder.GetNextRun(&val, &run_length); | ||
decoder.GetNextRun(&val, &run_length); | ||
decoder.GetNextRun(&val, &run_length); | ||
decoder.GetNextRun(&val, &run_length); | ||
} | ||
} | ||
|
||
} // namespace kudu | ||
|
||
int main(int argc, char **argv) { | ||
FLAGS_logtostderr = 1; | ||
google::InitGoogleLogging(argv[0]); | ||
google::ParseCommandLineFlags(&argc, &argv, true); | ||
|
||
LOG_TIMING(INFO, "BooleanBitStream") { | ||
kudu::BooleanBitStream(); | ||
} | ||
|
||
LOG_TIMING(INFO, "BooleanRLE") { | ||
kudu::BooleanRLE(); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.