Skip to content

Commit

Permalink
misc: add build properties info to LOG file (#262)
Browse files Browse the repository at this point in the history
 use_rtti, debug level, portable was added to LOG file
  • Loading branch information
RoyBenMoshe authored and udi-speedb committed Nov 12, 2023
1 parent d19eddc commit 2b416d8
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 12 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,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}),)
Expand All @@ -833,7 +837,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
Expand Down
2 changes: 2 additions & 0 deletions db/db_impl/db_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5190,6 +5190,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,
Expand Down
15 changes: 15 additions & 0 deletions include/rocksdb/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ namespace ROCKSDB_NAMESPACE {
// was created.
const std::unordered_map<std::string, std::string>& GetRocksBuildProperties();

// Returns a set of debug properties such as PORTABLE, DEBUG_LEVEL
// and USE_RTTI indicating how was created.
const std::unordered_map<std::string, std::string>& 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)
Expand All @@ -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:
// "<program> from RocksDB <version>.
// 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
56 changes: 45 additions & 11 deletions util/build_version.cc.in
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -45,22 +54,34 @@ static void AddProperty(std::unordered_map<std::string, std::string> *props, con
}
}
}

static std::unordered_map<std::string, std::string>* LoadPropertiesSet() {
auto * properties = new std::unordered_map<std::string, std::string>();
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<std::string, std::string>* LoadPropertiesSet(std::string p) {
if(p == "properties"){
auto * properties = new std::unordered_map<std::string, std::string>();
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<std::string, std::string>();
AddProperty(debug_properties, use_rtti);
AddProperty(debug_properties, debug_level);
AddProperty(debug_properties, portable);
return debug_properties;
}
return properties;
}

const std::unordered_map<std::string, std::string>& GetRocksBuildProperties() {
static std::unique_ptr<std::unordered_map<std::string, std::string>> props(LoadPropertiesSet());
static std::unique_ptr<std::unordered_map<std::string, std::string>> props(LoadPropertiesSet("properties"));
return *props;
}
const std::unordered_map<std::string, std::string>& GetRocksDebugProperties() {
static std::unique_ptr<std::unordered_map<std::string, std::string>> props(LoadPropertiesSet("debug_properties"));
return *props;
}

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 2b416d8

Please sign in to comment.