Skip to content

Commit

Permalink
Adapt RocksDB 8.3.2 (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
linxGnu authored Aug 29, 2023
1 parent f7ca8fe commit fb202b6
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 9 deletions.
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ cd $BUILD_PATH && wget https://github.com/facebook/zstd/archive/v${zstd_version}
# Note: if you don't have a good reason, please do not set -DPORTABLE=ON
#
# This one is set here on purpose of compatibility with github action runtime processor
rocksdb_version="8.1.1"
rocksdb_version="8.3.2"
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 -DWITH_LIBURING=OFF \
-DWITH_ZSTD=ON -DWITH_BZ2=OFF -WITH_GFLAGS=OFF -DPORTABLE=ON .. && make -j16 install/strip && \
-DWITH_ZSTD=ON -DWITH_BZ2=OFF -WITH_GFLAGS=OFF -DPORTABLE=1 .. && make -j16 install/strip && \
cd $BUILD_PATH && rm -rf *
34 changes: 27 additions & 7 deletions c.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
extern "C" {
#endif

#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
Expand Down Expand Up @@ -1719,7 +1718,8 @@ enum {
rocksdb_blob_checksum_time,
rocksdb_blob_decompress_time,
rocksdb_internal_range_del_reseek_count,
rocksdb_total_metric_count = 78
rocksdb_block_read_cpu_time,
rocksdb_total_metric_count = 79
};

extern ROCKSDB_LIBRARY_API void rocksdb_set_perf_level(int);
Expand Down Expand Up @@ -2007,20 +2007,26 @@ extern ROCKSDB_LIBRARY_API rocksdb_cache_t* rocksdb_cache_create_lru(
extern ROCKSDB_LIBRARY_API rocksdb_cache_t*
rocksdb_cache_create_lru_with_strict_capacity_limit(size_t capacity);
extern ROCKSDB_LIBRARY_API rocksdb_cache_t* rocksdb_cache_create_lru_opts(
rocksdb_lru_cache_options_t*);
const rocksdb_lru_cache_options_t*);

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
rocksdb_cache_get_capacity(rocksdb_cache_t* cache);
rocksdb_cache_get_capacity(const rocksdb_cache_t* cache);
extern ROCKSDB_LIBRARY_API size_t
rocksdb_cache_get_usage(const rocksdb_cache_t* cache);
extern ROCKSDB_LIBRARY_API size_t
rocksdb_cache_get_pinned_usage(const rocksdb_cache_t* cache);
extern ROCKSDB_LIBRARY_API size_t
rocksdb_cache_get_usage(rocksdb_cache_t* cache);
rocksdb_cache_get_table_address_count(const rocksdb_cache_t* cache);
extern ROCKSDB_LIBRARY_API size_t
rocksdb_cache_get_pinned_usage(rocksdb_cache_t* cache);
rocksdb_cache_get_occupancy_count(const rocksdb_cache_t* cache);

/* HyperClockCache */

extern ROCKSDB_LIBRARY_API rocksdb_hyper_clock_cache_options_t*
rocksdb_hyper_clock_cache_options_create(size_t capacity,
size_t estimated_entry_charge);
Expand All @@ -2041,7 +2047,8 @@ rocksdb_hyper_clock_cache_options_set_memory_allocator(
extern ROCKSDB_LIBRARY_API rocksdb_cache_t* rocksdb_cache_create_hyper_clock(
size_t capacity, size_t estimated_entry_charge);
extern ROCKSDB_LIBRARY_API rocksdb_cache_t*
rocksdb_cache_create_hyper_clock_opts(rocksdb_hyper_clock_cache_options_t*);
rocksdb_cache_create_hyper_clock_opts(
const rocksdb_hyper_clock_cache_options_t*);

/* DBPath */

Expand Down Expand Up @@ -2541,13 +2548,26 @@ extern ROCKSDB_LIBRARY_API void rocksdb_transaction_multi_get(
const size_t* keys_list_sizes, char** values_list,
size_t* values_list_sizes, char** errs);

extern ROCKSDB_LIBRARY_API void rocksdb_transaction_multi_get_for_update(
rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options,
size_t num_keys, const char* const* keys_list,
const size_t* keys_list_sizes, char** values_list,
size_t* values_list_sizes, char** errs);

extern ROCKSDB_LIBRARY_API void rocksdb_transaction_multi_get_cf(
rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options,
const rocksdb_column_family_handle_t* const* column_families,
size_t num_keys, const char* const* keys_list,
const size_t* keys_list_sizes, char** values_list,
size_t* values_list_sizes, char** errs);

extern ROCKSDB_LIBRARY_API void rocksdb_transaction_multi_get_for_update_cf(
rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options,
const rocksdb_column_family_handle_t* const* column_families,
size_t num_keys, const char* const* keys_list,
const size_t* keys_list_sizes, char** values_list,
size_t* values_list_sizes, char** errs);

extern ROCKSDB_LIBRARY_API char* rocksdb_transactiondb_get(
rocksdb_transactiondb_t* txn_db, const rocksdb_readoptions_t* options,
const char* key, size_t klen, size_t* vlen, char** errptr);
Expand Down
16 changes: 16 additions & 0 deletions cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@ func (c *Cache) GetPinnedUsage() uint64 {
return uint64(C.rocksdb_cache_get_pinned_usage(c.c))
}

// TODO: try to re-enable at next release of RocksDB

// // GetTableAddressCount returns the number of ways the hash function is divided for addressing
// // entries. Zero means "not supported." This is used for inspecting the load
// // factor, along with GetOccupancyCount().
// func (c *Cache) GetTableAddressCount() int {
// return int(rocksdb_cache_get_table_address_count(c.c))
// }

// // GetOccupancyCount returns the number of entries currently tracked in the table. SIZE_MAX
// // means "not supported." This is used for inspecting the load factor, along
// // with GetTableAddressCount().
// func (c *Cache) GetOccupancyCount() int {
// return int(rocksdb_cache_get_occupancy_count(c.c))
// }

// SetCapacity sets capacity of the cache.
func (c *Cache) SetCapacity(value uint64) {
C.rocksdb_cache_set_capacity(c.c, C.size_t(value))
Expand Down

0 comments on commit fb202b6

Please sign in to comment.