Skip to content

Commit

Permalink
trigger compaction when kL0_SlowdownWritesTrigger
Browse files Browse the repository at this point in the history
  • Loading branch information
ideawu committed Dec 10, 2013
1 parent 40d3425 commit 7cee72e
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
5 changes: 4 additions & 1 deletion deps/leveldb-1.14.0/db/db_impl.cc
Expand Up @@ -819,8 +819,9 @@ Status DBImpl::FinishCompactionOutputFile(CompactionState* compact,
delete iter;
if (s.ok()) {
Log(options_.info_log,
"Generated table #%llu: %lld keys, %lld bytes",
"Generated table #%llu@%d: %lld keys, %lld bytes",
(unsigned long long) output_number,
compact->compaction->level(),
(unsigned long long) current_entries,
(unsigned long long) current_bytes);

Expand Down Expand Up @@ -1297,6 +1298,8 @@ Status DBImpl::MakeRoomForWrite(bool force) {
} else if (
allow_delay &&
versions_->NumLevelFiles(0) >= config::kL0_SlowdownWritesTrigger) {
// Added by @ideawu, aggressive compaction
MaybeScheduleCompaction();
// We are getting close to hitting a hard limit on the number of
// L0 files. Rather than delaying a single write by several
// seconds when we hit the hard limit, start delaying each
Expand Down
4 changes: 3 additions & 1 deletion src/serv.cpp
Expand Up @@ -165,7 +165,9 @@ static Command commands[] = {
PROC(dump, "b"),
PROC(sync140, "b"),
PROC(info, "r"),
PROC(compact, "wt"),
// doing compaction in a reader thread, because we have one
// writer thread(for performance reason), we don't want to block writes
PROC(compact, "rt"),
PROC(key_range, "r"),

{NULL, NULL, 0, NULL}
Expand Down
56 changes: 56 additions & 0 deletions tools/ssdb-startup.sh
@@ -0,0 +1,56 @@
#!/bin/bash

ssdb_dir=/usr/local/ssdb
config=$ssdb_dir/ssdb.conf
pidfile=$ssdb_dir/var/ssdb.pid

start(){
${ssdb_dir}/ssdb-server -d ${config}
echo "ssdb started."
}

stop(){
if [ ! -f "$pidfile" ]; then
return
fi

pid=`cat $pidfile`
ps_pid=`ps aux | grep "$pid" | grep "$ssdb_dir" | grep -v grep | awk '{print $2}'`

if [ "$pid" = "$ps_pid" ]; then
kill $pid
fi

for((i=0; i<10; i++)) do
sleep 0.5
if [ ! -f "$pidfile" ]; then
break
fi
echo -n "."
done

if [ -f "$pidfile" ]; then
echo "remove obsolete pidfile $pidfile"
rm -f "$pidfile"
fi
echo "ssdb stopped."
}


case "$1" in
'start')
stop
start
;;
'stop')
stop
;;
'restart')
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac

0 comments on commit 7cee72e

Please sign in to comment.