From 5fd11853cbde88a3f796105c7db3fe0f8963ff1f Mon Sep 17 00:00:00 2001 From: sdong Date: Fri, 10 Jul 2015 17:35:27 -0700 Subject: [PATCH] Print Fast CRC32 support information in DB LOG Summary: Print whether fast CRC32 is supported in DB info LOG Test Plan: Run db_bench and see it prints out correctly. Reviewers: yhchiang, anthony, kradhakrishnan, igor Reviewed By: igor Subscribers: MarkCallaghan, yoshinorim, leveldb, dhruba Differential Revision: https://reviews.facebook.net/D41733 --- db/db_impl.cc | 7 +++++-- util/crc32c.cc | 8 ++++++++ util/crc32c.h | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/db/db_impl.cc b/db/db_impl.cc index 1c7f734d8..32487dcf9 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -70,6 +70,7 @@ #include "util/build_version.h" #include "util/coding.h" #include "util/compression.h" +#include "util/crc32c.h" #include "util/db_info_dumper.h" #include "util/file_util.h" #include "util/hash_skiplist_rep.h" @@ -194,7 +195,7 @@ CompressionType GetCompressionFlush(const ImmutableCFOptions& ioptions) { } } -void DumpCompressionInfo(Logger* logger) { +void DumpSupportInfo(Logger* logger) { Log(InfoLogLevel::INFO_LEVEL, logger, "Compression algorithms supported:"); Log(InfoLogLevel::INFO_LEVEL, logger, "\tSnappy supported: %d", Snappy_Supported()); @@ -203,6 +204,8 @@ void DumpCompressionInfo(Logger* logger) { Log(InfoLogLevel::INFO_LEVEL, logger, "\tBzip supported: %d", BZip2_Supported()); Log(InfoLogLevel::INFO_LEVEL, logger, "\tLZ4 supported: %d", LZ4_Supported()); + Log(InfoLogLevel::INFO_LEVEL, logger, "Fast CRC32 supported: %d", + crc32c::IsFastCrc32Supported()); } } // namespace @@ -265,7 +268,7 @@ DBImpl::DBImpl(const DBOptions& options, const std::string& dbname) DumpRocksDBBuildVersion(db_options_.info_log.get()); DumpDBFileSummary(db_options_, dbname_); db_options_.Dump(db_options_.info_log.get()); - DumpCompressionInfo(db_options_.info_log.get()); + DumpSupportInfo(db_options_.info_log.get()); LogFlush(db_options_.info_log); } diff --git a/util/crc32c.cc b/util/crc32c.cc index 8f1a09e17..b8d281a27 100644 --- a/util/crc32c.cc +++ b/util/crc32c.cc @@ -383,6 +383,14 @@ static inline Function Choose_Extend() { return isSSE42() ? ExtendImpl : ExtendImpl; } +bool IsFastCrc32Supported() { +#ifdef __SSE4_2__ + return isSSE42(); +#else + return false; +#endif +} + Function ChosenExtend = Choose_Extend(); uint32_t Extend(uint32_t crc, const char* buf, size_t size) { diff --git a/util/crc32c.h b/util/crc32c.h index e5e6e143e..14167c1a0 100644 --- a/util/crc32c.h +++ b/util/crc32c.h @@ -14,6 +14,8 @@ namespace rocksdb { namespace crc32c { +extern bool IsFastCrc32Supported(); + // Return the crc32c of concat(A, data[0,n-1]) where init_crc is the // crc32c of some string A. Extend() is often used to maintain the // crc32c of a stream of data.