Skip to content

Commit

Permalink
NO-ISSUE Adapt rocksdb 6.20.3 (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
linxGnu authored May 24, 2021
1 parent 24124f3 commit 9154c4a
Show file tree
Hide file tree
Showing 47 changed files with 540 additions and 217 deletions.
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ cd $BUILD_PATH && wget https://github.com/lz4/lz4/archive/v${lz4_version}.tar.gz
cmake $CMAKE_REQUIRED_PARAMS -DLZ4_BUILD_LEGACY_LZ4C=OFF -DBUILD_SHARED_LIBS=OFF -DLZ4_POSITION_INDEPENDENT_LIB=ON && make -j16 install && \
cd $BUILD_PATH && rm -rf *

zstd_version="1.4.9"
zstd_version="1.5.0"
cd $BUILD_PATH && wget https://github.com/facebook/zstd/archive/v${zstd_version}.tar.gz && tar xzf v${zstd_version}.tar.gz && \
cd zstd-${zstd_version}/build/cmake && mkdir -p build_place && cd build_place && \
cmake -DZSTD_BUILD_PROGRAMS=OFF -DZSTD_BUILD_CONTRIB=OFF -DZSTD_BUILD_STATIC=ON -DZSTD_BUILD_SHARED=OFF -DZSTD_BUILD_TESTS=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DZSTD_ZLIB_SUPPORT=ON -DZSTD_LZMA_SUPPORT=OFF -DCMAKE_BUILD_TYPE=Release .. && make -j$(nproc) install && \
cd $BUILD_PATH && rm -rf * && ldconfig

rocksdb_version="6.19.3"
rocksdb_version="6.20.3"
cd $BUILD_PATH && wget https://github.com/facebook/rocksdb/archive/v${rocksdb_version}.tar.gz && tar xzf v${rocksdb_version}.tar.gz && cd rocksdb-${rocksdb_version}/ && \
mkdir -p build_place && cd build_place && cmake -DCMAKE_BUILD_TYPE=Release $CMAKE_REQUIRED_PARAMS -DCMAKE_PREFIX_PATH=$INSTALL_PREFIX -DWITH_TESTS=OFF -DWITH_GFLAGS=OFF \
-DWITH_BENCHMARK_TOOLS=OFF -DWITH_TOOLS=OFF -DWITH_MD_LIBRARY=OFF -DWITH_RUNTIME_DEBUG=OFF -DROCKSDB_BUILD_SHARED=OFF -DWITH_SNAPPY=ON -DWITH_LZ4=ON -DWITH_ZLIB=ON \
Expand Down
9 changes: 9 additions & 0 deletions cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ func (c *Cache) GetCapacity() uint64 {
return uint64(C.rocksdb_cache_get_capacity(c.c))
}

// Disowndata call this on shutdown if you want to speed it up. Cache will disown
// any underlying data and will not free it on delete. This call will leak
// memory - call this only if you're shutting down the process.
// Any attempts of using cache after this call will fail terribly.
// Always delete the DB object before calling this method!
func (c *Cache) DisownData() {
C.rocksdb_cache_disown_data(c.c)
}

// Destroy deallocates the Cache object.
func (c *Cache) Destroy() {
C.rocksdb_cache_destroy(c.c)
Expand Down
2 changes: 2 additions & 0 deletions cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ func TestCache(t *testing.T) {
require.EqualValues(t, 19, cache.GetCapacity())
cache.SetCapacity(128)
require.EqualValues(t, 128, cache.GetCapacity())

cache.DisownData()
}
2 changes: 1 addition & 1 deletion db.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

var (
// ErrColumnFamilyMustMatch indicates number of column family names and options must match.
ErrColumnFamilyMustMatch = fmt.Errorf("Must provide the same number of column family names and options")
ErrColumnFamilyMustMatch = fmt.Errorf("must provide the same number of column family names and options")
)

// Range is a range of keys in the database. GetApproximateSizes calls with it
Expand Down
2 changes: 1 addition & 1 deletion dist/linux_amd64/include/rocksdb/advanced_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ struct AdvancedColumnFamilyOptions {
// updated from the file system.
// Pre-req: This needs max_open_files to be set to -1.
// In Level: Non-bottom-level files older than TTL will go through the
// compation process.
// compaction process.
// In FIFO: Files older than TTL will be deleted.
// unit: seconds. Ex: 1 day = 1 * 24 * 60 * 60
// In FIFO, this option will have the same meaning as
Expand Down
33 changes: 33 additions & 0 deletions dist/linux_amd64/include/rocksdb/c.h
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,37 @@ extern ROCKSDB_LIBRARY_API unsigned char
rocksdb_options_get_skip_checking_sst_file_sizes_on_db_open(
rocksdb_options_t* opt);

/* Blob Options Settings */
extern ROCKSDB_LIBRARY_API void rocksdb_options_set_enable_blob_files(
rocksdb_options_t* opt, unsigned char val);
extern ROCKSDB_LIBRARY_API unsigned char rocksdb_options_get_enable_blob_files(
rocksdb_options_t* opt);

extern ROCKSDB_LIBRARY_API void rocksdb_options_set_min_blob_size(
rocksdb_options_t* opt, uint64_t val);
extern ROCKSDB_LIBRARY_API uint64_t
rocksdb_options_get_min_blob_size(rocksdb_options_t* opt);

extern ROCKSDB_LIBRARY_API void rocksdb_options_set_blob_file_size(
rocksdb_options_t* opt, uint64_t val);
extern ROCKSDB_LIBRARY_API uint64_t
rocksdb_options_get_blob_file_size(rocksdb_options_t* opt);

extern ROCKSDB_LIBRARY_API void rocksdb_options_set_blob_compression_type(
rocksdb_options_t* opt, int val);
extern ROCKSDB_LIBRARY_API int rocksdb_options_get_blob_compression_type(
rocksdb_options_t* opt);

extern ROCKSDB_LIBRARY_API void rocksdb_options_set_enable_blob_gc(
rocksdb_options_t* opt, unsigned char val);
extern ROCKSDB_LIBRARY_API unsigned char rocksdb_options_get_enable_blob_gc(
rocksdb_options_t* opt);

extern ROCKSDB_LIBRARY_API void rocksdb_options_set_blob_gc_age_cutoff(
rocksdb_options_t* opt, double val);
extern ROCKSDB_LIBRARY_API double rocksdb_options_get_blob_gc_age_cutoff(
rocksdb_options_t* opt);

/* returns a pointer to a malloc()-ed, null terminated string */
extern ROCKSDB_LIBRARY_API char* rocksdb_options_statistics_get_string(
rocksdb_options_t* opt);
Expand Down Expand Up @@ -1712,6 +1743,8 @@ extern ROCKSDB_LIBRARY_API unsigned char rocksdb_flushoptions_get_wait(
extern ROCKSDB_LIBRARY_API rocksdb_cache_t* rocksdb_cache_create_lru(
size_t capacity);
extern ROCKSDB_LIBRARY_API void rocksdb_cache_destroy(rocksdb_cache_t* cache);
extern ROCKSDB_LIBRARY_API void rocksdb_cache_disown_data(
rocksdb_cache_t* cache);
extern ROCKSDB_LIBRARY_API void rocksdb_cache_set_capacity(
rocksdb_cache_t* cache, size_t capacity);
extern ROCKSDB_LIBRARY_API size_t
Expand Down
2 changes: 1 addition & 1 deletion dist/linux_amd64/include/rocksdb/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class Cache {
// - Name-value option pairs -- "capacity=1M; num_shard_bits=4;
// For the LRUCache, the values are defined in LRUCacheOptions.
// @param result The new Cache object
// @return OK if the cache was sucessfully created
// @return OK if the cache was successfully created
// @return NotFound if an invalid name was specified in the value
// @return InvalidArgument if either the options were not valid
static Status CreateFromString(const ConfigOptions& config_options,
Expand Down
2 changes: 1 addition & 1 deletion dist/linux_amd64/include/rocksdb/concurrent_task_limiter.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ConcurrentTaskLimiter {
virtual int32_t GetOutstandingTask() const = 0;
};

// Create a ConcurrentTaskLimiter that can be shared with mulitple CFs
// Create a ConcurrentTaskLimiter that can be shared with multiple CFs
// across RocksDB instances to control concurrent tasks.
//
// @param name: Name of the limiter.
Expand Down
6 changes: 3 additions & 3 deletions dist/linux_amd64/include/rocksdb/configurable.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct DBOptions;
// standard way of configuring objects. A Configurable object can:
// -> Populate itself given:
// - One or more "name/value" pair strings
// - A string repesenting the set of name=value properties
// - A string representing the set of name=value properties
// - A map of name/value properties.
// -> Convert itself into its string representation
// -> Dump itself to a Logger
Expand Down Expand Up @@ -166,7 +166,7 @@ class Configurable {
// This is the inverse of ConfigureFromString.
// @param config_options Controls how serialization happens.
// @param result The string representation of this object.
// @return OK If the options for this object wer successfully serialized.
// @return OK If the options for this object were successfully serialized.
// @return InvalidArgument If one or more of the options could not be
// serialized.
Status GetOptionString(const ConfigOptions& config_options,
Expand Down Expand Up @@ -276,7 +276,7 @@ class Configurable {
// Classes may override this method to provide further specialization (such as
// returning a sub-option)
//
// The default implemntation looks at the registered options. If the
// The default implementation looks at the registered options. If the
// input name matches that of a registered option, the pointer registered
// with that name is returned.
// e.g,, RegisterOptions("X", &my_ptr, ...); GetOptionsPtr("X") returns
Expand Down
6 changes: 3 additions & 3 deletions dist/linux_amd64/include/rocksdb/convenience.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct ConfigOptions {
#ifndef ROCKSDB_LITE

// The following set of functions provide a way to construct RocksDB Options
// from a string or a string-to-string map. Here're the general rule of
// from a string or a string-to-string map. Here is the general rule of
// setting option values from strings by type. Some RocksDB types are also
// supported in these APIs. Please refer to the comment of the function itself
// to find more information about how to config those RocksDB types.
Expand Down Expand Up @@ -149,7 +149,7 @@ struct ConfigOptions {
// ColumnFamilyOptions "new_options".
//
// Below are the instructions of how to config some non-primitive-typed
// options in ColumnFOptions:
// options in ColumnFamilyOptions:
//
// * table_factory:
// table_factory can be configured using our custom nested-option syntax.
Expand Down Expand Up @@ -191,7 +191,7 @@ struct ConfigOptions {
// * {"memtable", "skip_list:5"} is equivalent to setting
// memtable to SkipListFactory(5).
// - PrefixHash:
// Pass "prfix_hash:<hash_bucket_count>" to config memtable
// Pass "prefix_hash:<hash_bucket_count>" to config memtable
// to use PrefixHash, or simply "prefix_hash" to use the default
// PrefixHash.
// [Example]:
Expand Down
14 changes: 7 additions & 7 deletions dist/linux_amd64/include/rocksdb/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ struct RangePtr {
};

// It is valid that files_checksums and files_checksum_func_names are both
// empty (no checksum informaiton is provided for ingestion). Otherwise,
// empty (no checksum information is provided for ingestion). Otherwise,
// their sizes should be the same as external_files. The file order should
// be the same in three vectors and guaranteed by the caller.
struct IngestExternalFileArg {
Expand Down Expand Up @@ -205,11 +205,11 @@ class DB {
// to open the primary instance.
// The secondary_path argument points to a directory where the secondary
// instance stores its info log.
// The column_families argument specifieds a list of column families to open.
// The column_families argument specifies a list of column families to open.
// If any of the column families does not exist, the function returns non-OK
// status.
// The handles is an out-arg corresponding to the opened database column
// familiy handles.
// family handles.
// The dbptr is an out-arg corresponding to the opened secondary instance.
// The pointer points to a heap-allocated database, and the caller should
// delete it after use. Before deleting the dbptr, the user should also
Expand Down Expand Up @@ -745,7 +745,7 @@ class DB {
static const std::string kCFStats;

// "rocksdb.cfstats-no-file-histogram" - returns a multi-line string with
// general columm family stats per-level over db's lifetime ("L<n>"),
// general column family stats per-level over db's lifetime ("L<n>"),
// aggregated over db's lifetime ("Sum"), and aggregated over the
// interval since the last retrieval ("Int").
static const std::string kCFStatsNoFileHistogram;
Expand Down Expand Up @@ -1025,7 +1025,7 @@ class DB {
uint64_t* sizes) = 0;

// Simpler versions of the GetApproximateSizes() method above.
// The include_flags argumenbt must of type DB::SizeApproximationFlags
// The include_flags argument must of type DB::SizeApproximationFlags
// and can not be NONE.
virtual Status GetApproximateSizes(ColumnFamilyHandle* column_family,
const Range* ranges, int n,
Expand Down Expand Up @@ -1368,7 +1368,7 @@ class DB {
virtual void GetLiveFilesMetaData(
std::vector<LiveFileMetaData>* /*metadata*/) {}

// Return a list of all table file checksum info.
// Return a list of all table and blob files checksum info.
// Note: This function might be of limited use because it cannot be
// synchronized with GetLiveFiles.
virtual Status GetLiveFilesChecksumInfo(FileChecksumList* checksum_list) = 0;
Expand Down Expand Up @@ -1612,7 +1612,7 @@ class DB {
}

// IO Tracing operations. Use EndIOTrace() to stop tracing.
virtual Status StartIOTrace(Env* /*env*/, const TraceOptions& /*options*/,
virtual Status StartIOTrace(const TraceOptions& /*options*/,
std::unique_ptr<TraceWriter>&& /*trace_writer*/) {
return Status::NotSupported("StartIOTrace() is not implemented.");
}
Expand Down
16 changes: 14 additions & 2 deletions dist/linux_amd64/include/rocksdb/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ class Env {
virtual Status GetTestDirectory(std::string* path) = 0;

// Create and returns a default logger (an instance of EnvLogger) for storing
// informational messages. Derived classes can overide to provide custom
// informational messages. Derived classes can override to provide custom
// logger.
virtual Status NewLogger(const std::string& fname,
std::shared_ptr<Logger>* result);
Expand Down Expand Up @@ -546,6 +546,13 @@ class Env {
const EnvOptions& env_options,
const ImmutableDBOptions& db_options) const;

// OptimizeForBlobFileRead will create a new EnvOptions object that
// is a copy of the EnvOptions in the parameters, but is optimized for reading
// blob files.
virtual EnvOptions OptimizeForBlobFileRead(
const EnvOptions& env_options,
const ImmutableDBOptions& db_options) const;

// Returns the status of all threads that belong to the current Env.
virtual Status GetThreadList(std::vector<ThreadStatus>* /*thread_list*/) {
return Status::NotSupported("Env::GetThreadList() not supported.");
Expand Down Expand Up @@ -798,7 +805,7 @@ class WritableFile {
virtual ~WritableFile();

// Append data to the end of the file
// Note: A WriteabelFile object must support either Append or
// Note: A WriteableFile object must support either Append or
// PositionedAppend, so the users cannot mix the two.
virtual Status Append(const Slice& data) = 0;

Expand Down Expand Up @@ -1495,6 +1502,11 @@ class EnvWrapper : public Env {
const ImmutableDBOptions& db_options) const override {
return target_->OptimizeForCompactionTableRead(env_options, db_options);
}
EnvOptions OptimizeForBlobFileRead(
const EnvOptions& env_options,
const ImmutableDBOptions& db_options) const override {
return target_->OptimizeForBlobFileRead(env_options, db_options);
}
Status GetFreeSpace(const std::string& path, uint64_t* diskfree) override {
return target_->GetFreeSpace(path, diskfree);
}
Expand Down
4 changes: 2 additions & 2 deletions dist/linux_amd64/include/rocksdb/env_encryption.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class BlockCipher {
// - ROT13 Create a ROT13 Cipher
// - ROT13:nn Create a ROT13 Cipher with block size of nn
// @param result The new cipher object
// @return OK if the cipher was sucessfully created
// @return OK if the cipher was successfully created
// @return NotFound if an invalid name was specified in the value
// @return InvalidArgument if either the options were not valid
static Status CreateFromString(const ConfigOptions& config_options,
Expand Down Expand Up @@ -118,7 +118,7 @@ class EncryptionProvider {
// - CTR Create a CTR provider
// - test://CTR Create a CTR provider and initialize it for tests.
// @param result The new provider object
// @return OK if the provider was sucessfully created
// @return OK if the provider was successfully created
// @return NotFound if an invalid name was specified in the value
// @return InvalidArgument if either the options were not valid
static Status CreateFromString(const ConfigOptions& config_options,
Expand Down
2 changes: 1 addition & 1 deletion dist/linux_amd64/include/rocksdb/file_checksum.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class FileChecksumList {
// Create a new file checksum list.
extern FileChecksumList* NewFileChecksumList();

// Return a shared_ptr of the builtin Crc32c based file checksum generatory
// Return a shared_ptr of the builtin Crc32c based file checksum generator
// factory object, which can be shared to create the Crc32c based checksum
// generator object.
// Note: this implementation is compatible with many other crc32c checksum
Expand Down
42 changes: 39 additions & 3 deletions dist/linux_amd64/include/rocksdb/file_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,36 @@ struct IODebugContext {
// To be set by the FileSystem implementation
std::string msg;

// To be set by the underlying FileSystem implementation.
std::string request_id;

// In order to log required information in IO tracing for different
// operations, Each bit in trace_data stores which corresponding info from
// IODebugContext will be added in the trace. Foreg, if trace_data = 1, it
// means bit at position 0 is set so TraceData::kRequestID (request_id) will
// be logged in the trace record.
//
enum TraceData : char {
// The value of each enum represents the bitwise position for
// that information in trace_data which will be used by IOTracer for
// tracing. Make sure to add them sequentially.
kRequestID = 0,
};
uint64_t trace_data = 0;

IODebugContext() {}

void AddCounter(std::string& name, uint64_t value) {
counters.emplace(name, value);
}

// Called by underlying file system to set request_id and log request_id in
// IOTracing.
void SetRequestId(const std::string& _request_id) {
request_id = _request_id;
trace_data |= (1 << TraceData::kRequestID);
}

std::string ToString() {
std::ostringstream ss;
ss << file_path << ", ";
Expand Down Expand Up @@ -473,7 +497,7 @@ class FileSystem {
IODebugContext* dbg) = 0;

// Create and returns a default logger (an instance of EnvLogger) for storing
// informational messages. Derived classes can overide to provide custom
// informational messages. Derived classes can override to provide custom
// logger.
virtual IOStatus NewLogger(const std::string& fname, const IOOptions& io_opts,
std::shared_ptr<Logger>* result,
Expand Down Expand Up @@ -526,6 +550,13 @@ class FileSystem {
const FileOptions& file_options,
const ImmutableDBOptions& db_options) const;

// OptimizeForBlobFileRead will create a new FileOptions object that
// is a copy of the FileOptions in the parameters, but is optimized for
// reading blob files.
virtual FileOptions OptimizeForBlobFileRead(
const FileOptions& file_options,
const ImmutableDBOptions& db_options) const;

// This seems to clash with a macro on Windows, so #undef it here
#ifdef GetFreeSpace
#undef GetFreeSpace
Expand Down Expand Up @@ -725,7 +756,7 @@ class FSRandomAccessFile {
};

// A data structure brings the data verification information, which is
// used togther with data being written to a file.
// used together with data being written to a file.
struct DataVerificationInfo {
// checksum of the data being written.
Slice checksum;
Expand Down Expand Up @@ -753,7 +784,7 @@ class FSWritableFile {
virtual ~FSWritableFile() {}

// Append data to the end of the file
// Note: A WriteabelFile object must support either Append or
// Note: A WriteableFile object must support either Append or
// PositionedAppend, so the users cannot mix the two.
virtual IOStatus Append(const Slice& data, const IOOptions& options,
IODebugContext* dbg) = 0;
Expand Down Expand Up @@ -1265,6 +1296,11 @@ class FileSystemWrapper : public FileSystem {
const ImmutableDBOptions& db_options) const override {
return target_->OptimizeForCompactionTableRead(file_options, db_options);
}
FileOptions OptimizeForBlobFileRead(
const FileOptions& file_options,
const ImmutableDBOptions& db_options) const override {
return target_->OptimizeForBlobFileRead(file_options, db_options);
}
IOStatus GetFreeSpace(const std::string& path, const IOOptions& options,
uint64_t* diskfree, IODebugContext* dbg) override {
return target_->GetFreeSpace(path, options, diskfree, dbg);
Expand Down
Loading

0 comments on commit 9154c4a

Please sign in to comment.