Skip to content

Commit 1966b63

Browse files
author
Kai Liu
committed
Merge branch 'master' into perf
2 parents 4e6463e + 4c81383 commit 1966b63

33 files changed

+408
-212
lines changed

INSTALL.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@ libraries. You are on your own.
2525
`sudo apt-get install libsnappy-dev`.
2626
* Install zlib. Try: `sudo apt-get install zlib1g-dev`.
2727
* Install bzip2: `sudo apt-get install libbz2-dev`.
28+
* Install gflags: `sudo apt-get install libgflags-dev`.
2829
* **OS X**:
29-
* Update your xcode to the latest version to get the compiler with
30-
C++ 11 support.
30+
* Install latest C++ compiler that supports C++ 11:
31+
* Update XCode: run `xcode-select --install` (or install it from XCode App's settting).
32+
* Install via [homebrew](http://brew.sh/).
33+
* If you're first time developer in MacOS, you still need to run: `xcode-select --install` in your command line.
34+
* run `brew tap homebrew/dupes; brew install gcc47 --use-llvm` to install gcc 4.7 (or higher).
3135
* Install zlib, bzip2 and snappy libraries for compression.
3236
* Install gflags. We have included a script
3337
`build_tools/mac-install-gflags.sh`, which should automatically install it.

build_tools/build_detect_platform

+6
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,12 @@ if [ "$CROSS_COMPILE" = "true" -o "$FBCODE_BUILD" = "true" ]; then
174174
# Also don't need any compilation tests if compiling on fbcode
175175
true
176176
else
177+
# do fPIC on 64 bit in non-fbcode environment
178+
case "$TARGET_OS" in
179+
x86_64)
180+
PLATFORM_CXXFLAGS="$PLATFORM_CXXFLAGS -fPIC"
181+
esac
182+
177183
# If -std=c++0x works, use <atomic>. Otherwise use port_posix.h.
178184
$CXX $CFLAGS -std=c++0x -x c++ - -o /dev/null 2>/dev/null <<EOF
179185
#include <atomic>

build_tools/fbcode.gcc471.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ CXX="$TOOLCHAIN_EXECUTABLES/gcc/gcc-4.7.1-glibc-2.14.1/bin/g++ $JINCLUDE $SNAPPY
5151
AR=$TOOLCHAIN_EXECUTABLES/binutils/binutils-2.21.1/da39a3e/bin/ar
5252
RANLIB=$TOOLCHAIN_EXECUTABLES/binutils/binutils-2.21.1/da39a3e/bin/ranlib
5353

54-
CFLAGS="-B$TOOLCHAIN_EXECUTABLES/binutils/binutils-2.21.1/da39a3e/bin/gold -m64 -mtune=generic -fPIC"
54+
CFLAGS="-B$TOOLCHAIN_EXECUTABLES/binutils/binutils-2.21.1/da39a3e/bin/gold -m64 -mtune=generic"
5555
CFLAGS+=" -I $TOOLCHAIN_LIB_BASE/jemalloc/$TOOL_JEMALLOC/include -DHAVE_JEMALLOC"
5656
CFLAGS+=" $LIBGCC_INCLUDE $GLIBC_INCLUDE"
5757
CFLAGS+=" -DROCKSDB_PLATFORM_POSIX -DROCKSDB_ATOMIC_PRESENT"

build_tools/fbcode.gcc481.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ CXX="$TOOLCHAIN_EXECUTABLES/gcc/gcc-4.8.1/cc6c9dc/bin/g++ $JINCLUDE $SNAPPY_INCL
5959
AR=$TOOLCHAIN_EXECUTABLES/binutils/binutils-2.21.1/da39a3e/bin/ar
6060
RANLIB=$TOOLCHAIN_EXECUTABLES/binutils/binutils-2.21.1/da39a3e/bin/ranlib
6161

62-
CFLAGS="-B$TOOLCHAIN_EXECUTABLES/binutils/binutils-2.21.1/da39a3e/bin/gold -m64 -mtune=generic -fPIC"
62+
CFLAGS="-B$TOOLCHAIN_EXECUTABLES/binutils/binutils-2.21.1/da39a3e/bin/gold -m64 -mtune=generic"
6363
CFLAGS+=" -nostdlib $LIBGCC_INCLUDE $GLIBC_INCLUDE"
6464
CFLAGS+=" -DROCKSDB_PLATFORM_POSIX -DROCKSDB_ATOMIC_PRESENT"
6565
CFLAGS+=" -DSNAPPY -DGFLAGS -DZLIB -DBZIP2"

build_tools/regression_build_test.sh

+80-22
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,15 @@ function cleanup {
2222
rm -f $STAT_FILE.fillseq
2323
rm -f $STAT_FILE.readrandom
2424
rm -f $STAT_FILE.overwrite
25+
rm -f $STAT_FILE.memtablefillreadrandom
2526
}
2627

2728
trap cleanup EXIT
2829

29-
function send_to_ods {
30-
key="$1"
31-
value="$2"
32-
33-
if [ -z "$value" ];then
34-
echo >&2 "ERROR: Key $key doesn't have a value."
35-
return
36-
fi
37-
curl -s "https://www.intern.facebook.com/intern/agent/ods_set.php?entity=rocksdb_build&key=$key&value=$value" \
38-
--connect-timeout 60
39-
}
40-
4130
make clean
42-
make db_bench -j$(nproc)
31+
OPT=-DNDEBUG make db_bench -j$(nproc)
4332

33+
# measure fillseq + fill up the DB for overwrite benchmark
4434
./db_bench \
4535
--benchmarks=fillseq \
4636
--db=$DATA_DIR \
@@ -57,6 +47,7 @@ make db_bench -j$(nproc)
5747
--disable_wal=1 \
5848
--sync=0 > ${STAT_FILE}.fillseq
5949

50+
# measure overwrite performance
6051
./db_bench \
6152
--benchmarks=overwrite \
6253
--db=$DATA_DIR \
@@ -74,27 +65,94 @@ make db_bench -j$(nproc)
7465
--sync=0 \
7566
--threads=8 > ${STAT_FILE}.overwrite
7667

68+
# fill up the db for readrandom benchmark
69+
./db_bench \
70+
--benchmarks=fillseq \
71+
--db=$DATA_DIR \
72+
--use_existing_db=0 \
73+
--bloom_bits=10 \
74+
--num=$NUM \
75+
--writes=$NUM \
76+
--cache_size=6442450944 \
77+
--cache_numshardbits=6 \
78+
--open_files=55000 \
79+
--statistics=1 \
80+
--histogram=1 \
81+
--disable_data_sync=1 \
82+
--disable_wal=1 \
83+
--sync=0 \
84+
--threads=1 > /dev/null
85+
86+
# measure readrandom
7787
./db_bench \
7888
--benchmarks=readrandom \
7989
--db=$DATA_DIR \
8090
--use_existing_db=1 \
8191
--bloom_bits=10 \
8292
--num=$NUM \
83-
--reads=$((NUM / 100)) \
93+
--reads=$NUM \
8494
--cache_size=6442450944 \
85-
--cache_numshardbits=6 \
95+
--cache_numshardbits=8 \
96+
--open_files=55000 \
97+
--disable_seek_compaction=1 \
98+
--statistics=1 \
99+
--histogram=1 \
100+
--disable_data_sync=1 \
101+
--disable_wal=1 \
102+
--sync=0 \
103+
--threads=32 > ${STAT_FILE}.readrandom
104+
105+
# measure memtable performance -- none of the data gets flushed to disk
106+
./db_bench \
107+
--benchmarks=fillrandom,readrandom, \
108+
--db=$DATA_DIR \
109+
--use_existing_db=0 \
110+
--num=$((NUM / 10)) \
111+
--reads=$NUM \
112+
--cache_size=6442450944 \
113+
--cache_numshardbits=8 \
114+
--write_buffer_size=1000000000 \
86115
--open_files=55000 \
116+
--disable_seek_compaction=1 \
87117
--statistics=1 \
88118
--histogram=1 \
89119
--disable_data_sync=1 \
90120
--disable_wal=1 \
91121
--sync=0 \
92-
--threads=128 > ${STAT_FILE}.readrandom
122+
--value_size=10 \
123+
--threads=32 > ${STAT_FILE}.memtablefillreadrandom
93124

94-
OVERWRITE_OPS=$(awk '/overwrite/ {print $5}' $STAT_FILE.overwrite)
95-
FILLSEQ_OPS=$(awk '/fillseq/ {print $5}' $STAT_FILE.fillseq)
96-
READRANDOM_OPS=$(awk '/readrandom/ {print $5}' $STAT_FILE.readrandom)
125+
# send data to ods
126+
function send_to_ods {
127+
key="$1"
128+
value="$2"
129+
130+
if [ -z "$value" ];then
131+
echo >&2 "ERROR: Key $key doesn't have a value."
132+
return
133+
fi
134+
curl -s "https://www.intern.facebook.com/intern/agent/ods_set.php?entity=rocksdb_build&key=$key&value=$value" \
135+
--connect-timeout 60
136+
}
137+
138+
function send_benchmark_to_ods {
139+
bench="$1"
140+
bench_key="$2"
141+
file="$3"
142+
143+
QPS=$(grep $bench $file | awk '{print $5}')
144+
P50_MICROS=$(grep $bench $file -A 4 | tail -n1 | awk '{print $3}' )
145+
P75_MICROS=$(grep $bench $file -A 4 | tail -n1 | awk '{print $5}' )
146+
P99_MICROS=$(grep $bench $file -A 4 | tail -n1 | awk '{print $7}' )
147+
148+
send_to_ods rocksdb.build.$bench_key.qps $QPS
149+
send_to_ods rocksdb.build.$bench_key.p50_micros $P50_MICROS
150+
send_to_ods rocksdb.build.$bench_key.p75_micros $P75_MICROS
151+
send_to_ods rocksdb.build.$bench_key.p99_micros $P99_MICROS
152+
}
97153

98-
send_to_ods rocksdb.build.overwrite.qps $OVERWRITE_OPS
99-
send_to_ods rocksdb.build.fillseq.qps $FILLSEQ_OPS
100-
send_to_ods rocksdb.build.readrandom.qps $READRANDOM_OPS
154+
send_benchmark_to_ods overwrite overwrite $STAT_FILE.overwrite
155+
send_benchmark_to_ods fillseq fillseq $STAT_FILE.fillseq
156+
send_benchmark_to_ods readrandom readrandom $STAT_FILE.readrandom
157+
send_benchmark_to_ods fillrandom memtablefillrandom $STAT_FILE.memtablefillreadrandom
158+
send_benchmark_to_ods readrandom memtablereadrandom $STAT_FILE.memtablefillreadrandom

db/builder.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ Status BuildTable(const std::string& dbname,
112112

113113
if (this_ikey.type == kTypeMerge) {
114114
// Handle merge-type keys using the MergeHelper
115+
// TODO: pass statistics to MergeUntil
115116
merge.MergeUntil(iter, 0 /* don't worry about snapshot */);
116117
iterator_at_next = true;
117118
if (merge.IsSuccess()) {
@@ -188,10 +189,10 @@ Status BuildTable(const std::string& dbname,
188189
// Finish and check for file errors
189190
if (s.ok() && !options.disableDataSync) {
190191
if (options.use_fsync) {
191-
StopWatch sw(env, options.statistics, TABLE_SYNC_MICROS);
192+
StopWatch sw(env, options.statistics.get(), TABLE_SYNC_MICROS);
192193
s = file->Fsync();
193194
} else {
194-
StopWatch sw(env, options.statistics, TABLE_SYNC_MICROS);
195+
StopWatch sw(env, options.statistics.get(), TABLE_SYNC_MICROS);
195196
s = file->Sync();
196197
}
197198
}

0 commit comments

Comments
 (0)