Merge branch 'master' into performance
This commit is contained in:
commit
17a222670b
1
.gitignore
vendored
1
.gitignore
vendored
@ -19,5 +19,4 @@ sst_dump
|
||||
util/build_version.cc
|
||||
build_tools/VALGRIND_LOGS/
|
||||
coverage/COVERAGE_REPORT
|
||||
util/build_version.cc.tmp
|
||||
.gdbhistory
|
||||
|
@ -5,38 +5,18 @@
|
||||
# is then built as a regular source file as part of the compilation process.
|
||||
# One can run "strings executable_filename | grep _build_" to find the version of
|
||||
# the source that we used to build the executable file.
|
||||
#
|
||||
|
||||
# create git version file
|
||||
VFILE=$PWD/util/build_version.cc.tmp
|
||||
trap "rm $VFILE" EXIT
|
||||
OUTFILE="$PWD/util/build_version.cc"
|
||||
|
||||
# check to see if git is in the path
|
||||
which git > /dev/null
|
||||
|
||||
if [ "$?" = 0 ]; then
|
||||
env -i git rev-parse HEAD 2>&1 |
|
||||
awk '
|
||||
BEGIN {
|
||||
print "#include \"build_version.h\"\n"
|
||||
}
|
||||
{ print "const char* rocksdb_build_git_sha = \"rocksdb_build_git_sha:" $0"\";" }
|
||||
' > ${VFILE}
|
||||
else
|
||||
echo "git not found" |
|
||||
awk '
|
||||
BEGIN {
|
||||
print "#include \"build_version.h\""
|
||||
}
|
||||
{ print "const char* rocksdb_build_git_sha = \"rocksdb_build_git_sha:git not found\";" }
|
||||
' > ${VFILE}
|
||||
GIT_SHA=""
|
||||
if command -v git >/dev/null 2>&1; then
|
||||
GIT_SHA=$(git rev-parse HEAD 2>/dev/null)
|
||||
fi
|
||||
|
||||
echo "const char* rocksdb_build_git_datetime = \"rocksdb_build_git_datetime:$(date)\";" >> ${VFILE}
|
||||
echo "const char* rocksdb_build_compile_date = __DATE__;" >> ${VFILE}
|
||||
echo "const char* rocksdb_build_compile_time = __TIME__;" >> ${VFILE}
|
||||
|
||||
OUTFILE=$PWD/util/build_version.cc
|
||||
if [ ! -e $OUTFILE ] || ! cmp -s $VFILE $OUTFILE; then
|
||||
cp $VFILE $OUTFILE
|
||||
fi
|
||||
cat > "${OUTFILE}" <<EOF
|
||||
#include "build_version.h"
|
||||
const char* rocksdb_build_git_sha = "rocksdb_build_git_sha:${GIT_SHA}";
|
||||
const char* rocksdb_build_git_datetime = "rocksdb_build_git_datetime:$(date)";
|
||||
const char* rocksdb_build_compile_date = __DATE__;
|
||||
const char* rocksdb_build_compile_time = __TIME__;
|
||||
EOF
|
||||
|
@ -244,6 +244,7 @@ DBImpl::DBImpl(const Options& options, const std::string& dbname)
|
||||
super_version_(nullptr),
|
||||
tmp_batch_(),
|
||||
bg_compaction_scheduled_(0),
|
||||
bg_manual_only_(0),
|
||||
bg_flush_scheduled_(0),
|
||||
bg_logstats_scheduled_(false),
|
||||
manual_compaction_(nullptr),
|
||||
@ -1608,45 +1609,44 @@ void DBImpl::TEST_CompactRange(int level, const Slice* begin,const Slice* end) {
|
||||
|
||||
MutexLock l(&mutex_);
|
||||
|
||||
// When a manual compaction arrives, temporarily throttle down
|
||||
// the number of background compaction threads to 1. This is
|
||||
// needed to ensure that this manual compaction can compact
|
||||
// any range of keys/files. We artificialy increase
|
||||
// bg_compaction_scheduled_ by a large number, this causes
|
||||
// the system to have a single background thread. Now,
|
||||
// this manual compaction can progress without stomping
|
||||
// on any other concurrent compactions.
|
||||
const int LargeNumber = 10000000;
|
||||
const int newvalue = options_.max_background_compactions-1;
|
||||
bg_compaction_scheduled_ += LargeNumber;
|
||||
while (bg_compaction_scheduled_ > LargeNumber) {
|
||||
Log(options_.info_log, "Manual compaction request waiting for background threads to fall below 1");
|
||||
// When a manual compaction arrives, temporarily disable scheduling of
|
||||
// non-manual compactions and wait until the number of scheduled compaction
|
||||
// jobs drops to zero. This is needed to ensure that this manual compaction
|
||||
// can compact any range of keys/files.
|
||||
//
|
||||
// bg_manual_only_ is non-zero when at least one thread is inside
|
||||
// TEST_CompactRange(), i.e. during that time no other compaction will
|
||||
// get scheduled (see MaybeScheduleFlushOrCompaction).
|
||||
//
|
||||
// Note that the following loop doesn't stop more that one thread calling
|
||||
// TEST_CompactRange() from getting to the second while loop below.
|
||||
// However, only one of them will actually schedule compaction, while
|
||||
// others will wait on a condition variable until it completes.
|
||||
|
||||
++bg_manual_only_;
|
||||
while (bg_compaction_scheduled_ > 0) {
|
||||
Log(options_.info_log,
|
||||
"Manual compaction waiting for all other scheduled background "
|
||||
"compactions to finish");
|
||||
bg_cv_.Wait();
|
||||
}
|
||||
|
||||
Log(options_.info_log, "Manual compaction starting");
|
||||
|
||||
while (!manual.done) {
|
||||
while (manual_compaction_ != nullptr) {
|
||||
while (!manual.done && !shutting_down_.Acquire_Load() && bg_error_.ok()) {
|
||||
assert(bg_manual_only_ > 0);
|
||||
if (manual_compaction_ != nullptr) {
|
||||
// Running either this or some other manual compaction
|
||||
bg_cv_.Wait();
|
||||
}
|
||||
} else {
|
||||
manual_compaction_ = &manual;
|
||||
if (bg_compaction_scheduled_ == LargeNumber) {
|
||||
bg_compaction_scheduled_ = newvalue;
|
||||
}
|
||||
MaybeScheduleFlushOrCompaction();
|
||||
while (manual_compaction_ == &manual) {
|
||||
bg_cv_.Wait();
|
||||
}
|
||||
}
|
||||
assert(!manual.in_progress);
|
||||
|
||||
// wait till there are no background threads scheduled
|
||||
bg_compaction_scheduled_ += LargeNumber;
|
||||
while (bg_compaction_scheduled_ > LargeNumber + newvalue) {
|
||||
Log(options_.info_log, "Manual compaction resetting background threads");
|
||||
bg_cv_.Wait();
|
||||
}
|
||||
bg_compaction_scheduled_ = 0;
|
||||
assert(!manual.in_progress);
|
||||
assert(bg_manual_only_ > 0);
|
||||
--bg_manual_only_;
|
||||
}
|
||||
|
||||
Status DBImpl::FlushMemTable(const FlushOptions& options) {
|
||||
@ -1711,11 +1711,16 @@ void DBImpl::MaybeScheduleFlushOrCompaction() {
|
||||
env_->Schedule(&DBImpl::BGWorkFlush, this, Env::Priority::HIGH);
|
||||
}
|
||||
|
||||
// Schedule BGWorkCompaction if there's a compaction pending (or a memtable
|
||||
// flush, but the HIGH pool is not enabled). Do it only if
|
||||
// max_background_compactions hasn't been reached and, in case
|
||||
// bg_manual_only_ > 0, if it's a manual compaction.
|
||||
if ((manual_compaction_ ||
|
||||
versions_->NeedsCompaction() ||
|
||||
(is_flush_pending && (options_.max_background_flushes <= 0))) &&
|
||||
bg_compaction_scheduled_ < options_.max_background_compactions) {
|
||||
// compaction needed, or memtable flush needed but HIGH pool not enabled.
|
||||
bg_compaction_scheduled_ < options_.max_background_compactions &&
|
||||
(!bg_manual_only_ || manual_compaction_)) {
|
||||
|
||||
bg_compaction_scheduled_++;
|
||||
env_->Schedule(&DBImpl::BGWorkCompaction, this, Env::Priority::LOW);
|
||||
}
|
||||
|
@ -389,9 +389,14 @@ class DBImpl : public DB {
|
||||
// part of ongoing compactions.
|
||||
std::set<uint64_t> pending_outputs_;
|
||||
|
||||
// count how many background compaction been scheduled or is running?
|
||||
// count how many background compactions are running or have been scheduled
|
||||
int bg_compaction_scheduled_;
|
||||
|
||||
// If non-zero, MaybeScheduleFlushOrCompaction() will only schedule manual
|
||||
// compactions (if manual_compaction_ is not null). This mechanism enables
|
||||
// manual compactions to wait until all other compactions are finished.
|
||||
int bg_manual_only_;
|
||||
|
||||
// number of background memtable flush jobs, submitted to the HIGH pool
|
||||
int bg_flush_scheduled_;
|
||||
|
||||
|
@ -17,7 +17,7 @@ using namespace std;
|
||||
|
||||
class AutoVectorTest { };
|
||||
|
||||
const size_t kSize = 8;
|
||||
const unsigned long kSize = 8;
|
||||
TEST(AutoVectorTest, PushBackAndPopBack) {
|
||||
autovector<size_t, kSize> vec;
|
||||
ASSERT_TRUE(vec.empty());
|
||||
|
Loading…
Reference in New Issue
Block a user