|
|
@ -60,8 +60,8 @@ DEFINE_string(benchmarks, |
|
|
|
"randomwithverify," |
|
|
|
"randomwithverify," |
|
|
|
"fill100K," |
|
|
|
"fill100K," |
|
|
|
"crc32c," |
|
|
|
"crc32c," |
|
|
|
"snappycomp," |
|
|
|
"compress," |
|
|
|
"snappyuncomp," |
|
|
|
"uncompress," |
|
|
|
"acquireload," |
|
|
|
"acquireload," |
|
|
|
"fillfromstdin,", |
|
|
|
"fillfromstdin,", |
|
|
|
|
|
|
|
|
|
|
@ -338,6 +338,10 @@ enum rocksdb::CompressionType StringToCompressionType(const char* ctype) { |
|
|
|
return rocksdb::kZlibCompression; |
|
|
|
return rocksdb::kZlibCompression; |
|
|
|
else if (!strcasecmp(ctype, "bzip2")) |
|
|
|
else if (!strcasecmp(ctype, "bzip2")) |
|
|
|
return rocksdb::kBZip2Compression; |
|
|
|
return rocksdb::kBZip2Compression; |
|
|
|
|
|
|
|
else if (!strcasecmp(ctype, "lz4")) |
|
|
|
|
|
|
|
return rocksdb::kLZ4Compression; |
|
|
|
|
|
|
|
else if (!strcasecmp(ctype, "lz4hc")) |
|
|
|
|
|
|
|
return rocksdb::kLZ4HCCompression; |
|
|
|
|
|
|
|
|
|
|
|
fprintf(stdout, "Cannot parse compression type '%s'\n", ctype); |
|
|
|
fprintf(stdout, "Cannot parse compression type '%s'\n", ctype); |
|
|
|
return rocksdb::kSnappyCompression; //default value
|
|
|
|
return rocksdb::kSnappyCompression; //default value
|
|
|
@ -841,7 +845,13 @@ class Benchmark { |
|
|
|
case rocksdb::kBZip2Compression: |
|
|
|
case rocksdb::kBZip2Compression: |
|
|
|
fprintf(stdout, "Compression: bzip2\n"); |
|
|
|
fprintf(stdout, "Compression: bzip2\n"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
case rocksdb::kLZ4Compression: |
|
|
|
|
|
|
|
fprintf(stdout, "Compression: lz4\n"); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case rocksdb::kLZ4HCCompression: |
|
|
|
|
|
|
|
fprintf(stdout, "Compression: lz4hc\n"); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch (FLAGS_rep_factory) { |
|
|
|
switch (FLAGS_rep_factory) { |
|
|
|
case kPrefixHash: |
|
|
|
case kPrefixHash: |
|
|
@ -896,6 +906,16 @@ class Benchmark { |
|
|
|
strlen(text), &compressed); |
|
|
|
strlen(text), &compressed); |
|
|
|
name = "BZip2"; |
|
|
|
name = "BZip2"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
case kLZ4Compression: |
|
|
|
|
|
|
|
result = port::LZ4_Compress(Options().compression_opts, text, |
|
|
|
|
|
|
|
strlen(text), &compressed); |
|
|
|
|
|
|
|
name = "LZ4"; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case kLZ4HCCompression: |
|
|
|
|
|
|
|
result = port::LZ4HC_Compress(Options().compression_opts, text, |
|
|
|
|
|
|
|
strlen(text), &compressed); |
|
|
|
|
|
|
|
name = "LZ4HC"; |
|
|
|
|
|
|
|
break; |
|
|
|
case kNoCompression: |
|
|
|
case kNoCompression: |
|
|
|
assert(false); // cannot happen
|
|
|
|
assert(false); // cannot happen
|
|
|
|
break; |
|
|
|
break; |
|
|
@ -1146,10 +1166,10 @@ class Benchmark { |
|
|
|
method = &Benchmark::Crc32c; |
|
|
|
method = &Benchmark::Crc32c; |
|
|
|
} else if (name == Slice("acquireload")) { |
|
|
|
} else if (name == Slice("acquireload")) { |
|
|
|
method = &Benchmark::AcquireLoad; |
|
|
|
method = &Benchmark::AcquireLoad; |
|
|
|
} else if (name == Slice("snappycomp")) { |
|
|
|
} else if (name == Slice("compress")) { |
|
|
|
method = &Benchmark::SnappyCompress; |
|
|
|
method = &Benchmark::Compress; |
|
|
|
} else if (name == Slice("snappyuncomp")) { |
|
|
|
} else if (name == Slice("uncompress")) { |
|
|
|
method = &Benchmark::SnappyUncompress; |
|
|
|
method = &Benchmark::Uncompress; |
|
|
|
} else if (name == Slice("heapprofile")) { |
|
|
|
} else if (name == Slice("heapprofile")) { |
|
|
|
HeapProfile(); |
|
|
|
HeapProfile(); |
|
|
|
} else if (name == Slice("stats")) { |
|
|
|
} else if (name == Slice("stats")) { |
|
|
@ -1302,23 +1322,47 @@ class Benchmark { |
|
|
|
if (ptr == nullptr) exit(1); // Disable unused variable warning.
|
|
|
|
if (ptr == nullptr) exit(1); // Disable unused variable warning.
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SnappyCompress(ThreadState* thread) { |
|
|
|
void Compress(ThreadState *thread) { |
|
|
|
RandomGenerator gen; |
|
|
|
RandomGenerator gen; |
|
|
|
Slice input = gen.Generate(Options().block_size); |
|
|
|
Slice input = gen.Generate(Options().block_size); |
|
|
|
int64_t bytes = 0; |
|
|
|
int64_t bytes = 0; |
|
|
|
int64_t produced = 0; |
|
|
|
int64_t produced = 0; |
|
|
|
bool ok = true; |
|
|
|
bool ok = true; |
|
|
|
std::string compressed; |
|
|
|
std::string compressed; |
|
|
|
while (ok && bytes < 1024 * 1048576) { // Compress 1G
|
|
|
|
|
|
|
|
ok = port::Snappy_Compress(Options().compression_opts, input.data(), |
|
|
|
// Compress 1G
|
|
|
|
|
|
|
|
while (ok && bytes < int64_t(1) << 30) { |
|
|
|
|
|
|
|
switch (FLAGS_compression_type_e) { |
|
|
|
|
|
|
|
case rocksdb::kSnappyCompression: |
|
|
|
|
|
|
|
ok = port::Snappy_Compress(Options().compression_opts, input.data(), |
|
|
|
|
|
|
|
input.size(), &compressed); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case rocksdb::kZlibCompression: |
|
|
|
|
|
|
|
ok = port::Zlib_Compress(Options().compression_opts, input.data(), |
|
|
|
input.size(), &compressed); |
|
|
|
input.size(), &compressed); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case rocksdb::kBZip2Compression: |
|
|
|
|
|
|
|
ok = port::BZip2_Compress(Options().compression_opts, input.data(), |
|
|
|
|
|
|
|
input.size(), &compressed); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case rocksdb::kLZ4Compression: |
|
|
|
|
|
|
|
ok = port::LZ4_Compress(Options().compression_opts, input.data(), |
|
|
|
|
|
|
|
input.size(), &compressed); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case rocksdb::kLZ4HCCompression: |
|
|
|
|
|
|
|
ok = port::LZ4HC_Compress(Options().compression_opts, input.data(), |
|
|
|
|
|
|
|
input.size(), &compressed); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
ok = false; |
|
|
|
|
|
|
|
} |
|
|
|
produced += compressed.size(); |
|
|
|
produced += compressed.size(); |
|
|
|
bytes += input.size(); |
|
|
|
bytes += input.size(); |
|
|
|
thread->stats.FinishedSingleOp(nullptr); |
|
|
|
thread->stats.FinishedSingleOp(nullptr); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!ok) { |
|
|
|
if (!ok) { |
|
|
|
thread->stats.AddMessage("(snappy failure)"); |
|
|
|
thread->stats.AddMessage("(compression failure)"); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
char buf[100]; |
|
|
|
char buf[100]; |
|
|
|
snprintf(buf, sizeof(buf), "(output: %.1f%%)", |
|
|
|
snprintf(buf, sizeof(buf), "(output: %.1f%%)", |
|
|
@ -1328,24 +1372,78 @@ class Benchmark { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SnappyUncompress(ThreadState* thread) { |
|
|
|
void Uncompress(ThreadState *thread) { |
|
|
|
RandomGenerator gen; |
|
|
|
RandomGenerator gen; |
|
|
|
Slice input = gen.Generate(Options().block_size); |
|
|
|
Slice input = gen.Generate(Options().block_size); |
|
|
|
std::string compressed; |
|
|
|
std::string compressed; |
|
|
|
bool ok = port::Snappy_Compress(Options().compression_opts, input.data(), |
|
|
|
|
|
|
|
input.size(), &compressed); |
|
|
|
bool ok; |
|
|
|
|
|
|
|
switch (FLAGS_compression_type_e) { |
|
|
|
|
|
|
|
case rocksdb::kSnappyCompression: |
|
|
|
|
|
|
|
ok = port::Snappy_Compress(Options().compression_opts, input.data(), |
|
|
|
|
|
|
|
input.size(), &compressed); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case rocksdb::kZlibCompression: |
|
|
|
|
|
|
|
ok = port::Zlib_Compress(Options().compression_opts, input.data(), |
|
|
|
|
|
|
|
input.size(), &compressed); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case rocksdb::kBZip2Compression: |
|
|
|
|
|
|
|
ok = port::BZip2_Compress(Options().compression_opts, input.data(), |
|
|
|
|
|
|
|
input.size(), &compressed); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case rocksdb::kLZ4Compression: |
|
|
|
|
|
|
|
ok = port::LZ4_Compress(Options().compression_opts, input.data(), |
|
|
|
|
|
|
|
input.size(), &compressed); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case rocksdb::kLZ4HCCompression: |
|
|
|
|
|
|
|
ok = port::LZ4HC_Compress(Options().compression_opts, input.data(), |
|
|
|
|
|
|
|
input.size(), &compressed); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
ok = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int64_t bytes = 0; |
|
|
|
int64_t bytes = 0; |
|
|
|
char* uncompressed = new char[input.size()]; |
|
|
|
int decompress_size; |
|
|
|
while (ok && bytes < 1024 * 1048576) { // Compress 1G
|
|
|
|
while (ok && bytes < 1024 * 1048576) { |
|
|
|
ok = port::Snappy_Uncompress(compressed.data(), compressed.size(), |
|
|
|
char *uncompressed = nullptr; |
|
|
|
uncompressed); |
|
|
|
switch (FLAGS_compression_type_e) { |
|
|
|
|
|
|
|
case rocksdb::kSnappyCompression: |
|
|
|
|
|
|
|
// allocate here to make comparison fair
|
|
|
|
|
|
|
|
uncompressed = new char[input.size()]; |
|
|
|
|
|
|
|
ok = port::Snappy_Uncompress(compressed.data(), compressed.size(), |
|
|
|
|
|
|
|
uncompressed); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case rocksdb::kZlibCompression: |
|
|
|
|
|
|
|
uncompressed = port::Zlib_Uncompress( |
|
|
|
|
|
|
|
compressed.data(), compressed.size(), &decompress_size); |
|
|
|
|
|
|
|
ok = uncompressed != nullptr; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case rocksdb::kBZip2Compression: |
|
|
|
|
|
|
|
uncompressed = port::BZip2_Uncompress( |
|
|
|
|
|
|
|
compressed.data(), compressed.size(), &decompress_size); |
|
|
|
|
|
|
|
ok = uncompressed != nullptr; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case rocksdb::kLZ4Compression: |
|
|
|
|
|
|
|
uncompressed = port::LZ4_Uncompress( |
|
|
|
|
|
|
|
compressed.data(), compressed.size(), &decompress_size); |
|
|
|
|
|
|
|
ok = uncompressed != nullptr; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case rocksdb::kLZ4HCCompression: |
|
|
|
|
|
|
|
uncompressed = port::LZ4_Uncompress( |
|
|
|
|
|
|
|
compressed.data(), compressed.size(), &decompress_size); |
|
|
|
|
|
|
|
ok = uncompressed != nullptr; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
ok = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
delete[] uncompressed; |
|
|
|
bytes += input.size(); |
|
|
|
bytes += input.size(); |
|
|
|
thread->stats.FinishedSingleOp(nullptr); |
|
|
|
thread->stats.FinishedSingleOp(nullptr); |
|
|
|
} |
|
|
|
} |
|
|
|
delete[] uncompressed; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!ok) { |
|
|
|
if (!ok) { |
|
|
|
thread->stats.AddMessage("(snappy failure)"); |
|
|
|
thread->stats.AddMessage("(compression failure)"); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
thread->stats.AddBytes(bytes); |
|
|
|
thread->stats.AddBytes(bytes); |
|
|
|
} |
|
|
|
} |
|
|
|