Skip to content

Commit 495fc80

Browse files
author
Ankit Gupta
committed
Merge branch 'master' of https://github.com/facebook/rocksdb
2 parents b18d914 + faf7691 commit 495fc80

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+633
-395
lines changed

Makefile

+12-8
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ endif
1515

1616
ifeq ($(MAKECMDGOALS),shared_lib)
1717
PLATFORM_SHARED_LDFLAGS=-fPIC
18+
OPT += -DNDEBUG
19+
endif
20+
ifeq ($(MAKECMDGOALS),static_lib)
21+
OPT += -DNDEBUG
1822
endif
23+
1924
#-----------------------------------------------
2025

2126
# detect what platform we're building on
@@ -113,8 +118,7 @@ TOOLS = \
113118
db_repl_stress \
114119
blob_store_bench
115120

116-
117-
PROGRAMS = db_bench signal_test table_reader_bench $(TESTS) $(TOOLS)
121+
PROGRAMS = db_bench signal_test table_reader_bench $(TOOLS)
118122
BENCHMARKS = db_bench_sqlite3 db_bench_tree_db table_reader_bench
119123

120124
# The library name is configurable since we are maintaining libraries of both
@@ -160,18 +164,18 @@ endif # PLATFORM_SHARED_EXT
160164
release tags valgrind_check whitebox_crash_test format static_lib shared_lib all \
161165
dbg
162166

163-
all: $(LIBRARY) $(PROGRAMS)
167+
all: $(LIBRARY) $(PROGRAMS) $(TESTS)
164168

165169
static_lib: $(LIBRARY)
166170

167171
shared_lib: $(SHARED)
168172

169-
dbg: $(LIBRARY) $(PROGRAMS)
173+
dbg: $(LIBRARY) $(PROGRAMS) $(TESTS)
170174

171-
# Will also generate shared libraries.
175+
# creates static library and programs
172176
release:
173177
$(MAKE) clean
174-
OPT="-DNDEBUG -O2" $(MAKE) all -j32
178+
OPT="-DNDEBUG -O2" $(MAKE) static_lib $(PROGRAMS) -j32
175179

176180
coverage:
177181
$(MAKE) clean
@@ -184,7 +188,7 @@ check: $(PROGRAMS) $(TESTS) $(TOOLS)
184188
for t in $(TESTS); do echo "***** Running $$t"; ./$$t || exit 1; done
185189
python tools/ldb_test.py
186190

187-
ldb_tests: all $(PROGRAMS) $(TOOLS)
191+
ldb_tests: all $(PROGRAMS) $(TESTS) $(TOOLS)
188192
python tools/ldb_test.py
189193

190194
crash_test: blackbox_crash_test whitebox_crash_test
@@ -220,7 +224,7 @@ valgrind_check: all $(PROGRAMS) $(TESTS)
220224
done
221225

222226
clean:
223-
-rm -f $(PROGRAMS) $(BENCHMARKS) $(LIBRARY) $(SHARED) $(MEMENVLIBRARY) build_config.mk
227+
-rm -f $(PROGRAMS) $(TESTS) $(BENCHMARKS) $(LIBRARY) $(SHARED) $(MEMENVLIBRARY) build_config.mk
224228
-rm -rf ios-x86/* ios-arm/*
225229
-find . -name "*.[od]" -exec rm {} \;
226230
-find . -type f -regex ".*\.\(\(gcda\)\|\(gcno\)\)" -exec rm {} \;

ROCKSDB_LITE.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# RocksDBLite
2+
3+
RocksDBLite is a project focused on mobile use cases, which don't need a lot of fancy things we've built for server workloads and they are very sensitive to binary size. For that reason, we added a compile flag ROCKSDB_LITE that comments out a lot of the nonessential code and keeps the binary lean.
4+
5+
Some examples of the features disabled by ROCKSDB_LITE:
6+
* compiled-in support for LDB tool
7+
* No backupable DB
8+
* No support for replication (which we provide in form of TrasactionalIterator)
9+
* No advanced monitoring tools
10+
* No special-purpose memtables that are highly optimized for specific use cases
11+
12+
When adding a new big feature to RocksDB, please add ROCKSDB_LITE compile guard if:
13+
* Nobody from mobile really needs your feature,
14+
* Your feature is adding a lot of weight to the binary.
15+
16+
Don't add ROCKSDB_LITE compile guard if:
17+
* It would introduce a lot of code complexity. Compile guards make code harder to read. It's a trade-off.
18+
* Your feature is not adding a lot of weight.
19+
20+
If unsure, ask. :)

build_tools/build_detect_platform

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ case "$TARGET_OS" in
100100
;;
101101
IOS)
102102
PLATFORM=IOS
103-
COMMON_FLAGS="$COMMON_FLAGS -DOS_MACOSX -DIOS_CROSS_COMPILE"
103+
COMMON_FLAGS="$COMMON_FLAGS -DOS_MACOSX -DIOS_CROSS_COMPILE -DROCKSDB_LITE"
104104
PLATFORM_SHARED_EXT=dylib
105105
PLATFORM_SHARED_LDFLAGS="-dynamiclib -install_name "
106106
CROSS_COMPILE=true

db/c.cc

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
// Use of this source code is governed by a BSD-style license that can be
88
// found in the LICENSE file. See the AUTHORS file for names of contributors.
99

10+
#ifndef ROCKSDB_LITE
11+
1012
#include "rocksdb/c.h"
1113

1214
#include <stdlib.h>
@@ -1467,3 +1469,5 @@ extern void rocksdb_livefiles_destroy(
14671469
}
14681470

14691471
} // end extern "C"
1472+
1473+
#endif // ROCKSDB_LITE

db/column_family_test.cc

+45-2
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,38 @@ std::string RandomString(Random* rnd, int len) {
2929
}
3030
} // anonymous namespace
3131

32+
// counts how many operations were performed
33+
class EnvCounter : public EnvWrapper {
34+
public:
35+
explicit EnvCounter(Env* base)
36+
: EnvWrapper(base), num_new_writable_file_(0) {}
37+
int GetNumberOfNewWritableFileCalls() {
38+
return num_new_writable_file_;
39+
}
40+
Status NewWritableFile(const std::string& f, unique_ptr<WritableFile>* r,
41+
const EnvOptions& soptions) {
42+
++num_new_writable_file_;
43+
return EnvWrapper::NewWritableFile(f, r, soptions);
44+
}
45+
46+
private:
47+
int num_new_writable_file_;
48+
};
49+
3250
class ColumnFamilyTest {
3351
public:
3452
ColumnFamilyTest() : rnd_(139) {
35-
env_ = Env::Default();
53+
env_ = new EnvCounter(Env::Default());
3654
dbname_ = test::TmpDir() + "/column_family_test";
3755
db_options_.create_if_missing = true;
56+
db_options_.env = env_;
3857
DestroyDB(dbname_, Options(db_options_, column_family_options_));
3958
}
4059

60+
~ColumnFamilyTest() {
61+
delete env_;
62+
}
63+
4164
void Close() {
4265
for (auto h : handles_) {
4366
delete h;
@@ -299,7 +322,7 @@ class ColumnFamilyTest {
299322
DBOptions db_options_;
300323
std::string dbname_;
301324
DB* db_ = nullptr;
302-
Env* env_;
325+
EnvCounter* env_;
303326
Random rnd_;
304327
};
305328

@@ -895,6 +918,26 @@ TEST(ColumnFamilyTest, ReadOnlyDBTest) {
895918
ASSERT_TRUE(!s.ok());
896919
}
897920

921+
TEST(ColumnFamilyTest, DontRollEmptyLogs) {
922+
Open();
923+
CreateColumnFamiliesAndReopen({"one", "two", "three", "four"});
924+
925+
for (int i = 0; i < handles_.size(); ++i) {
926+
PutRandomData(i, 10, 100);
927+
}
928+
int num_writable_file_start = env_->GetNumberOfNewWritableFileCalls();
929+
// this will trigger the flushes
930+
ASSERT_OK(db_->Write(WriteOptions(), nullptr));
931+
932+
for (int i = 0; i < 4; ++i) {
933+
dbfull()->TEST_WaitForFlushMemTable(handles_[i]);
934+
}
935+
int total_new_writable_files =
936+
env_->GetNumberOfNewWritableFileCalls() - num_writable_file_start;
937+
ASSERT_EQ(total_new_writable_files, handles_.size() + 1);
938+
Close();
939+
}
940+
898941
} // namespace rocksdb
899942

900943
int main(int argc, char** argv) {

db/db_filesnapshot.cc

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
// Use of this source code is governed by a BSD-style license that can be
88
// found in the LICENSE file.
99

10+
#ifndef ROCKSDB_LITE
11+
1012
#define __STDC_FORMAT_MACROS
1113
#include <inttypes.h>
1214
#include <algorithm>
@@ -166,3 +168,5 @@ Status DBImpl::GetSortedWalFiles(VectorLogPtr& files) {
166168
}
167169

168170
}
171+
172+
#endif // ROCKSDB_LITE

0 commit comments

Comments
 (0)