From fe3de0025b6d8358015da671838ef8ed3e7f0931 Mon Sep 17 00:00:00 2001 From: Roy Ben Moshe Date: Sun, 18 Dec 2022 21:49:56 +0200 Subject: [PATCH] misc: add build properties info to LOG file (#262) use_rtti, debug level, portable was added to LOG file --- Makefile | 6 ++++- db/db_impl/db_impl.cc | 2 ++ include/rocksdb/version.h | 15 +++++++++++ util/build_version.cc.in | 56 +++++++++++++++++++++++++++++++-------- 4 files changed, 67 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 4fd873a449..f27db34d95 100644 --- a/Makefile +++ b/Makefile @@ -825,6 +825,10 @@ else git_date := $(shell git log -1 --date=iso --format="%ad" 2>/dev/null | awk '{print $1 " " $2}' 2>/dev/null) endif +use_rtti := $(USE_RTTI) +portable := $(PORTABLE) +debug_level := $(DEBUG_LEVEL) + SPDB_BUILD_TAG ?= ifneq (${SPDB_RELEASE_BUILD},1) ifeq ($(strip ${SPDB_BUILD_TAG}),) @@ -834,7 +838,7 @@ ifneq (${SPDB_RELEASE_BUILD},1) SPDB_BUILD_TAG := ? endif endif -gen_build_version = sed -e s/@GIT_SHA@/$(git_sha)/ -e s:@GIT_TAG@:"$(git_tag)": -e s/@GIT_MOD@/"$(git_mod)"/ -e s/@BUILD_DATE@/"$(build_date)"/ -e s/@GIT_DATE@/"$(git_date)"/ -e 's!@SPDB_BUILD_TAG@!$(SPDB_BUILD_TAG:!=\!)!' -e s/@ROCKSDB_PLUGIN_BUILTINS@/'$(ROCKSDB_PLUGIN_BUILTINS)'/ -e s/@ROCKSDB_PLUGIN_EXTERNS@/"$(ROCKSDB_PLUGIN_EXTERNS)"/ util/build_version.cc.in +gen_build_version = sed -e s/@GIT_SHA@/$(git_sha)/ -e s:@GIT_TAG@:"$(git_tag)": -e s/@GIT_MOD@/"$(git_mod)"/ -e s/@BUILD_DATE@/"$(build_date)"/ -e s/@GIT_DATE@/"$(git_date)"/ -e 's!@SPDB_BUILD_TAG@!$(SPDB_BUILD_TAG:!=\!)!' -e s/@ROCKSDB_PLUGIN_BUILTINS@/'$(ROCKSDB_PLUGIN_BUILTINS)'/ -e s/@ROCKSDB_PLUGIN_EXTERNS@/"$(ROCKSDB_PLUGIN_EXTERNS)"/ -e s/@DEBUG_LEVEL@/"$(debug_level)"/ -e s/@PORTABLE@/"$(portable)"/ -e s/@USE_RTTI@/"$(use_rtti)"/ util/build_version.cc.in # Record the version of the source that we are compiling. # We keep a record of the git revision in this file. It is then built diff --git a/db/db_impl/db_impl.cc b/db/db_impl/db_impl.cc index faacceb100..8b8ffb971a 100644 --- a/db/db_impl/db_impl.cc +++ b/db/db_impl/db_impl.cc @@ -5012,6 +5012,8 @@ void DumpRocksDBBuildVersion(Logger* log) { if (date != props.end()) { ROCKS_LOG_HEADER(log, "Compile date %s", date->second.c_str()); } + ROCKS_LOG_HEADER(log, "Build properties:%s", + GetRocksDebugPropertiesAsString().c_str()); } SequenceNumber DBImpl::GetEarliestMemTableSequenceNumber(SuperVersion* sv, diff --git a/include/rocksdb/version.h b/include/rocksdb/version.h index 74e7bac24b..6ba66ed44c 100644 --- a/include/rocksdb/version.h +++ b/include/rocksdb/version.h @@ -27,6 +27,10 @@ namespace ROCKSDB_NAMESPACE { // was created. const std::unordered_map& GetRocksBuildProperties(); +// Returns a set of debug properties such as PORTABLE, DEBUG_LEVEL +// and USE_RTTI indicating how was created. +const std::unordered_map& GetRocksDebugProperties(); + // Returns the current version of RocksDB as a string (e.g. "6.16.0"). // If with_patch is true, the patch is included (6.16.x). // Otherwise, only major and minor version is included (6.16) @@ -40,4 +44,15 @@ std::string GetRocksVersionAsString(bool with_patch = true); // GetRocksVersionString) is printed. std::string GetRocksBuildInfoAsString(const std::string& program, bool verbose = false); +//// Gets the set of build properties (@see GetRocksBuildProperties) into a +// string. Properties are returned one-per-line, with the first line being: +// " from RocksDB . +// If verbose is true, the full set of properties is +// printed. If verbose is false, only the version information (@see +// GetRocksVersionString) is printed. +std::string GetRocksBuildFlagsAsString(); +//// Gets the set of build debug properties (@see GetRocksDebugProperties()) +// into a string. +// Properties are returned on after another(if defined) in a single line. +std::string GetRocksDebugPropertiesAsString(); } // namespace ROCKSDB_NAMESPACE diff --git a/util/build_version.cc.in b/util/build_version.cc.in index f89d3af11c..2e03800006 100644 --- a/util/build_version.cc.in +++ b/util/build_version.cc.in @@ -25,6 +25,15 @@ static const std::string speedb_build_date = "speedb_build_date:@BUILD_DATE@"; #define SPDB_BUILD_TAG "@SPDB_BUILD_TAG@" static const std::string speedb_build_tag = "speedb_build_tag:" SPDB_BUILD_TAG; +#define USE_RTTI "@USE_RTTI@" +static const std::string use_rtti = "use_rtti:" USE_RTTI; + +#define DEBUG_LEVEL "@DEBUG_LEVEL@" +static const std::string debug_level = "debug_level:" DEBUG_LEVEL; + +#define PORTABLE "@PORTABLE@" +static const std::string portable = "portable:" PORTABLE; + extern "C" { @ROCKSDB_PLUGIN_EXTERNS@ } // extern "C" @@ -45,22 +54,34 @@ static void AddProperty(std::unordered_map *props, con } } } - -static std::unordered_map* LoadPropertiesSet() { - auto * properties = new std::unordered_map(); - AddProperty(properties, speedb_build_git_sha); - AddProperty(properties, speedb_build_git_tag); - AddProperty(properties, speedb_build_date); - if (SPDB_BUILD_TAG[0] == '@') { - AddProperty(properties, "?"); + +static std::unordered_map* LoadPropertiesSet(std::string p) { + if(p == "properties"){ + auto * properties = new std::unordered_map(); + AddProperty(properties, speedb_build_git_sha); + AddProperty(properties, speedb_build_git_tag); + AddProperty(properties, speedb_build_date); + if (SPDB_BUILD_TAG[0] == '@') { + AddProperty(properties, "?"); + } else { + AddProperty(properties, speedb_build_tag); + } + return properties; } else { - AddProperty(properties, speedb_build_tag); + auto * debug_properties = new std::unordered_map(); + AddProperty(debug_properties, use_rtti); + AddProperty(debug_properties, debug_level); + AddProperty(debug_properties, portable); + return debug_properties; } - return properties; } const std::unordered_map& GetRocksBuildProperties() { - static std::unique_ptr> props(LoadPropertiesSet()); + static std::unique_ptr> props(LoadPropertiesSet("properties")); + return *props; +} +const std::unordered_map& GetRocksDebugProperties() { + static std::unique_ptr> props(LoadPropertiesSet("debug_properties")); return *props; } @@ -100,6 +121,19 @@ std::string GetRocksBuildInfoAsString(const std::string& program, bool verbose) info.append(": "); info.append(it.second); } + info.append("\n Build properties:"); + info.append(GetRocksDebugPropertiesAsString()); + } + return info; +} + +std::string GetRocksDebugPropertiesAsString() { + std::string info; + for (const auto& it : GetRocksDebugProperties()) { + info.append(" "); + info.append(it.first); + info.append("="); + info.append(it.second); } return info; }