Skip to content

Commit 588bca2

Browse files
committed
RocksDBLite
Summary: Introducing RocksDBLite! Removes all the non-essential features and reduces the binary size. This effort should help our adoption on mobile. Binary size when compiling for IOS (`TARGET_OS=IOS m static_lib`) is down to 9MB from 15MB (without stripping) Test Plan: compiles :) Reviewers: dhruba, haobo, ljin, sdong, yhchiang Reviewed By: yhchiang CC: leveldb Differential Revision: https://reviews.facebook.net/D17835
1 parent 23c8f89 commit 588bca2

Some content is hidden

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

51 files changed

+507
-348
lines changed

Makefile

+5
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

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/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)