2017-01-20 21:16:22 +00:00
|
|
|
# Prerequisites for Windows:
|
|
|
|
# This cmake build is for Windows 64-bit only.
|
2015-07-01 23:13:49 +00:00
|
|
|
#
|
|
|
|
# Prerequisites:
|
2022-03-29 20:23:31 +00:00
|
|
|
# You must have at least Visual Studio 2019. Start the Developer Command Prompt window that is a part of Visual Studio installation.
|
2015-07-01 23:13:49 +00:00
|
|
|
# Run the build commands from within the Developer Command Prompt window to have paths to the compiler and runtime libraries set.
|
2015-07-09 21:42:41 +00:00
|
|
|
# You must have git.exe in your %PATH% environment variable.
|
2015-07-01 23:13:49 +00:00
|
|
|
#
|
|
|
|
# To build Rocksdb for Windows is as easy as 1-2-3-4-5:
|
2015-07-15 21:51:51 +00:00
|
|
|
#
|
2015-07-09 21:42:41 +00:00
|
|
|
# 1. Update paths to third-party libraries in thirdparty.inc file
|
2015-07-01 23:13:49 +00:00
|
|
|
# 2. Create a new directory for build artifacts
|
|
|
|
# mkdir build
|
|
|
|
# cd build
|
2015-07-09 21:42:41 +00:00
|
|
|
# 3. Run cmake to generate project files for Windows, add more options to enable required third-party libraries.
|
|
|
|
# See thirdparty.inc for more information.
|
2022-02-05 01:12:03 +00:00
|
|
|
# sample command: cmake -G "Visual Studio 16 2019" -DCMAKE_BUILD_TYPE=Release -DWITH_GFLAGS=1 -DWITH_SNAPPY=1 -DWITH_JEMALLOC=1 -DWITH_JNI=1 ..
|
2015-10-20 20:35:08 +00:00
|
|
|
# 4. Then build the project in debug mode (you may want to add /m[:<N>] flag to run msbuild in <N> parallel threads
|
2018-05-04 22:09:40 +00:00
|
|
|
# or simply /m to use all avail cores)
|
2015-10-20 20:35:08 +00:00
|
|
|
# msbuild rocksdb.sln
|
|
|
|
#
|
|
|
|
# rocksdb.sln build features exclusions of test only code in Release. If you build ALL_BUILD then everything
|
|
|
|
# will be attempted but test only code does not build in Release mode.
|
|
|
|
#
|
2015-09-30 18:20:23 +00:00
|
|
|
# 5. And release mode (/m[:<N>] is also supported)
|
2015-10-20 20:35:08 +00:00
|
|
|
# msbuild rocksdb.sln /p:Configuration=Release
|
2015-07-01 23:13:49 +00:00
|
|
|
#
|
2017-01-20 21:16:22 +00:00
|
|
|
# Linux:
|
|
|
|
#
|
2022-02-05 01:12:03 +00:00
|
|
|
# 1. Install a recent toolchain if you're on a older distro. C++17 required (GCC >= 7, Clang >= 5)
|
2017-01-20 21:16:22 +00:00
|
|
|
# 2. mkdir build; cd build
|
|
|
|
# 3. cmake ..
|
|
|
|
# 4. make -j
|
2015-07-01 23:13:49 +00:00
|
|
|
|
2021-06-01 21:42:06 +00:00
|
|
|
cmake_minimum_required(VERSION 3.10)
|
2019-08-06 02:47:33 +00:00
|
|
|
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/modules/")
|
|
|
|
include(ReadVersion)
|
2021-06-01 21:42:06 +00:00
|
|
|
include(GoogleTest)
|
2019-08-06 02:47:33 +00:00
|
|
|
get_rocksdb_version(rocksdb_VERSION)
|
|
|
|
project(rocksdb
|
|
|
|
VERSION ${rocksdb_VERSION}
|
2022-05-05 16:03:31 +00:00
|
|
|
DESCRIPTION "An embeddable persistent key-value store for fast storage"
|
|
|
|
HOMEPAGE_URL https://rocksdb.org/
|
2019-08-06 02:47:33 +00:00
|
|
|
LANGUAGES CXX C ASM)
|
2015-07-01 23:13:49 +00:00
|
|
|
|
2024-03-12 22:50:40 +00:00
|
|
|
if(APPLE)
|
|
|
|
# On macOS Cmake, when cross-compiling, sometimes CMAKE_SYSTEM_PROCESSOR wrongfully stays
|
|
|
|
# the same as CMAKE_HOST_SYSTEM_PROCESSOR regardless the target CPU.
|
|
|
|
# The manual call to set(CMAKE_SYSTEM_PROCESSOR) has to be set after the project() call.
|
|
|
|
# because project() might reset CMAKE_SYSTEM_PROCESSOR back to the value of CMAKE_HOST_SYSTEM_PROCESSOR.
|
|
|
|
# Check if CMAKE_SYSTEM_PROCESSOR is not equal to CMAKE_OSX_ARCHITECTURES
|
|
|
|
if(NOT CMAKE_OSX_ARCHITECTURES STREQUAL "")
|
|
|
|
if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_OSX_ARCHITECTURES)
|
|
|
|
# Split CMAKE_OSX_ARCHITECTURES into a list
|
|
|
|
string(REPLACE ";" " " ARCH_LIST ${CMAKE_OSX_ARCHITECTURES})
|
|
|
|
separate_arguments(ARCH_LIST UNIX_COMMAND ${ARCH_LIST})
|
|
|
|
# Count the number of architectures
|
|
|
|
list(LENGTH ARCH_LIST ARCH_COUNT)
|
|
|
|
# Ensure that exactly one architecture is specified
|
|
|
|
if(NOT ARCH_COUNT EQUAL 1)
|
|
|
|
message(FATAL_ERROR "CMAKE_OSX_ARCHITECTURES must have exactly one value. Current value: ${CMAKE_OSX_ARCHITECTURES}")
|
|
|
|
endif()
|
|
|
|
set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_OSX_ARCHITECTURES})
|
|
|
|
message(STATUS "CMAKE_SYSTEM_PROCESSOR is manually set to ${CMAKE_SYSTEM_PROCESSOR}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-09-28 18:53:15 +00:00
|
|
|
if(POLICY CMP0042)
|
|
|
|
cmake_policy(SET CMP0042 NEW)
|
|
|
|
endif()
|
|
|
|
|
2019-12-13 19:33:59 +00:00
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
|
|
|
set(default_build_type "Debug")
|
|
|
|
else()
|
|
|
|
set(default_build_type "RelWithDebInfo")
|
|
|
|
endif()
|
|
|
|
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING
|
|
|
|
"Default BUILD_TYPE is ${default_build_type}" FORCE)
|
|
|
|
endif()
|
|
|
|
|
2019-05-31 17:40:39 +00:00
|
|
|
find_program(CCACHE_FOUND ccache)
|
|
|
|
if(CCACHE_FOUND)
|
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
|
|
|
|
endif(CCACHE_FOUND)
|
|
|
|
|
2017-10-27 20:14:07 +00:00
|
|
|
option(WITH_JEMALLOC "build with JeMalloc" OFF)
|
2021-05-21 17:20:58 +00:00
|
|
|
option(WITH_LIBURING "build with liburing" ON)
|
2018-01-05 22:52:57 +00:00
|
|
|
option(WITH_SNAPPY "build with SNAPPY" OFF)
|
|
|
|
option(WITH_LZ4 "build with lz4" OFF)
|
|
|
|
option(WITH_ZLIB "build with zlib" OFF)
|
2018-07-19 22:07:22 +00:00
|
|
|
option(WITH_ZSTD "build with zstd" OFF)
|
2018-10-12 06:22:42 +00:00
|
|
|
option(WITH_WINDOWS_UTF8_FILENAMES "use UTF8 as characterset for opening files, regardles of the system code page" OFF)
|
|
|
|
if (WITH_WINDOWS_UTF8_FILENAMES)
|
|
|
|
add_definitions(-DROCKSDB_WINDOWS_UTF8_FILENAMES)
|
|
|
|
endif()
|
2022-09-12 04:40:11 +00:00
|
|
|
option(ROCKSDB_BUILD_SHARED "Build shared versions of the RocksDB libraries" ON)
|
2021-06-01 21:42:06 +00:00
|
|
|
|
2020-04-20 20:21:34 +00:00
|
|
|
if( NOT DEFINED CMAKE_CXX_STANDARD )
|
2022-02-05 01:12:03 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2020-04-20 20:21:34 +00:00
|
|
|
endif()
|
|
|
|
|
2019-12-13 19:33:59 +00:00
|
|
|
include(CMakeDependentOption)
|
|
|
|
|
2017-04-06 20:54:49 +00:00
|
|
|
if(MSVC)
|
2021-02-23 22:30:05 +00:00
|
|
|
option(WITH_GFLAGS "build with GFlags" OFF)
|
2018-01-05 22:52:57 +00:00
|
|
|
option(WITH_XPRESS "build with windows built in compression" OFF)
|
2022-06-04 02:20:34 +00:00
|
|
|
option(ROCKSDB_SKIP_THIRDPARTY "skip thirdparty.inc" OFF)
|
|
|
|
|
|
|
|
if(NOT ROCKSDB_SKIP_THIRDPARTY)
|
|
|
|
include(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty.inc)
|
|
|
|
endif()
|
2016-09-28 18:53:15 +00:00
|
|
|
else()
|
2020-06-18 16:50:05 +00:00
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" AND NOT CMAKE_SYSTEM_NAME MATCHES "kFreeBSD")
|
2018-03-08 18:18:34 +00:00
|
|
|
# FreeBSD has jemalloc as default malloc
|
2017-04-09 18:15:35 +00:00
|
|
|
# but it does not have all the jemalloc files in include/...
|
2017-04-06 20:54:49 +00:00
|
|
|
set(WITH_JEMALLOC ON)
|
2017-04-09 18:15:35 +00:00
|
|
|
else()
|
|
|
|
if(WITH_JEMALLOC)
|
|
|
|
find_package(JeMalloc REQUIRED)
|
|
|
|
add_definitions(-DROCKSDB_JEMALLOC -DJEMALLOC_NO_DEMANGLE)
|
2019-08-06 02:47:33 +00:00
|
|
|
list(APPEND THIRDPARTY_LIBS JeMalloc::JeMalloc)
|
2017-04-09 18:15:35 +00:00
|
|
|
endif()
|
2017-04-16 18:41:12 +00:00
|
|
|
endif()
|
2018-03-28 17:23:31 +00:00
|
|
|
|
2021-02-23 22:30:05 +00:00
|
|
|
if(MINGW)
|
|
|
|
option(WITH_GFLAGS "build with GFlags" OFF)
|
|
|
|
else()
|
|
|
|
option(WITH_GFLAGS "build with GFlags" ON)
|
|
|
|
endif()
|
2020-06-26 00:21:27 +00:00
|
|
|
set(GFLAGS_LIB)
|
2018-01-05 22:52:57 +00:00
|
|
|
if(WITH_GFLAGS)
|
2020-05-11 17:26:18 +00:00
|
|
|
# Config with namespace available since gflags 2.2.2
|
|
|
|
option(GFLAGS_USE_TARGET_NAMESPACE "Use gflags import target with namespace." ON)
|
|
|
|
find_package(gflags CONFIG)
|
|
|
|
if(gflags_FOUND)
|
|
|
|
if(TARGET ${GFLAGS_TARGET})
|
|
|
|
# Config with GFLAGS_TARGET available since gflags 2.2.0
|
2020-06-26 00:21:27 +00:00
|
|
|
set(GFLAGS_LIB ${GFLAGS_TARGET})
|
2020-05-11 17:26:18 +00:00
|
|
|
else()
|
|
|
|
# Config with GFLAGS_LIBRARIES available since gflags 2.1.0
|
2021-06-01 21:42:06 +00:00
|
|
|
set(GFLAGS_LIB ${gflags_LIBRARIES})
|
2020-05-11 17:26:18 +00:00
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
find_package(gflags REQUIRED)
|
2021-06-01 21:42:06 +00:00
|
|
|
set(GFLAGS_LIB gflags::gflags)
|
2020-05-11 17:26:18 +00:00
|
|
|
endif()
|
2020-06-26 00:21:27 +00:00
|
|
|
include_directories(${GFLAGS_INCLUDE_DIR})
|
|
|
|
list(APPEND THIRDPARTY_LIBS ${GFLAGS_LIB})
|
2019-12-13 19:33:59 +00:00
|
|
|
add_definitions(-DGFLAGS=1)
|
2018-01-05 22:52:57 +00:00
|
|
|
endif()
|
2017-08-14 04:29:53 +00:00
|
|
|
|
2016-09-28 18:53:15 +00:00
|
|
|
if(WITH_SNAPPY)
|
2020-05-11 17:26:18 +00:00
|
|
|
find_package(Snappy CONFIG)
|
|
|
|
if(NOT Snappy_FOUND)
|
|
|
|
find_package(Snappy REQUIRED)
|
|
|
|
endif()
|
2016-09-28 18:53:15 +00:00
|
|
|
add_definitions(-DSNAPPY)
|
2020-05-11 17:26:18 +00:00
|
|
|
list(APPEND THIRDPARTY_LIBS Snappy::snappy)
|
2016-09-28 18:53:15 +00:00
|
|
|
endif()
|
2017-08-14 04:29:53 +00:00
|
|
|
|
|
|
|
if(WITH_ZLIB)
|
2019-04-29 22:27:09 +00:00
|
|
|
find_package(ZLIB REQUIRED)
|
2017-08-14 04:29:53 +00:00
|
|
|
add_definitions(-DZLIB)
|
2019-08-06 02:47:33 +00:00
|
|
|
list(APPEND THIRDPARTY_LIBS ZLIB::ZLIB)
|
2017-08-14 04:29:53 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
option(WITH_BZ2 "build with bzip2" OFF)
|
|
|
|
if(WITH_BZ2)
|
2019-08-06 02:47:33 +00:00
|
|
|
find_package(BZip2 REQUIRED)
|
2017-08-14 04:29:53 +00:00
|
|
|
add_definitions(-DBZIP2)
|
2019-08-06 02:47:33 +00:00
|
|
|
if(BZIP2_INCLUDE_DIRS)
|
|
|
|
include_directories(${BZIP2_INCLUDE_DIRS})
|
|
|
|
else()
|
|
|
|
include_directories(${BZIP2_INCLUDE_DIR})
|
|
|
|
endif()
|
2017-08-14 04:29:53 +00:00
|
|
|
list(APPEND THIRDPARTY_LIBS ${BZIP2_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_LZ4)
|
|
|
|
find_package(lz4 REQUIRED)
|
|
|
|
add_definitions(-DLZ4)
|
2019-08-06 02:47:33 +00:00
|
|
|
list(APPEND THIRDPARTY_LIBS lz4::lz4)
|
2017-08-14 04:29:53 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_ZSTD)
|
|
|
|
find_package(zstd REQUIRED)
|
|
|
|
add_definitions(-DZSTD)
|
2024-01-25 20:35:27 +00:00
|
|
|
include_directories(${ZSTD_INCLUDE_DIRS})
|
2019-08-06 02:47:33 +00:00
|
|
|
list(APPEND THIRDPARTY_LIBS zstd::zstd)
|
2017-08-14 04:29:53 +00:00
|
|
|
endif()
|
2016-09-28 18:53:15 +00:00
|
|
|
endif()
|
|
|
|
|
cross-platform compatibility improvements
Summary:
We've had a couple CockroachDB users fail to build RocksDB on exotic platforms, so I figured I'd try my hand at solving these issues upstream. The problems stem from a) `USE_SSE=1` being too aggressive about turning on SSE4.2, even on toolchains that don't support SSE4.2 and b) RocksDB attempting to detect support for thread-local storage based on OS, even though it can vary by compiler on the same OS.
See the individual commit messages for details. Regarding SSE support, this PR should change virtually nothing for non-CMake based builds. `make`, `PORTABLE=1 make`, `USE_SSE=1 make`, and `PORTABLE=1 USE_SSE=1 make` function exactly as before, except that SSE support will be automatically disabled when a simple SSE4.2-using test program fails to compile, as it does on OpenBSD. (OpenBSD's ports GCC supports SSE4.2, but its binutils do not, so `__SSE_4_2__` is defined but an SSE4.2-using program will fail to assemble.) A warning is emitted in this case. The CMake build is modified to support the same set of options, except that `USE_SSE` is spelled `FORCE_SSE42` because `USE_SSE` is rather useless now that we can automatically detect SSE support, and I figure changing options in the CMake build is less disruptive than changing the non-CMake build.
I've tested these changes on all the platforms I can get my hands on (macOS, Windows MSVC, Windows MinGW, and OpenBSD) and it all works splendidly. Let me know if there's anything you object to—I obviously don't mean to break any of your build pipelines in the process of fixing ours downstream.
Closes https://github.com/facebook/rocksdb/pull/2199
Differential Revision: D5054042
Pulled By: yiwu-arbug
fbshipit-source-id: 938e1fc665c049c02ae15698e1409155b8e72171
2017-05-15 21:42:32 +00:00
|
|
|
option(WITH_MD_LIBRARY "build with MD" ON)
|
|
|
|
if(WIN32 AND MSVC)
|
|
|
|
if(WITH_MD_LIBRARY)
|
|
|
|
set(RUNTIME_LIBRARY "MD")
|
|
|
|
else()
|
|
|
|
set(RUNTIME_LIBRARY "MT")
|
2017-04-03 16:58:35 +00:00
|
|
|
endif()
|
cross-platform compatibility improvements
Summary:
We've had a couple CockroachDB users fail to build RocksDB on exotic platforms, so I figured I'd try my hand at solving these issues upstream. The problems stem from a) `USE_SSE=1` being too aggressive about turning on SSE4.2, even on toolchains that don't support SSE4.2 and b) RocksDB attempting to detect support for thread-local storage based on OS, even though it can vary by compiler on the same OS.
See the individual commit messages for details. Regarding SSE support, this PR should change virtually nothing for non-CMake based builds. `make`, `PORTABLE=1 make`, `USE_SSE=1 make`, and `PORTABLE=1 USE_SSE=1 make` function exactly as before, except that SSE support will be automatically disabled when a simple SSE4.2-using test program fails to compile, as it does on OpenBSD. (OpenBSD's ports GCC supports SSE4.2, but its binutils do not, so `__SSE_4_2__` is defined but an SSE4.2-using program will fail to assemble.) A warning is emitted in this case. The CMake build is modified to support the same set of options, except that `USE_SSE` is spelled `FORCE_SSE42` because `USE_SSE` is rather useless now that we can automatically detect SSE support, and I figure changing options in the CMake build is less disruptive than changing the non-CMake build.
I've tested these changes on all the platforms I can get my hands on (macOS, Windows MSVC, Windows MinGW, and OpenBSD) and it all works splendidly. Let me know if there's anything you object to—I obviously don't mean to break any of your build pipelines in the process of fixing ours downstream.
Closes https://github.com/facebook/rocksdb/pull/2199
Differential Revision: D5054042
Pulled By: yiwu-arbug
fbshipit-source-id: 938e1fc665c049c02ae15698e1409155b8e72171
2017-05-15 21:42:32 +00:00
|
|
|
endif()
|
2017-04-22 03:41:37 +00:00
|
|
|
|
2017-08-14 04:46:05 +00:00
|
|
|
if(MSVC)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi /nologo /EHsc /GS /Gd /GR /GF /fp:precise /Zc:wchar_t /Zc:forScope /errorReport:queue")
|
2017-10-19 17:48:47 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /FC /d2Zi+ /W4 /wd4127 /wd4800 /wd4996 /wd4351 /wd4100 /wd4204 /wd4324")
|
2017-08-14 04:46:05 +00:00
|
|
|
else()
|
2021-06-01 21:42:06 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wextra -Wall -pthread")
|
Use -Wno-invalid-offsetof instead of dangerous offset_of hack (#9563)
Summary:
After https://github.com/facebook/rocksdb/issues/9515 added a unique_ptr to Status, we see some
warnings-as-error in some internal builds like this:
```
stderr: rocksdb/src/db/compaction/compaction_job.cc:2839:7: error:
offset of on non-standard-layout type 'struct CompactionServiceResult'
[-Werror,-Winvalid-offsetof]
{offsetof(struct CompactionServiceResult, status),
^ ~~~~~~
```
I see three potential solutions to resolving this:
* Expand our use of an idiom that works around the warning (see offset_of
functions removed in this change, inspired by
https://gist.github.com/graphitemaster/494f21190bb2c63c5516) However,
this construction is invoking undefined behavior that assumes consistent
layout with no compiler-introduced indirection. A compiler incompatible
with our assumptions will likely compile the code and exhibit undefined
behavior.
* Migrate to something in place of offset, like a function mapping
CompactionServiceResult* to Status* (for the `status` field). This might
be required in the long term.
* **Selected:** Use our new C++17 dependency to use offsetof in a well-defined way
when the compiler allows it. From a comment on
https://gist.github.com/graphitemaster/494f21190bb2c63c5516:
> A final note: in C++17, offsetof is conditionally supported, which
> means that you can use it on any type (not just standard layout
> types) and the compiler will error if it can't compile it correctly.
> That appears to be the best option if you can live with C++17 and
> don't need constexpr support.
The C++17 semantics are confirmed on
https://en.cppreference.com/w/cpp/types/offsetof, so we can suppress the
warning as long as we accept that we might run into a compiler that
rejects the code, and at that point we will find a solution, such as
the more intrusive "migrate" solution above.
Although this is currently only showing in our buck build, it will
surely show up also with make and cmake, so I have updated those
configurations as well.
Also in the buck build, -Wno-expansion-to-defined does not appear to be
needed anymore (both current compiler configurations) so I
removed it.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/9563
Test Plan: Tried out buck builds with both current compiler configurations
Reviewed By: riversand963
Differential Revision: D34220931
Pulled By: pdillinger
fbshipit-source-id: d39436008259bd1eaaa87c77be69fb2a5b559e1f
2022-02-15 17:18:08 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-compare -Wshadow -Wno-unused-parameter -Wno-unused-variable -Woverloaded-virtual -Wnon-virtual-dtor -Wno-missing-field-initializers -Wno-strict-aliasing -Wno-invalid-offsetof")
|
2021-03-10 04:42:58 +00:00
|
|
|
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wstrict-prototypes")
|
|
|
|
endif()
|
2017-08-14 04:46:05 +00:00
|
|
|
if(MINGW)
|
2022-06-15 00:42:55 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-format")
|
Introduce MultiCfIterator (#12153)
Summary:
This PR introduces a new implementation of `Iterator` via a new public API called `NewMultiCfIterator()`. The new API takes a vector of column family handles to build a cross-column-family iterator, which internally maintains multiple `DBIter`s as child iterators from a consistent database state. When a key exists in multiple column families, the iterator selects the value (and wide columns) from the first column family containing the key, following the order provided in the `column_families` parameter. Similar to the merging iterator, a min heap is used to iterate across the child iterators. Backward iteration and direction change functionalities will be implemented in future PRs.
The comparator used to compare keys across different column families will be derived from the iterator of the first column family specified in `column_families`. This comparator will be checked against the comparators from all other column families that the iterator will traverse. If there's a mismatch with any of the comparators, the initialization of the iterator will fail.
Please note that this PR is not enough for users to start using `MultiCfIterator`. The `MultiCfIterator` and related APIs are still marked as "**DO NOT USE - UNDER CONSTRUCTION**". This PR is just the first of many PRs that will follow soon.
This PR includes the following:
- Introduction and partial implementation of the `MultiCfIterator`, which implements the generic `Iterator` interface. The implementation includes the construction of the iterator, `SeekToFirst()`, `Next()`, `Valid()`, `key()`, `value()`, and `columns()`.
- Unit tests to verify iteration across multiple column families in two distinct scenarios: (1) keys are unique across all column families, and (2) the same keys exist in multiple column families.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/12153
Reviewed By: pdillinger
Differential Revision: D52308697
Pulled By: jaykorean
fbshipit-source-id: b03e69f13b40af5a8f0598d0f43a0bec01ef8294
2024-03-05 18:22:43 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj")
|
2019-06-17 17:15:58 +00:00
|
|
|
add_definitions(-D_POSIX_C_SOURCE=1)
|
2017-08-14 04:46:05 +00:00
|
|
|
endif()
|
|
|
|
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
2018-07-13 17:47:49 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer")
|
2017-08-14 04:46:05 +00:00
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
CHECK_CXX_COMPILER_FLAG("-momit-leaf-frame-pointer" HAVE_OMIT_LEAF_FRAME_POINTER)
|
|
|
|
if(HAVE_OMIT_LEAF_FRAME_POINTER)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -momit-leaf-frame-pointer")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2018-01-24 00:44:09 +00:00
|
|
|
include(CheckCCompilerFlag)
|
2020-03-11 19:31:06 +00:00
|
|
|
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64")
|
|
|
|
CHECK_C_COMPILER_FLAG("-mcpu=power9" HAS_POWER9)
|
|
|
|
if(HAS_POWER9)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=power9 -mtune=power9")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=power9 -mtune=power9")
|
|
|
|
else()
|
|
|
|
CHECK_C_COMPILER_FLAG("-mcpu=power8" HAS_POWER8)
|
|
|
|
if(HAS_POWER8)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=power8 -mtune=power8")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=power8 -mtune=power8")
|
|
|
|
endif(HAS_POWER8)
|
|
|
|
endif(HAS_POWER9)
|
2018-01-24 00:44:09 +00:00
|
|
|
CHECK_C_COMPILER_FLAG("-maltivec" HAS_ALTIVEC)
|
|
|
|
if(HAS_ALTIVEC)
|
|
|
|
message(STATUS " HAS_ALTIVEC yes")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maltivec")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maltivec")
|
|
|
|
endif(HAS_ALTIVEC)
|
2020-03-11 19:31:06 +00:00
|
|
|
endif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64")
|
2018-01-24 00:44:09 +00:00
|
|
|
|
2021-01-20 18:48:04 +00:00
|
|
|
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64|AARCH64")
|
2019-09-07 00:01:45 +00:00
|
|
|
CHECK_C_COMPILER_FLAG("-march=armv8-a+crc+crypto" HAS_ARMV8_CRC)
|
2019-05-15 20:24:36 +00:00
|
|
|
if(HAS_ARMV8_CRC)
|
|
|
|
message(STATUS " HAS_ARMV8_CRC yes")
|
2019-09-07 00:01:45 +00:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv8-a+crc+crypto -Wno-unused-function")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv8-a+crc+crypto -Wno-unused-function")
|
2019-05-15 20:24:36 +00:00
|
|
|
endif(HAS_ARMV8_CRC)
|
2021-01-20 18:48:04 +00:00
|
|
|
endif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64|AARCH64")
|
2019-05-15 20:24:36 +00:00
|
|
|
|
2021-10-22 17:12:09 +00:00
|
|
|
if(CMAKE_SYSTEM_PROCESSOR MATCHES "s390x")
|
|
|
|
CHECK_C_COMPILER_FLAG("-march=native" HAS_S390X_MARCH_NATIVE)
|
|
|
|
if(HAS_S390X_MARCH_NATIVE)
|
|
|
|
message(STATUS " HAS_S390X_MARCH_NATIVE yes")
|
|
|
|
endif(HAS_S390X_MARCH_NATIVE)
|
|
|
|
endif(CMAKE_SYSTEM_PROCESSOR MATCHES "s390x")
|
|
|
|
|
2023-01-13 16:42:44 +00:00
|
|
|
if(CMAKE_SYSTEM_PROCESSOR MATCHES "loongarch64")
|
|
|
|
CHECK_C_COMPILER_FLAG("-march=loongarch64" HAS_LOONGARCH64)
|
|
|
|
if(HAS_LOONGARCH64)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=loongarch64 -mtune=loongarch64")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=loongarch64 -mtune=loongarch64")
|
|
|
|
endif(HAS_LOONGARCH64)
|
|
|
|
endif(CMAKE_SYSTEM_PROCESSOR MATCHES "loongarch64")
|
|
|
|
|
Simplify detection of x86 CPU features (#11419)
Summary:
**Background** - runtime detection of certain x86 CPU features was added for optimizing CRC32c checksums, where performance is dramatically affected by the availability of certain CPU instructions and code using intrinsics for those instructions. And Java builds with native library try to be broadly compatible but performant.
What has changed is that CRC32c is no longer the most efficient cheecksum on contemporary x86_64 hardware, nor the default checksum. XXH3 is generally faster and not as dramatically impacted by the availability of certain CPU instructions. For example, on my Skylake system using db_bench (similar on an older Skylake system without AVX512):
PORTABLE=1 empty USE_SSE : xxh3->8 GB/s crc32c->0.8 GB/s (no SSE4.2 nor AVX2 instructions)
PORTABLE=1 USE_SSE=1 : xxh3->19 GB/s crc32c->16 GB/s (with SSE4.2 and AVX2)
PORTABLE=0 USE_SSE ignored: xxh3->28 GB/s crc32c->16 GB/s (also some AVX512)
Testing a ~10 year old system, with SSE4.2 but without AVX2, crc32c is a similar speed to the new systems but xxh3 is only about half that speed, also 8GB/s like the non-AVX2 compile above. Given that xxh3 has specific optimization for AVX2, I think we can infer that that crc32c is only fastest for that ~2008-2013 period when SSE4.2 was included but not AVX2. And given that xxh3 is only about 2x slower on these systems (not like >10x slower for unoptimized crc32c), I don't think we need to invest too much in optimally adapting to these old cases.
x86 hardware that doesn't support fast CRC32c is now extremely rare, so requiring a custom build to support such hardware is fine IMHO.
**This change** does two related things:
* Remove runtime CPU detection for optimizing CRC32c on x86. Maintaining this code is non-zero work, and compiling special code that doesn't work on the configured target instruction set for code generation is always dubious. (On the one hand we have to ensure the CRC32c code uses SSE4.2 but on the other hand we have to ensure nothing else does.)
* Detect CPU features in source code, not in build scripts. Although there are some hypothetical advantages to detectiong in build scripts (compiler generality), RocksDB supports at least three build systems: make, cmake, and buck. It's not practical to support feature detection on all three, and we have suffered from missed optimization opportunities by relying on missing or incomplete detection in cmake and buck. We also depend on some components like xxhash that do source code detection anyway.
**In more detail:**
* `HAVE_SSE42`, `HAVE_AVX2`, and `HAVE_PCLMUL` replaced by standard macros `__SSE4_2__`, `__AVX2__`, and `__PCLMUL__`.
* MSVC does not provide high fidelity defines for SSE, PCLMUL, or POPCNT, but we can infer those from `__AVX__` or `__AVX2__` in a compatibility header. In rare cases of false negative or false positive feature detection, a build engineer should be able to set defines to work around the issue.
* `__POPCNT__` is another standard define, but we happen to only need it on MSVC, where it is set by that compatibility header, or can be set by the build engineer.
* `PORTABLE` can be set to a CPU type, e.g. "haswell", to compile for that CPU type.
* `USE_SSE` is deprecated, now equivalent to PORTABLE=haswell, which roughly approximates its old behavior.
Notably, this change should enable more builds to use the AVX2-optimized Bloom filter implementation.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/11419
Test Plan:
existing tests, CI
Manual performance tests after the change match the before above (none expected with make build).
We also see AVX2 optimized Bloom filter code enabled when expected, by injecting a compiler error. (Performance difference is not big on my current CPU.)
Reviewed By: ajkr
Differential Revision: D45489041
Pulled By: pdillinger
fbshipit-source-id: 60ceb0dd2aa3b365c99ed08a8b2a087a9abb6a70
2023-05-10 05:25:45 +00:00
|
|
|
set(PORTABLE 0 CACHE STRING "Minimum CPU arch to support, or 0 = current CPU, 1 = baseline CPU")
|
2023-09-18 19:11:15 +00:00
|
|
|
if(PORTABLE MATCHES "1|ON|YES|TRUE|Y")
|
Simplify detection of x86 CPU features (#11419)
Summary:
**Background** - runtime detection of certain x86 CPU features was added for optimizing CRC32c checksums, where performance is dramatically affected by the availability of certain CPU instructions and code using intrinsics for those instructions. And Java builds with native library try to be broadly compatible but performant.
What has changed is that CRC32c is no longer the most efficient cheecksum on contemporary x86_64 hardware, nor the default checksum. XXH3 is generally faster and not as dramatically impacted by the availability of certain CPU instructions. For example, on my Skylake system using db_bench (similar on an older Skylake system without AVX512):
PORTABLE=1 empty USE_SSE : xxh3->8 GB/s crc32c->0.8 GB/s (no SSE4.2 nor AVX2 instructions)
PORTABLE=1 USE_SSE=1 : xxh3->19 GB/s crc32c->16 GB/s (with SSE4.2 and AVX2)
PORTABLE=0 USE_SSE ignored: xxh3->28 GB/s crc32c->16 GB/s (also some AVX512)
Testing a ~10 year old system, with SSE4.2 but without AVX2, crc32c is a similar speed to the new systems but xxh3 is only about half that speed, also 8GB/s like the non-AVX2 compile above. Given that xxh3 has specific optimization for AVX2, I think we can infer that that crc32c is only fastest for that ~2008-2013 period when SSE4.2 was included but not AVX2. And given that xxh3 is only about 2x slower on these systems (not like >10x slower for unoptimized crc32c), I don't think we need to invest too much in optimally adapting to these old cases.
x86 hardware that doesn't support fast CRC32c is now extremely rare, so requiring a custom build to support such hardware is fine IMHO.
**This change** does two related things:
* Remove runtime CPU detection for optimizing CRC32c on x86. Maintaining this code is non-zero work, and compiling special code that doesn't work on the configured target instruction set for code generation is always dubious. (On the one hand we have to ensure the CRC32c code uses SSE4.2 but on the other hand we have to ensure nothing else does.)
* Detect CPU features in source code, not in build scripts. Although there are some hypothetical advantages to detectiong in build scripts (compiler generality), RocksDB supports at least three build systems: make, cmake, and buck. It's not practical to support feature detection on all three, and we have suffered from missed optimization opportunities by relying on missing or incomplete detection in cmake and buck. We also depend on some components like xxhash that do source code detection anyway.
**In more detail:**
* `HAVE_SSE42`, `HAVE_AVX2`, and `HAVE_PCLMUL` replaced by standard macros `__SSE4_2__`, `__AVX2__`, and `__PCLMUL__`.
* MSVC does not provide high fidelity defines for SSE, PCLMUL, or POPCNT, but we can infer those from `__AVX__` or `__AVX2__` in a compatibility header. In rare cases of false negative or false positive feature detection, a build engineer should be able to set defines to work around the issue.
* `__POPCNT__` is another standard define, but we happen to only need it on MSVC, where it is set by that compatibility header, or can be set by the build engineer.
* `PORTABLE` can be set to a CPU type, e.g. "haswell", to compile for that CPU type.
* `USE_SSE` is deprecated, now equivalent to PORTABLE=haswell, which roughly approximates its old behavior.
Notably, this change should enable more builds to use the AVX2-optimized Bloom filter implementation.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/11419
Test Plan:
existing tests, CI
Manual performance tests after the change match the before above (none expected with make build).
We also see AVX2 optimized Bloom filter code enabled when expected, by injecting a compiler error. (Performance difference is not big on my current CPU.)
Reviewed By: ajkr
Differential Revision: D45489041
Pulled By: pdillinger
fbshipit-source-id: 60ceb0dd2aa3b365c99ed08a8b2a087a9abb6a70
2023-05-10 05:25:45 +00:00
|
|
|
# Usually nothing to do; compiler default is typically the most general
|
|
|
|
if(NOT MSVC)
|
2021-10-22 17:12:09 +00:00
|
|
|
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^s390x")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=z196")
|
|
|
|
endif()
|
2023-01-13 16:42:44 +00:00
|
|
|
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^loongarch64")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=loongarch64")
|
|
|
|
endif()
|
2020-09-03 15:02:39 +00:00
|
|
|
endif()
|
2023-09-18 19:11:15 +00:00
|
|
|
elseif(PORTABLE MATCHES "0|OFF|NO|FALSE|N")
|
cross-platform compatibility improvements
Summary:
We've had a couple CockroachDB users fail to build RocksDB on exotic platforms, so I figured I'd try my hand at solving these issues upstream. The problems stem from a) `USE_SSE=1` being too aggressive about turning on SSE4.2, even on toolchains that don't support SSE4.2 and b) RocksDB attempting to detect support for thread-local storage based on OS, even though it can vary by compiler on the same OS.
See the individual commit messages for details. Regarding SSE support, this PR should change virtually nothing for non-CMake based builds. `make`, `PORTABLE=1 make`, `USE_SSE=1 make`, and `PORTABLE=1 USE_SSE=1 make` function exactly as before, except that SSE support will be automatically disabled when a simple SSE4.2-using test program fails to compile, as it does on OpenBSD. (OpenBSD's ports GCC supports SSE4.2, but its binutils do not, so `__SSE_4_2__` is defined but an SSE4.2-using program will fail to assemble.) A warning is emitted in this case. The CMake build is modified to support the same set of options, except that `USE_SSE` is spelled `FORCE_SSE42` because `USE_SSE` is rather useless now that we can automatically detect SSE support, and I figure changing options in the CMake build is less disruptive than changing the non-CMake build.
I've tested these changes on all the platforms I can get my hands on (macOS, Windows MSVC, Windows MinGW, and OpenBSD) and it all works splendidly. Let me know if there's anything you object to—I obviously don't mean to break any of your build pipelines in the process of fixing ours downstream.
Closes https://github.com/facebook/rocksdb/pull/2199
Differential Revision: D5054042
Pulled By: yiwu-arbug
fbshipit-source-id: 938e1fc665c049c02ae15698e1409155b8e72171
2017-05-15 21:42:32 +00:00
|
|
|
if(MSVC)
|
Simplify detection of x86 CPU features (#11419)
Summary:
**Background** - runtime detection of certain x86 CPU features was added for optimizing CRC32c checksums, where performance is dramatically affected by the availability of certain CPU instructions and code using intrinsics for those instructions. And Java builds with native library try to be broadly compatible but performant.
What has changed is that CRC32c is no longer the most efficient cheecksum on contemporary x86_64 hardware, nor the default checksum. XXH3 is generally faster and not as dramatically impacted by the availability of certain CPU instructions. For example, on my Skylake system using db_bench (similar on an older Skylake system without AVX512):
PORTABLE=1 empty USE_SSE : xxh3->8 GB/s crc32c->0.8 GB/s (no SSE4.2 nor AVX2 instructions)
PORTABLE=1 USE_SSE=1 : xxh3->19 GB/s crc32c->16 GB/s (with SSE4.2 and AVX2)
PORTABLE=0 USE_SSE ignored: xxh3->28 GB/s crc32c->16 GB/s (also some AVX512)
Testing a ~10 year old system, with SSE4.2 but without AVX2, crc32c is a similar speed to the new systems but xxh3 is only about half that speed, also 8GB/s like the non-AVX2 compile above. Given that xxh3 has specific optimization for AVX2, I think we can infer that that crc32c is only fastest for that ~2008-2013 period when SSE4.2 was included but not AVX2. And given that xxh3 is only about 2x slower on these systems (not like >10x slower for unoptimized crc32c), I don't think we need to invest too much in optimally adapting to these old cases.
x86 hardware that doesn't support fast CRC32c is now extremely rare, so requiring a custom build to support such hardware is fine IMHO.
**This change** does two related things:
* Remove runtime CPU detection for optimizing CRC32c on x86. Maintaining this code is non-zero work, and compiling special code that doesn't work on the configured target instruction set for code generation is always dubious. (On the one hand we have to ensure the CRC32c code uses SSE4.2 but on the other hand we have to ensure nothing else does.)
* Detect CPU features in source code, not in build scripts. Although there are some hypothetical advantages to detectiong in build scripts (compiler generality), RocksDB supports at least three build systems: make, cmake, and buck. It's not practical to support feature detection on all three, and we have suffered from missed optimization opportunities by relying on missing or incomplete detection in cmake and buck. We also depend on some components like xxhash that do source code detection anyway.
**In more detail:**
* `HAVE_SSE42`, `HAVE_AVX2`, and `HAVE_PCLMUL` replaced by standard macros `__SSE4_2__`, `__AVX2__`, and `__PCLMUL__`.
* MSVC does not provide high fidelity defines for SSE, PCLMUL, or POPCNT, but we can infer those from `__AVX__` or `__AVX2__` in a compatibility header. In rare cases of false negative or false positive feature detection, a build engineer should be able to set defines to work around the issue.
* `__POPCNT__` is another standard define, but we happen to only need it on MSVC, where it is set by that compatibility header, or can be set by the build engineer.
* `PORTABLE` can be set to a CPU type, e.g. "haswell", to compile for that CPU type.
* `USE_SSE` is deprecated, now equivalent to PORTABLE=haswell, which roughly approximates its old behavior.
Notably, this change should enable more builds to use the AVX2-optimized Bloom filter implementation.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/11419
Test Plan:
existing tests, CI
Manual performance tests after the change match the before above (none expected with make build).
We also see AVX2 optimized Bloom filter code enabled when expected, by injecting a compiler error. (Performance difference is not big on my current CPU.)
Reviewed By: ajkr
Differential Revision: D45489041
Pulled By: pdillinger
fbshipit-source-id: 60ceb0dd2aa3b365c99ed08a8b2a087a9abb6a70
2023-05-10 05:25:45 +00:00
|
|
|
# NOTE: No auto-detection of current CPU, but instead assume some useful
|
|
|
|
# level of optimization is supported
|
cross-platform compatibility improvements
Summary:
We've had a couple CockroachDB users fail to build RocksDB on exotic platforms, so I figured I'd try my hand at solving these issues upstream. The problems stem from a) `USE_SSE=1` being too aggressive about turning on SSE4.2, even on toolchains that don't support SSE4.2 and b) RocksDB attempting to detect support for thread-local storage based on OS, even though it can vary by compiler on the same OS.
See the individual commit messages for details. Regarding SSE support, this PR should change virtually nothing for non-CMake based builds. `make`, `PORTABLE=1 make`, `USE_SSE=1 make`, and `PORTABLE=1 USE_SSE=1 make` function exactly as before, except that SSE support will be automatically disabled when a simple SSE4.2-using test program fails to compile, as it does on OpenBSD. (OpenBSD's ports GCC supports SSE4.2, but its binutils do not, so `__SSE_4_2__` is defined but an SSE4.2-using program will fail to assemble.) A warning is emitted in this case. The CMake build is modified to support the same set of options, except that `USE_SSE` is spelled `FORCE_SSE42` because `USE_SSE` is rather useless now that we can automatically detect SSE support, and I figure changing options in the CMake build is less disruptive than changing the non-CMake build.
I've tested these changes on all the platforms I can get my hands on (macOS, Windows MSVC, Windows MinGW, and OpenBSD) and it all works splendidly. Let me know if there's anything you object to—I obviously don't mean to break any of your build pipelines in the process of fixing ours downstream.
Closes https://github.com/facebook/rocksdb/pull/2199
Differential Revision: D5054042
Pulled By: yiwu-arbug
fbshipit-source-id: 938e1fc665c049c02ae15698e1409155b8e72171
2017-05-15 21:42:32 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2")
|
|
|
|
else()
|
Simplify detection of x86 CPU features (#11419)
Summary:
**Background** - runtime detection of certain x86 CPU features was added for optimizing CRC32c checksums, where performance is dramatically affected by the availability of certain CPU instructions and code using intrinsics for those instructions. And Java builds with native library try to be broadly compatible but performant.
What has changed is that CRC32c is no longer the most efficient cheecksum on contemporary x86_64 hardware, nor the default checksum. XXH3 is generally faster and not as dramatically impacted by the availability of certain CPU instructions. For example, on my Skylake system using db_bench (similar on an older Skylake system without AVX512):
PORTABLE=1 empty USE_SSE : xxh3->8 GB/s crc32c->0.8 GB/s (no SSE4.2 nor AVX2 instructions)
PORTABLE=1 USE_SSE=1 : xxh3->19 GB/s crc32c->16 GB/s (with SSE4.2 and AVX2)
PORTABLE=0 USE_SSE ignored: xxh3->28 GB/s crc32c->16 GB/s (also some AVX512)
Testing a ~10 year old system, with SSE4.2 but without AVX2, crc32c is a similar speed to the new systems but xxh3 is only about half that speed, also 8GB/s like the non-AVX2 compile above. Given that xxh3 has specific optimization for AVX2, I think we can infer that that crc32c is only fastest for that ~2008-2013 period when SSE4.2 was included but not AVX2. And given that xxh3 is only about 2x slower on these systems (not like >10x slower for unoptimized crc32c), I don't think we need to invest too much in optimally adapting to these old cases.
x86 hardware that doesn't support fast CRC32c is now extremely rare, so requiring a custom build to support such hardware is fine IMHO.
**This change** does two related things:
* Remove runtime CPU detection for optimizing CRC32c on x86. Maintaining this code is non-zero work, and compiling special code that doesn't work on the configured target instruction set for code generation is always dubious. (On the one hand we have to ensure the CRC32c code uses SSE4.2 but on the other hand we have to ensure nothing else does.)
* Detect CPU features in source code, not in build scripts. Although there are some hypothetical advantages to detectiong in build scripts (compiler generality), RocksDB supports at least three build systems: make, cmake, and buck. It's not practical to support feature detection on all three, and we have suffered from missed optimization opportunities by relying on missing or incomplete detection in cmake and buck. We also depend on some components like xxhash that do source code detection anyway.
**In more detail:**
* `HAVE_SSE42`, `HAVE_AVX2`, and `HAVE_PCLMUL` replaced by standard macros `__SSE4_2__`, `__AVX2__`, and `__PCLMUL__`.
* MSVC does not provide high fidelity defines for SSE, PCLMUL, or POPCNT, but we can infer those from `__AVX__` or `__AVX2__` in a compatibility header. In rare cases of false negative or false positive feature detection, a build engineer should be able to set defines to work around the issue.
* `__POPCNT__` is another standard define, but we happen to only need it on MSVC, where it is set by that compatibility header, or can be set by the build engineer.
* `PORTABLE` can be set to a CPU type, e.g. "haswell", to compile for that CPU type.
* `USE_SSE` is deprecated, now equivalent to PORTABLE=haswell, which roughly approximates its old behavior.
Notably, this change should enable more builds to use the AVX2-optimized Bloom filter implementation.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/11419
Test Plan:
existing tests, CI
Manual performance tests after the change match the before above (none expected with make build).
We also see AVX2 optimized Bloom filter code enabled when expected, by injecting a compiler error. (Performance difference is not big on my current CPU.)
Reviewed By: ajkr
Differential Revision: D45489041
Pulled By: pdillinger
fbshipit-source-id: 60ceb0dd2aa3b365c99ed08a8b2a087a9abb6a70
2023-05-10 05:25:45 +00:00
|
|
|
# Require instruction set from current CPU (with some legacy or opt-out
|
|
|
|
# exceptions)
|
2021-10-22 17:12:09 +00:00
|
|
|
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^s390x" AND NOT HAS_S390X_MARCH_NATIVE)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=z196")
|
|
|
|
elseif(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64" AND NOT HAS_ARMV8_CRC)
|
2018-01-24 00:44:09 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
|
|
|
|
endif()
|
2017-04-16 18:41:12 +00:00
|
|
|
endif()
|
2023-09-18 19:11:15 +00:00
|
|
|
else()
|
|
|
|
# Name of a CPU arch spec or feature set to require
|
|
|
|
if(MSVC)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:${PORTABLE}")
|
|
|
|
else()
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${PORTABLE}")
|
|
|
|
endif()
|
2017-04-03 16:58:35 +00:00
|
|
|
endif()
|
|
|
|
|
cross-platform compatibility improvements
Summary:
We've had a couple CockroachDB users fail to build RocksDB on exotic platforms, so I figured I'd try my hand at solving these issues upstream. The problems stem from a) `USE_SSE=1` being too aggressive about turning on SSE4.2, even on toolchains that don't support SSE4.2 and b) RocksDB attempting to detect support for thread-local storage based on OS, even though it can vary by compiler on the same OS.
See the individual commit messages for details. Regarding SSE support, this PR should change virtually nothing for non-CMake based builds. `make`, `PORTABLE=1 make`, `USE_SSE=1 make`, and `PORTABLE=1 USE_SSE=1 make` function exactly as before, except that SSE support will be automatically disabled when a simple SSE4.2-using test program fails to compile, as it does on OpenBSD. (OpenBSD's ports GCC supports SSE4.2, but its binutils do not, so `__SSE_4_2__` is defined but an SSE4.2-using program will fail to assemble.) A warning is emitted in this case. The CMake build is modified to support the same set of options, except that `USE_SSE` is spelled `FORCE_SSE42` because `USE_SSE` is rather useless now that we can automatically detect SSE support, and I figure changing options in the CMake build is less disruptive than changing the non-CMake build.
I've tested these changes on all the platforms I can get my hands on (macOS, Windows MSVC, Windows MinGW, and OpenBSD) and it all works splendidly. Let me know if there's anything you object to—I obviously don't mean to break any of your build pipelines in the process of fixing ours downstream.
Closes https://github.com/facebook/rocksdb/pull/2199
Differential Revision: D5054042
Pulled By: yiwu-arbug
fbshipit-source-id: 938e1fc665c049c02ae15698e1409155b8e72171
2017-05-15 21:42:32 +00:00
|
|
|
include(CheckCXXSourceCompiles)
|
2021-04-22 15:28:20 +00:00
|
|
|
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
2017-10-11 19:14:53 +00:00
|
|
|
if(NOT MSVC)
|
Port 3 way SSE4.2 crc32c implementation from Folly
Summary:
**# Summary**
RocksDB uses SSE crc32 intrinsics to calculate the crc32 values but it does it in single way fashion (not pipelined on single CPU core). Intel's whitepaper () published an algorithm that uses 3-way pipelining for the crc32 intrinsics, then use pclmulqdq intrinsic to combine the values. Because pclmulqdq has overhead on its own, this algorithm will show perf gains on buffers larger than 216 bytes, which makes RocksDB a perfect user, since most of the buffers RocksDB call crc32c on is over 4KB. Initial db_bench show tremendous CPU gain.
This change uses the 3-way SSE algorithm by default. The old SSE algorithm is now behind a compiler tag NO_THREEWAY_CRC32C. If user compiles the code with NO_THREEWAY_CRC32C=1 then the old SSE Crc32c algorithm would be used. If the server does not have SSE4.2 at the run time the slow way (Non SSE) will be used.
**# Performance Test Results**
We ran the FillRandom and ReadRandom benchmarks in db_bench. ReadRandom is the point of interest here since it calculates the CRC32 for the in-mem buffers. We did 3 runs for each algorithm.
Before this change the CRC32 value computation takes about 11.5% of total CPU cost, and with the new 3-way algorithm it reduced to around 4.5%. The overall throughput also improved from 25.53MB/s to 27.63MB/s.
1) ReadRandom in db_bench overall metrics
PER RUN
Algorithm | run | micros/op | ops/sec |Throughput (MB/s)
3-way | 1 | 4.143 | 241387 | 26.7
3-way | 2 | 3.775 | 264872 | 29.3
3-way | 3 | 4.116 | 242929 | 26.9
FastCrc32c|1 | 4.037 | 247727 | 27.4
FastCrc32c|2 | 4.648 | 215166 | 23.8
FastCrc32c|3 | 4.352 | 229799 | 25.4
AVG
Algorithm | Average of micros/op | Average of ops/sec | Average of Throughput (MB/s)
3-way | 4.01 | 249,729 | 27.63
FastCrc32c | 4.35 | 230,897 | 25.53
2) Crc32c computation CPU cost (inclusive samples percentage)
PER RUN
Implementation | run | TotalSamples | Crc32c percentage
3-way | 1 | 4,572,250,000 | 4.37%
3-way | 2 | 3,779,250,000 | 4.62%
3-way | 3 | 4,129,500,000 | 4.48%
FastCrc32c | 1 | 4,663,500,000 | 11.24%
FastCrc32c | 2 | 4,047,500,000 | 12.34%
FastCrc32c | 3 | 4,366,750,000 | 11.68%
**# Test Plan**
make -j64 corruption_test && ./corruption_test
By default it uses 3-way SSE algorithm
NO_THREEWAY_CRC32C=1 make -j64 corruption_test && ./corruption_test
make clean && DEBUG_LEVEL=0 make -j64 db_bench
make clean && DEBUG_LEVEL=0 NO_THREEWAY_CRC32C=1 make -j64 db_bench
Closes https://github.com/facebook/rocksdb/pull/3173
Differential Revision: D6330882
Pulled By: yingsu00
fbshipit-source-id: 8ec3d89719533b63b536a736663ca6f0dd4482e9
2017-12-20 02:20:50 +00:00
|
|
|
set(CMAKE_REQUIRED_FLAGS "-msse4.2 -mpclmul")
|
2017-10-11 19:14:53 +00:00
|
|
|
endif()
|
2020-04-20 20:21:34 +00:00
|
|
|
|
2021-04-22 15:28:20 +00:00
|
|
|
# Check if -latomic is required or not
|
|
|
|
if (NOT MSVC)
|
2022-02-05 01:12:03 +00:00
|
|
|
set(CMAKE_REQUIRED_FLAGS "--std=c++17")
|
2021-04-22 15:28:20 +00:00
|
|
|
CHECK_CXX_SOURCE_COMPILES("
|
|
|
|
#include <atomic>
|
|
|
|
std::atomic<uint64_t> x(0);
|
|
|
|
int main() {
|
|
|
|
uint64_t i = x.load(std::memory_order_relaxed);
|
|
|
|
bool b = x.is_lock_free();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
" BUILTIN_ATOMIC)
|
2021-12-18 01:03:35 +00:00
|
|
|
if (NOT BUILTIN_ATOMIC)
|
|
|
|
#TODO: Check if -latomic exists
|
|
|
|
list(APPEND THIRDPARTY_LIBS atomic)
|
|
|
|
endif()
|
2021-04-22 15:28:20 +00:00
|
|
|
endif()
|
|
|
|
|
2021-05-21 17:20:58 +00:00
|
|
|
if (WITH_LIBURING)
|
2021-12-18 01:03:35 +00:00
|
|
|
find_package(uring)
|
|
|
|
if (uring_FOUND)
|
2021-05-21 17:20:58 +00:00
|
|
|
add_definitions(-DROCKSDB_IOURING_PRESENT)
|
2021-12-18 01:03:35 +00:00
|
|
|
list(APPEND THIRDPARTY_LIBS uring::uring)
|
2021-05-21 17:20:58 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-04-22 15:28:20 +00:00
|
|
|
# Reset the required flags
|
|
|
|
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
|
cross-platform compatibility improvements
Summary:
We've had a couple CockroachDB users fail to build RocksDB on exotic platforms, so I figured I'd try my hand at solving these issues upstream. The problems stem from a) `USE_SSE=1` being too aggressive about turning on SSE4.2, even on toolchains that don't support SSE4.2 and b) RocksDB attempting to detect support for thread-local storage based on OS, even though it can vary by compiler on the same OS.
See the individual commit messages for details. Regarding SSE support, this PR should change virtually nothing for non-CMake based builds. `make`, `PORTABLE=1 make`, `USE_SSE=1 make`, and `PORTABLE=1 USE_SSE=1 make` function exactly as before, except that SSE support will be automatically disabled when a simple SSE4.2-using test program fails to compile, as it does on OpenBSD. (OpenBSD's ports GCC supports SSE4.2, but its binutils do not, so `__SSE_4_2__` is defined but an SSE4.2-using program will fail to assemble.) A warning is emitted in this case. The CMake build is modified to support the same set of options, except that `USE_SSE` is spelled `FORCE_SSE42` because `USE_SSE` is rather useless now that we can automatically detect SSE support, and I figure changing options in the CMake build is less disruptive than changing the non-CMake build.
I've tested these changes on all the platforms I can get my hands on (macOS, Windows MSVC, Windows MinGW, and OpenBSD) and it all works splendidly. Let me know if there's anything you object to—I obviously don't mean to break any of your build pipelines in the process of fixing ours downstream.
Closes https://github.com/facebook/rocksdb/pull/2199
Differential Revision: D5054042
Pulled By: yiwu-arbug
fbshipit-source-id: 938e1fc665c049c02ae15698e1409155b8e72171
2017-05-15 21:42:32 +00:00
|
|
|
|
2021-04-13 14:55:58 +00:00
|
|
|
option(WITH_IOSTATS_CONTEXT "Enable IO stats context" ON)
|
|
|
|
if (NOT WITH_IOSTATS_CONTEXT)
|
|
|
|
add_definitions(-DNIOSTATS_CONTEXT)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
option(WITH_PERF_CONTEXT "Enable perf context" ON)
|
|
|
|
if (NOT WITH_PERF_CONTEXT)
|
|
|
|
add_definitions(-DNPERF_CONTEXT)
|
|
|
|
endif()
|
|
|
|
|
2016-11-01 08:11:02 +00:00
|
|
|
option(FAIL_ON_WARNINGS "Treat compile warnings as errors" ON)
|
|
|
|
if(FAIL_ON_WARNINGS)
|
|
|
|
if(MSVC)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
|
|
|
|
else() # assume GCC
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-09-28 18:53:15 +00:00
|
|
|
option(WITH_ASAN "build with ASAN" OFF)
|
|
|
|
if(WITH_ASAN)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
|
|
|
|
if(WITH_JEMALLOC)
|
|
|
|
message(FATAL "ASAN does not work well with JeMalloc")
|
|
|
|
endif()
|
|
|
|
endif()
|
2015-07-01 23:13:49 +00:00
|
|
|
|
2016-09-28 18:53:15 +00:00
|
|
|
option(WITH_TSAN "build with TSAN" OFF)
|
|
|
|
if(WITH_TSAN)
|
2022-02-17 23:46:16 +00:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread -Wl,-pie")
|
2016-09-28 18:53:15 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fPIC")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread -fPIC")
|
|
|
|
if(WITH_JEMALLOC)
|
|
|
|
message(FATAL "TSAN does not work well with JeMalloc")
|
|
|
|
endif()
|
|
|
|
endif()
|
2015-11-19 00:23:19 +00:00
|
|
|
|
2016-09-28 18:53:15 +00:00
|
|
|
option(WITH_UBSAN "build with UBSAN" OFF)
|
|
|
|
if(WITH_UBSAN)
|
2017-05-30 18:05:28 +00:00
|
|
|
add_definitions(-DROCKSDB_UBSAN_RUN)
|
2016-09-28 18:53:15 +00:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined")
|
|
|
|
if(WITH_JEMALLOC)
|
|
|
|
message(FATAL "UBSAN does not work well with JeMalloc")
|
|
|
|
endif()
|
|
|
|
endif()
|
2015-07-01 23:13:49 +00:00
|
|
|
|
2018-04-25 21:26:11 +00:00
|
|
|
option(WITH_NUMA "build with NUMA policy support" OFF)
|
|
|
|
if(WITH_NUMA)
|
|
|
|
find_package(NUMA REQUIRED)
|
2017-12-01 06:37:19 +00:00
|
|
|
add_definitions(-DNUMA)
|
2024-01-25 20:35:27 +00:00
|
|
|
include_directories(${NUMA_INCLUDE_DIRS})
|
2019-08-06 02:47:33 +00:00
|
|
|
list(APPEND THIRDPARTY_LIBS NUMA::NUMA)
|
2017-12-01 06:37:19 +00:00
|
|
|
endif()
|
|
|
|
|
2018-04-25 21:26:11 +00:00
|
|
|
option(WITH_TBB "build with Threading Building Blocks (TBB)" OFF)
|
|
|
|
if(WITH_TBB)
|
|
|
|
find_package(TBB REQUIRED)
|
2017-12-01 06:37:19 +00:00
|
|
|
add_definitions(-DTBB)
|
2019-08-06 02:47:33 +00:00
|
|
|
list(APPEND THIRDPARTY_LIBS TBB::TBB)
|
2017-12-01 06:37:19 +00:00
|
|
|
endif()
|
|
|
|
|
2018-05-09 17:04:55 +00:00
|
|
|
# Stall notifications eat some performance from inserts
|
|
|
|
option(DISABLE_STALL_NOTIF "Build with stall notifications" OFF)
|
|
|
|
if(DISABLE_STALL_NOTIF)
|
|
|
|
add_definitions(-DROCKSDB_DISABLE_STALL_NOTIFICATION)
|
|
|
|
endif()
|
|
|
|
|
2019-06-05 20:56:46 +00:00
|
|
|
option(WITH_DYNAMIC_EXTENSION "build with dynamic extension support" OFF)
|
|
|
|
if(NOT WITH_DYNAMIC_EXTENSION)
|
|
|
|
add_definitions(-DROCKSDB_NO_DYNAMIC_EXTENSION)
|
|
|
|
endif()
|
2015-09-29 19:22:48 +00:00
|
|
|
|
2020-09-25 16:06:51 +00:00
|
|
|
option(ASSERT_STATUS_CHECKED "build with assert status checked" OFF)
|
|
|
|
if (ASSERT_STATUS_CHECKED)
|
|
|
|
message(STATUS "Build with assert status checked")
|
|
|
|
add_definitions(-DROCKSDB_ASSERT_STATUS_CHECKED)
|
|
|
|
endif()
|
|
|
|
|
2022-04-12 19:12:23 +00:00
|
|
|
|
|
|
|
# RTTI is by default AUTO which enables it in debug and disables it in release.
|
|
|
|
set(USE_RTTI AUTO CACHE STRING "Enable RTTI in builds")
|
|
|
|
set_property(CACHE USE_RTTI PROPERTY STRINGS AUTO ON OFF)
|
|
|
|
if(USE_RTTI STREQUAL "AUTO")
|
|
|
|
message(STATUS "Enabling RTTI in Debug builds only (default)")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DROCKSDB_USE_RTTI")
|
|
|
|
if(MSVC)
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GR-")
|
2018-05-07 21:17:49 +00:00
|
|
|
else()
|
2022-04-12 19:12:23 +00:00
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-rtti")
|
2018-05-07 21:17:49 +00:00
|
|
|
endif()
|
2022-04-12 19:12:23 +00:00
|
|
|
elseif(USE_RTTI)
|
|
|
|
message(STATUS "Enabling RTTI in all builds")
|
2018-05-04 22:09:40 +00:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DROCKSDB_USE_RTTI")
|
2022-04-12 19:12:23 +00:00
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DROCKSDB_USE_RTTI")
|
|
|
|
else()
|
2018-06-04 19:04:52 +00:00
|
|
|
if(MSVC)
|
2022-04-12 19:12:23 +00:00
|
|
|
message(STATUS "Disabling RTTI in Release builds. Always on in Debug.")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DROCKSDB_USE_RTTI")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GR-")
|
2018-06-04 19:04:52 +00:00
|
|
|
else()
|
2022-04-12 19:12:23 +00:00
|
|
|
message(STATUS "Disabling RTTI in all builds")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-rtti")
|
2018-06-04 19:04:52 +00:00
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-rtti")
|
|
|
|
endif()
|
2018-05-04 22:09:40 +00:00
|
|
|
endif()
|
|
|
|
|
2018-07-19 22:07:22 +00:00
|
|
|
# Used to run CI build and tests so we can run faster
|
|
|
|
option(OPTDBG "Build optimized debug build with MSVC" OFF)
|
2018-08-27 22:48:57 +00:00
|
|
|
option(WITH_RUNTIME_DEBUG "build with debug version of runtime library" ON)
|
2017-03-30 23:47:19 +00:00
|
|
|
if(MSVC)
|
2018-07-19 22:07:22 +00:00
|
|
|
if(OPTDBG)
|
2016-09-28 18:53:15 +00:00
|
|
|
message(STATUS "Debug optimization is enabled")
|
2018-08-27 22:48:57 +00:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "/Oxt")
|
2016-09-28 18:53:15 +00:00
|
|
|
else()
|
2020-04-20 20:21:34 +00:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Od /RTC1")
|
|
|
|
|
|
|
|
# Minimal Build is deprecated after MSVC 2015
|
|
|
|
if( MSVC_VERSION GREATER 1900 )
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Gm-")
|
|
|
|
else()
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Gm")
|
|
|
|
endif()
|
|
|
|
|
2018-08-27 22:48:57 +00:00
|
|
|
endif()
|
|
|
|
if(WITH_RUNTIME_DEBUG)
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /${RUNTIME_LIBRARY}d")
|
|
|
|
else()
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /${RUNTIME_LIBRARY}")
|
2016-09-28 18:53:15 +00:00
|
|
|
endif()
|
2017-04-22 03:41:37 +00:00
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oxt /Zp8 /Gm- /Gy /${RUNTIME_LIBRARY}")
|
2016-09-28 18:53:15 +00:00
|
|
|
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEBUG")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG")
|
2015-09-29 19:22:48 +00:00
|
|
|
endif()
|
|
|
|
|
2016-09-28 18:53:15 +00:00
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-builtin-memcmp")
|
|
|
|
endif()
|
2015-07-01 23:13:49 +00:00
|
|
|
|
2016-09-28 18:53:15 +00:00
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "Cygwin")
|
|
|
|
add_definitions(-fno-builtin-memcmp -DCYGWIN)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
|
|
|
add_definitions(-DOS_MACOSX)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
|
|
add_definitions(-DOS_LINUX)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "SunOS")
|
|
|
|
add_definitions(-DOS_SOLARIS)
|
2020-06-18 16:50:05 +00:00
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD")
|
|
|
|
add_definitions(-DOS_GNU_KFREEBSD)
|
2016-09-28 18:53:15 +00:00
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
|
|
|
add_definitions(-DOS_FREEBSD)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
|
|
|
|
add_definitions(-DOS_NETBSD)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
|
|
|
|
add_definitions(-DOS_OPENBSD)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "DragonFly")
|
|
|
|
add_definitions(-DOS_DRAGONFLYBSD)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Android")
|
|
|
|
add_definitions(-DOS_ANDROID)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
|
|
|
add_definitions(-DWIN32 -DOS_WIN -D_MBCS -DWIN64 -DNOMINMAX)
|
2017-03-30 23:47:19 +00:00
|
|
|
if(MINGW)
|
|
|
|
add_definitions(-D_WIN32_WINNT=_WIN32_WINNT_VISTA)
|
|
|
|
endif()
|
2016-09-28 18:53:15 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT WIN32)
|
|
|
|
add_definitions(-DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
option(WITH_FALLOCATE "build with fallocate" ON)
|
|
|
|
if(WITH_FALLOCATE)
|
2017-12-01 06:37:19 +00:00
|
|
|
CHECK_CXX_SOURCE_COMPILES("
|
2016-09-28 18:53:15 +00:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <linux/falloc.h>
|
|
|
|
int main() {
|
|
|
|
int fd = open(\"/dev/null\", 0);
|
2019-03-04 23:40:26 +00:00
|
|
|
fallocate(fd, FALLOC_FL_KEEP_SIZE, 0, 1024);
|
2016-09-28 18:53:15 +00:00
|
|
|
}
|
|
|
|
" HAVE_FALLOCATE)
|
|
|
|
if(HAVE_FALLOCATE)
|
|
|
|
add_definitions(-DROCKSDB_FALLOCATE_PRESENT)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2017-12-01 06:37:19 +00:00
|
|
|
CHECK_CXX_SOURCE_COMPILES("
|
|
|
|
#include <fcntl.h>
|
|
|
|
int main() {
|
|
|
|
int fd = open(\"/dev/null\", 0);
|
|
|
|
sync_file_range(fd, 0, 1024, SYNC_FILE_RANGE_WRITE);
|
|
|
|
}
|
|
|
|
" HAVE_SYNC_FILE_RANGE_WRITE)
|
|
|
|
if(HAVE_SYNC_FILE_RANGE_WRITE)
|
|
|
|
add_definitions(-DROCKSDB_RANGESYNC_PRESENT)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
CHECK_CXX_SOURCE_COMPILES("
|
|
|
|
#include <pthread.h>
|
|
|
|
int main() {
|
|
|
|
(void) PTHREAD_MUTEX_ADAPTIVE_NP;
|
|
|
|
}
|
|
|
|
" HAVE_PTHREAD_MUTEX_ADAPTIVE_NP)
|
|
|
|
if(HAVE_PTHREAD_MUTEX_ADAPTIVE_NP)
|
|
|
|
add_definitions(-DROCKSDB_PTHREAD_ADAPTIVE_MUTEX)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
include(CheckCXXSymbolExists)
|
2020-06-26 00:28:02 +00:00
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "^FreeBSD")
|
|
|
|
check_cxx_symbol_exists(malloc_usable_size malloc_np.h HAVE_MALLOC_USABLE_SIZE)
|
|
|
|
else()
|
|
|
|
check_cxx_symbol_exists(malloc_usable_size malloc.h HAVE_MALLOC_USABLE_SIZE)
|
|
|
|
endif()
|
2016-09-28 18:53:15 +00:00
|
|
|
if(HAVE_MALLOC_USABLE_SIZE)
|
|
|
|
add_definitions(-DROCKSDB_MALLOC_USABLE_SIZE)
|
|
|
|
endif()
|
2015-07-01 23:13:49 +00:00
|
|
|
|
2017-12-01 06:37:19 +00:00
|
|
|
check_cxx_symbol_exists(sched_getcpu sched.h HAVE_SCHED_GETCPU)
|
|
|
|
if(HAVE_SCHED_GETCPU)
|
|
|
|
add_definitions(-DROCKSDB_SCHED_GETCPU_PRESENT)
|
|
|
|
endif()
|
|
|
|
|
2023-05-22 18:58:19 +00:00
|
|
|
check_cxx_symbol_exists(getauxval "sys/auxv.h" HAVE_AUXV_GETAUXVAL)
|
2020-03-04 02:06:56 +00:00
|
|
|
if(HAVE_AUXV_GETAUXVAL)
|
|
|
|
add_definitions(-DROCKSDB_AUXV_GETAUXVAL_PRESENT)
|
|
|
|
endif()
|
|
|
|
|
2022-01-19 04:21:37 +00:00
|
|
|
check_cxx_symbol_exists(F_FULLFSYNC "fcntl.h" HAVE_FULLFSYNC)
|
|
|
|
if(HAVE_FULLFSYNC)
|
|
|
|
add_definitions(-DHAVE_FULLFSYNC)
|
|
|
|
endif()
|
|
|
|
|
2015-07-01 23:13:49 +00:00
|
|
|
include_directories(${PROJECT_SOURCE_DIR})
|
|
|
|
include_directories(${PROJECT_SOURCE_DIR}/include)
|
2022-09-12 04:40:11 +00:00
|
|
|
|
|
|
|
if(USE_COROUTINES)
|
|
|
|
if(USE_FOLLY OR USE_FOLLY_LITE)
|
|
|
|
message(FATAL_ERROR "Please specify exactly one of USE_COROUTINES,"
|
|
|
|
" USE_FOLLY, and USE_FOLLY_LITE")
|
|
|
|
endif()
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoroutines -Wno-maybe-uninitialized")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-redundant-move")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-memory-model")
|
|
|
|
add_compile_definitions(USE_COROUTINES)
|
|
|
|
set(USE_FOLLY 1)
|
|
|
|
endif()
|
|
|
|
|
Meta-internal folly integration with F14FastMap (#9546)
Summary:
Especially after updating to C++17, I don't see a compelling case for
*requiring* any folly components in RocksDB. I was able to purge the existing
hard dependencies, and it can be quite difficult to strip out non-trivial components
from folly for use in RocksDB. (The prospect of doing that on F14 has changed
my mind on the best approach here.)
But this change creates an optional integration where we can plug in
components from folly at compile time, starting here with F14FastMap to replace
std::unordered_map when possible (probably no public APIs for example). I have
replaced the biggest CPU users of std::unordered_map with compile-time
pluggable UnorderedMap which will use F14FastMap when USE_FOLLY is set.
USE_FOLLY is always set in the Meta-internal buck build, and a simulation of
that is in the Makefile for public CI testing. A full folly build is not needed, but
checking out the full folly repo is much simpler for getting the dependency,
and anything else we might want to optionally integrate in the future.
Some picky details:
* I don't think the distributed mutex stuff is actually used, so it was easy to remove.
* I implemented an alternative to `folly::constexpr_log2` (which is much easier
in C++17 than C++11) so that I could pull out the hard dependencies on
`ConstexprMath.h`
* I had to add noexcept move constructors/operators to some types to make
F14's complainUnlessNothrowMoveAndDestroy check happy, and I added a
macro to make that easier in some common cases.
* Updated Meta-internal buck build to use folly F14Map (always)
No updates to HISTORY.md nor INSTALL.md as this is not (yet?) considered a
production integration for open source users.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/9546
Test Plan:
CircleCI tests updated so that a couple of them use folly.
Most internal unit & stress/crash tests updated to use Meta-internal latest folly.
(Note: they should probably use buck but they currently use Makefile.)
Example performance improvement: when filter partitions are pinned in cache,
they are tracked by PartitionedFilterBlockReader::filter_map_ and we can build
a test that exercises that heavily. Build DB with
```
TEST_TMPDIR=/dev/shm/rocksdb ./db_bench -benchmarks=fillrandom -num=10000000 -disable_wal=1 -write_buffer_size=30000000 -bloom_bits=16 -compaction_style=2 -fifo_compaction_max_table_files_size_mb=10000 -fifo_compaction_allow_compaction=0 -partition_index_and_filters
```
and test with (simultaneous runs with & without folly, ~20 times each to see
convergence)
```
TEST_TMPDIR=/dev/shm/rocksdb ./db_bench_folly -readonly -use_existing_db -benchmarks=readrandom -num=10000000 -bloom_bits=16 -compaction_style=2 -fifo_compaction_max_table_files_size_mb=10000 -fifo_compaction_allow_compaction=0 -partition_index_and_filters -duration=40 -pin_l0_filter_and_index_blocks_in_cache
```
Average ops/s no folly: 26229.2
Average ops/s with folly: 26853.3 (+2.4%)
Reviewed By: ajkr
Differential Revision: D34181736
Pulled By: pdillinger
fbshipit-source-id: ffa6ad5104c2880321d8a1aa7187e00ab0d02e94
2022-04-13 14:34:01 +00:00
|
|
|
if(USE_FOLLY)
|
2022-09-12 04:40:11 +00:00
|
|
|
if(USE_FOLLY_LITE)
|
|
|
|
message(FATAL_ERROR "Please specify one of USE_FOLLY or USE_FOLLY_LITE")
|
|
|
|
endif()
|
|
|
|
if(ROCKSDB_BUILD_SHARED)
|
|
|
|
message(FATAL_ERROR "Cannot build RocksDB shared library with folly")
|
|
|
|
endif()
|
|
|
|
set(ROCKSDB_BUILD_SHARED OFF)
|
|
|
|
set(GFLAGS_SHARED FALSE)
|
|
|
|
find_package(folly)
|
|
|
|
# If cmake could not find the folly-config.cmake file, fall back
|
|
|
|
# to looking in third-party/folly for folly and its dependencies
|
|
|
|
if(NOT FOLLY_LIBRARIES)
|
|
|
|
exec_program(python3 ${PROJECT_SOURCE_DIR}/third-party/folly ARGS
|
|
|
|
build/fbcode_builder/getdeps.py show-inst-dir OUTPUT_VARIABLE
|
|
|
|
FOLLY_INST_PATH)
|
|
|
|
exec_program(ls ARGS -d ${FOLLY_INST_PATH}/../boost* OUTPUT_VARIABLE
|
|
|
|
BOOST_INST_PATH)
|
|
|
|
exec_program(ls ARGS -d ${FOLLY_INST_PATH}/../fmt* OUTPUT_VARIABLE
|
|
|
|
FMT_INST_PATH)
|
|
|
|
exec_program(ls ARGS -d ${FOLLY_INST_PATH}/../gflags* OUTPUT_VARIABLE
|
|
|
|
GFLAGS_INST_PATH)
|
|
|
|
set(Boost_DIR ${BOOST_INST_PATH}/lib/cmake/Boost-1.78.0)
|
|
|
|
if(EXISTS ${FMT_INST_PATH}/lib64)
|
|
|
|
set(fmt_DIR ${FMT_INST_PATH}/lib64/cmake/fmt)
|
|
|
|
else()
|
|
|
|
set(fmt_DIR ${FMT_INST_PATH}/lib/cmake/fmt)
|
|
|
|
endif()
|
|
|
|
set(gflags_DIR ${GFLAGS_INST_PATH}/lib/cmake/gflags)
|
|
|
|
|
|
|
|
exec_program(sed ARGS -i 's/gflags_shared//g'
|
|
|
|
${FOLLY_INST_PATH}/lib/cmake/folly/folly-targets.cmake)
|
|
|
|
|
|
|
|
include(${FOLLY_INST_PATH}/lib/cmake/folly/folly-config.cmake)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_compile_definitions(USE_FOLLY FOLLY_NO_CONFIG HAVE_CXX11_ATOMIC)
|
|
|
|
list(APPEND THIRDPARTY_LIBS Folly::folly)
|
|
|
|
set(FOLLY_LIBS Folly::folly)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--copy-dt-needed-entries")
|
2019-08-07 21:29:35 +00:00
|
|
|
endif()
|
2016-09-28 18:53:15 +00:00
|
|
|
find_package(Threads REQUIRED)
|
2015-07-01 23:13:49 +00:00
|
|
|
|
2015-10-20 20:35:08 +00:00
|
|
|
# Main library source code
|
2016-09-28 18:53:15 +00:00
|
|
|
|
2015-07-01 23:13:49 +00:00
|
|
|
set(SOURCES
|
2020-04-29 01:02:11 +00:00
|
|
|
cache/cache.cc
|
Use deleters to label cache entries and collect stats (#8297)
Summary:
This change gathers and publishes statistics about the
kinds of items in block cache. This is especially important for
profiling relative usage of cache by index vs. filter vs. data blocks.
It works by iterating over the cache during periodic stats dump
(InternalStats, stats_dump_period_sec) or on demand when
DB::Get(Map)Property(kBlockCacheEntryStats), except that for
efficiency and sharing among column families, saved data from
the last scan is used when the data is not considered too old.
The new information can be seen in info LOG, for example:
Block cache LRUCache@0x7fca62229330 capacity: 95.37 MB collections: 8 last_copies: 0 last_secs: 0.00178 secs_since: 0
Block cache entry stats(count,size,portion): DataBlock(7092,28.24 MB,29.6136%) FilterBlock(215,867.90 KB,0.888728%) FilterMetaBlock(2,5.31 KB,0.00544%) IndexBlock(217,180.11 KB,0.184432%) WriteBuffer(1,256.00 KB,0.262144%) Misc(1,0.00 KB,0%)
And also through DB::GetProperty and GetMapProperty (here using
ldb just for demonstration):
$ ./ldb --db=/dev/shm/dbbench/ get_property rocksdb.block-cache-entry-stats
rocksdb.block-cache-entry-stats.bytes.data-block: 0
rocksdb.block-cache-entry-stats.bytes.deprecated-filter-block: 0
rocksdb.block-cache-entry-stats.bytes.filter-block: 0
rocksdb.block-cache-entry-stats.bytes.filter-meta-block: 0
rocksdb.block-cache-entry-stats.bytes.index-block: 178992
rocksdb.block-cache-entry-stats.bytes.misc: 0
rocksdb.block-cache-entry-stats.bytes.other-block: 0
rocksdb.block-cache-entry-stats.bytes.write-buffer: 0
rocksdb.block-cache-entry-stats.capacity: 8388608
rocksdb.block-cache-entry-stats.count.data-block: 0
rocksdb.block-cache-entry-stats.count.deprecated-filter-block: 0
rocksdb.block-cache-entry-stats.count.filter-block: 0
rocksdb.block-cache-entry-stats.count.filter-meta-block: 0
rocksdb.block-cache-entry-stats.count.index-block: 215
rocksdb.block-cache-entry-stats.count.misc: 1
rocksdb.block-cache-entry-stats.count.other-block: 0
rocksdb.block-cache-entry-stats.count.write-buffer: 0
rocksdb.block-cache-entry-stats.id: LRUCache@0x7f3636661290
rocksdb.block-cache-entry-stats.percent.data-block: 0.000000
rocksdb.block-cache-entry-stats.percent.deprecated-filter-block: 0.000000
rocksdb.block-cache-entry-stats.percent.filter-block: 0.000000
rocksdb.block-cache-entry-stats.percent.filter-meta-block: 0.000000
rocksdb.block-cache-entry-stats.percent.index-block: 2.133751
rocksdb.block-cache-entry-stats.percent.misc: 0.000000
rocksdb.block-cache-entry-stats.percent.other-block: 0.000000
rocksdb.block-cache-entry-stats.percent.write-buffer: 0.000000
rocksdb.block-cache-entry-stats.secs_for_last_collection: 0.000052
rocksdb.block-cache-entry-stats.secs_since_last_collection: 0
Solution detail - We need some way to flag what kind of blocks each
entry belongs to, preferably without changing the Cache API.
One of the complications is that Cache is a general interface that could
have other users that don't adhere to whichever convention we decide
on for keys and values. Or we would pay for an extra field in the Handle
that would only be used for this purpose.
This change uses a back-door approach, the deleter, to indicate the
"role" of a Cache entry (in addition to the value type, implicitly).
This has the added benefit of ensuring proper code origin whenever we
recognize a particular role for a cache entry; if the entry came from
some other part of the code, it will use an unrecognized deleter, which
we simply attribute to the "Misc" role.
An internal API makes for simple instantiation and automatic
registration of Cache deleters for a given value type and "role".
Another internal API, CacheEntryStatsCollector, solves the problem of
caching the results of a scan and sharing them, to ensure scans are
neither excessive nor redundant so as not to harm Cache performance.
Because code is added to BlocklikeTraits, it is pulled out of
block_based_table_reader.cc into its own file.
This is a reformulation of https://github.com/facebook/rocksdb/issues/8276, without the type checking option
(could still be added), and with actual stat gathering.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/8297
Test Plan: manual testing with db_bench, and a couple of basic unit tests
Reviewed By: ltamasi
Differential Revision: D28488721
Pulled By: pdillinger
fbshipit-source-id: 472f524a9691b5afb107934be2d41d84f2b129fb
2021-05-19 23:45:51 +00:00
|
|
|
cache/cache_entry_roles.cc
|
New stable, fixed-length cache keys (#9126)
Summary:
This change standardizes on a new 16-byte cache key format for
block cache (incl compressed and secondary) and persistent cache (but
not table cache and row cache).
The goal is a really fast cache key with practically ideal stability and
uniqueness properties without external dependencies (e.g. from FileSystem).
A fixed key size of 16 bytes should enable future optimizations to the
concurrent hash table for block cache, which is a heavy CPU user /
bottleneck, but there appears to be measurable performance improvement
even with no changes to LRUCache.
This change replaces a lot of disjointed and ugly code handling cache
keys with calls to a simple, clean new internal API (cache_key.h).
(Preserving the old cache key logic under an option would be very ugly
and likely negate the performance gain of the new approach. Complete
replacement carries some inherent risk, but I think that's acceptable
with sufficient analysis and testing.)
The scheme for encoding new cache keys is complicated but explained
in cache_key.cc.
Also: EndianSwapValue is moved to math.h to be next to other bit
operations. (Explains some new include "math.h".) ReverseBits operation
added and unit tests added to hash_test for both.
Fixes https://github.com/facebook/rocksdb/issues/7405 (presuming a root cause)
Pull Request resolved: https://github.com/facebook/rocksdb/pull/9126
Test Plan:
### Basic correctness
Several tests needed updates to work with the new functionality, mostly
because we are no longer relying on filesystem for stable cache keys
so table builders & readers need more context info to agree on cache
keys. This functionality is so core, a huge number of existing tests
exercise the cache key functionality.
### Performance
Create db with
`TEST_TMPDIR=/dev/shm ./db_bench -bloom_bits=10 -benchmarks=fillrandom -num=3000000 -partition_index_and_filters`
And test performance with
`TEST_TMPDIR=/dev/shm ./db_bench -readonly -use_existing_db -bloom_bits=10 -benchmarks=readrandom -num=3000000 -duration=30 -cache_index_and_filter_blocks -cache_size=250000 -threads=4`
using DEBUG_LEVEL=0 and simultaneous before & after runs.
Before ops/sec, avg over 100 runs: 121924
After ops/sec, avg over 100 runs: 125385 (+2.8%)
### Collision probability
I have built a tool, ./cache_bench -stress_cache_key to broadly simulate host-wide cache activity
over many months, by making some pessimistic simplifying assumptions:
* Every generated file has a cache entry for every byte offset in the file (contiguous range of cache keys)
* All of every file is cached for its entire lifetime
We use a simple table with skewed address assignment and replacement on address collision
to simulate files coming & going, with quite a variance (super-Poisson) in ages. Some output
with `./cache_bench -stress_cache_key -sck_keep_bits=40`:
```
Total cache or DBs size: 32TiB Writing 925.926 MiB/s or 76.2939TiB/day
Multiply by 9.22337e+18 to correct for simulation losses (but still assume whole file cached)
```
These come from default settings of 2.5M files per day of 32 MB each, and
`-sck_keep_bits=40` means that to represent a single file, we are only keeping 40 bits of
the 128-bit cache key. With file size of 2\*\*25 contiguous keys (pessimistic), our simulation
is about 2\*\*(128-40-25) or about 9 billion billion times more prone to collision than reality.
More default assumptions, relatively pessimistic:
* 100 DBs in same process (doesn't matter much)
* Re-open DB in same process (new session ID related to old session ID) on average
every 100 files generated
* Restart process (all new session IDs unrelated to old) 24 times per day
After enough data, we get a result at the end:
```
(keep 40 bits) 17 collisions after 2 x 90 days, est 10.5882 days between (9.76592e+19 corrected)
```
If we believe the (pessimistic) simulation and the mathematical generalization, we would need to run a billion machines all for 97 billion days to expect a cache key collision. To help verify that our generalization ("corrected") is robust, we can make our simulation more precise with `-sck_keep_bits=41` and `42`, which takes more running time to get enough data:
```
(keep 41 bits) 16 collisions after 4 x 90 days, est 22.5 days between (1.03763e+20 corrected)
(keep 42 bits) 19 collisions after 10 x 90 days, est 47.3684 days between (1.09224e+20 corrected)
```
The generalized prediction still holds. With the `-sck_randomize` option, we can see that we are beating "random" cache keys (except offsets still non-randomized) by a modest amount (roughly 20x less collision prone than random), which should make us reasonably comfortable even in "degenerate" cases:
```
197 collisions after 1 x 90 days, est 0.456853 days between (4.21372e+18 corrected)
```
I've run other tests to validate other conditions behave as expected, never behaving "worse than random" unless we start chopping off structured data.
Reviewed By: zhichao-cao
Differential Revision: D33171746
Pulled By: pdillinger
fbshipit-source-id: f16a57e369ed37be5e7e33525ace848d0537c88f
2021-12-17 01:13:55 +00:00
|
|
|
cache/cache_key.cc
|
Major Cache refactoring, CPU efficiency improvement (#10975)
Summary:
This is several refactorings bundled into one to avoid having to incrementally re-modify uses of Cache several times. Overall, there are breaking changes to Cache class, and it becomes more of low-level interface for implementing caches, especially block cache. New internal APIs make using Cache cleaner than before, and more insulated from block cache evolution. Hopefully, this is the last really big block cache refactoring, because of rather effectively decoupling the implementations from the uses. This change also removes the EXPERIMENTAL designation on the SecondaryCache support in Cache. It seems reasonably mature at this point but still subject to change/evolution (as I warn in the API docs for Cache).
The high-level motivation for this refactoring is to minimize code duplication / compounding complexity in adding SecondaryCache support to HyperClockCache (in a later PR). Other benefits listed below.
* static_cast lines of code +29 -35 (net removed 6)
* reinterpret_cast lines of code +6 -32 (net removed 26)
## cache.h and secondary_cache.h
* Always use CacheItemHelper with entries instead of just a Deleter. There are several motivations / justifications:
* Simpler for implementations to deal with just one Insert and one Lookup.
* Simpler and more efficient implementation because we don't have to track which entries are using helpers and which are using deleters
* Gets rid of hack to classify cache entries by their deleter. Instead, the CacheItemHelper includes a CacheEntryRole. This simplifies a lot of code (cache_entry_roles.h almost eliminated). Fixes https://github.com/facebook/rocksdb/issues/9428.
* Makes it trivial to adjust SecondaryCache behavior based on kind of block (e.g. don't re-compress filter blocks).
* It is arguably less convenient for many direct users of Cache, but direct users of Cache are now rare with introduction of typed_cache.h (below).
* I considered and rejected an alternative approach in which we reduce customizability by assuming each secondary cache compatible value starts with a Slice referencing the uncompressed block contents (already true or mostly true), but we apparently intend to stack secondary caches. Saving an entry from a compressed secondary to a lower tier requires custom handling offered by SaveToCallback, etc.
* Make CreateCallback part of the helper and introduce CreateContext to work with it (alternative to https://github.com/facebook/rocksdb/issues/10562). This cleans up the interface while still allowing context to be provided for loading/parsing values into primary cache. This model works for async lookup in BlockBasedTable reader (reader owns a CreateContext) under the assumption that it always waits on secondary cache operations to finish. (Otherwise, the CreateContext could be destroyed while async operation depending on it continues.) This likely contributes most to the observed performance improvement because it saves an std::function backed by a heap allocation.
* Use char* for serialized data, e.g. in SaveToCallback, where void* was confusingly used. (We use `char*` for serialized byte data all over RocksDB, with many advantages over `void*`. `memcpy` etc. are legacy APIs that should not be mimicked.)
* Add a type alias Cache::ObjectPtr = void*, so that we can better indicate the intent of the void* when it is to be the object associated with a Cache entry. Related: started (but did not complete) a refactoring to move away from "value" of a cache entry toward "object" or "obj". (It is confusing to call Cache a key-value store (like DB) when it is really storing arbitrary in-memory objects, not byte strings.)
* Remove unnecessary key param from DeleterFn. This is good for efficiency in HyperClockCache, which does not directly store the cache key in memory. (Alternative to https://github.com/facebook/rocksdb/issues/10774)
* Add allocator to Cache DeleterFn. This is a kind of future-proofing change in case we get more serious about using the Cache allocator for memory tracked by the Cache. Right now, only the uncompressed block contents are allocated using the allocator, and a pointer to that allocator is saved as part of the cached object so that the deleter can use it. (See CacheAllocationPtr.) If in the future we are able to "flatten out" our Cache objects some more, it would be good not to have to track the allocator as part of each object.
* Removes legacy `ApplyToAllCacheEntries` and changes `ApplyToAllEntries` signature for Deleter->CacheItemHelper change.
## typed_cache.h
Adds various "typed" interfaces to the Cache as internal APIs, so that most uses of Cache can use simple type safe code without casting and without explicit deleters, etc. Almost all of the non-test, non-glue code uses of Cache have been migrated. (Follow-up work: CompressedSecondaryCache deserves deeper attention to migrate.) This change expands RocksDB's internal usage of metaprogramming and SFINAE (https://en.cppreference.com/w/cpp/language/sfinae).
The existing usages of Cache are divided up at a high level into these new interfaces. See updated existing uses of Cache for examples of how these are used.
* PlaceholderCacheInterface - Used for making cache reservations, with entries that have a charge but no value.
* BasicTypedCacheInterface<TValue> - Used for primary cache storage of objects of type TValue, which can be cleaned up with std::default_delete<TValue>. The role is provided by TValue::kCacheEntryRole or given in an optional template parameter.
* FullTypedCacheInterface<TValue, TCreateContext> - Used for secondary cache compatible storage of objects of type TValue. In addition to BasicTypedCacheInterface constraints, we require TValue::ContentSlice() to return persistable data. This simplifies usage for the normal case of simple secondary cache compatibility (can give you a Slice to the data already in memory). In addition to TCreateContext performing the role of Cache::CreateContext, it is also expected to provide a factory function for creating TValue.
* For each of these, there's a "Shared" version (e.g. FullTypedSharedCacheInterface) that holds a shared_ptr to the Cache, rather than assuming external ownership by holding only a raw `Cache*`.
These interfaces introduce specific handle types for each interface instantiation, so that it's easy to see what kind of object is controlled by a handle. (Ultimately, this might not be worth the extra complexity, but it seems OK so far.)
Note: I attempted to make the cache 'charge' automatically inferred from the cache object type, such as by expecting an ApproximateMemoryUsage() function, but this is not so clean because there are cases where we need to compute the charge ahead of time and don't want to re-compute it.
## block_cache.h
This header is essentially the replacement for the old block_like_traits.h. It includes various things to support block cache access with typed_cache.h for block-based table.
## block_based_table_reader.cc
Before this change, accessing the block cache here was an awkward mix of static polymorphism (template TBlocklike) and switch-case on a dynamic BlockType value. This change mostly unifies on static polymorphism, relying on minor hacks in block_cache.h to distinguish variants of Block. We still check BlockType in some places (especially for stats, which could be improved in follow-up work) but at least the BlockType is a static constant from the template parameter. (No more awkward partial redundancy between static and dynamic info.) This likely contributes to the overall performance improvement, but hasn't been tested in isolation.
The other key source of simplification here is a more unified system of creating block cache objects: for directly populating from primary cache and for promotion from secondary cache. Both use BlockCreateContext, for context and for factory functions.
## block_based_table_builder.cc, cache_dump_load_impl.cc
Before this change, warming caches was super ugly code. Both of these source files had switch statements to basically transition from the dynamic BlockType world to the static TBlocklike world. None of that mess is needed anymore as there's a new, untyped WarmInCache function that handles all the details just as promotion from SecondaryCache would. (Fixes `TODO akanksha: Dedup below code` in block_based_table_builder.cc.)
## Everything else
Mostly just updating Cache users to use new typed APIs when reasonably possible, or changed Cache APIs when not.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/10975
Test Plan:
tests updated
Performance test setup similar to https://github.com/facebook/rocksdb/issues/10626 (by cache size, LRUCache when not "hyper" for HyperClockCache):
34MB 1thread base.hyper -> kops/s: 0.745 io_bytes/op: 2.52504e+06 miss_ratio: 0.140906 max_rss_mb: 76.4844
34MB 1thread new.hyper -> kops/s: 0.751 io_bytes/op: 2.5123e+06 miss_ratio: 0.140161 max_rss_mb: 79.3594
34MB 1thread base -> kops/s: 0.254 io_bytes/op: 1.36073e+07 miss_ratio: 0.918818 max_rss_mb: 45.9297
34MB 1thread new -> kops/s: 0.252 io_bytes/op: 1.36157e+07 miss_ratio: 0.918999 max_rss_mb: 44.1523
34MB 32thread base.hyper -> kops/s: 7.272 io_bytes/op: 2.88323e+06 miss_ratio: 0.162532 max_rss_mb: 516.602
34MB 32thread new.hyper -> kops/s: 7.214 io_bytes/op: 2.99046e+06 miss_ratio: 0.168818 max_rss_mb: 518.293
34MB 32thread base -> kops/s: 3.528 io_bytes/op: 1.35722e+07 miss_ratio: 0.914691 max_rss_mb: 264.926
34MB 32thread new -> kops/s: 3.604 io_bytes/op: 1.35744e+07 miss_ratio: 0.915054 max_rss_mb: 264.488
233MB 1thread base.hyper -> kops/s: 53.909 io_bytes/op: 2552.35 miss_ratio: 0.0440566 max_rss_mb: 241.984
233MB 1thread new.hyper -> kops/s: 62.792 io_bytes/op: 2549.79 miss_ratio: 0.044043 max_rss_mb: 241.922
233MB 1thread base -> kops/s: 1.197 io_bytes/op: 2.75173e+06 miss_ratio: 0.103093 max_rss_mb: 241.559
233MB 1thread new -> kops/s: 1.199 io_bytes/op: 2.73723e+06 miss_ratio: 0.10305 max_rss_mb: 240.93
233MB 32thread base.hyper -> kops/s: 1298.69 io_bytes/op: 2539.12 miss_ratio: 0.0440307 max_rss_mb: 371.418
233MB 32thread new.hyper -> kops/s: 1421.35 io_bytes/op: 2538.75 miss_ratio: 0.0440307 max_rss_mb: 347.273
233MB 32thread base -> kops/s: 9.693 io_bytes/op: 2.77304e+06 miss_ratio: 0.103745 max_rss_mb: 569.691
233MB 32thread new -> kops/s: 9.75 io_bytes/op: 2.77559e+06 miss_ratio: 0.103798 max_rss_mb: 552.82
1597MB 1thread base.hyper -> kops/s: 58.607 io_bytes/op: 1449.14 miss_ratio: 0.0249324 max_rss_mb: 1583.55
1597MB 1thread new.hyper -> kops/s: 69.6 io_bytes/op: 1434.89 miss_ratio: 0.0247167 max_rss_mb: 1584.02
1597MB 1thread base -> kops/s: 60.478 io_bytes/op: 1421.28 miss_ratio: 0.024452 max_rss_mb: 1589.45
1597MB 1thread new -> kops/s: 63.973 io_bytes/op: 1416.07 miss_ratio: 0.0243766 max_rss_mb: 1589.24
1597MB 32thread base.hyper -> kops/s: 1436.2 io_bytes/op: 1357.93 miss_ratio: 0.0235353 max_rss_mb: 1692.92
1597MB 32thread new.hyper -> kops/s: 1605.03 io_bytes/op: 1358.04 miss_ratio: 0.023538 max_rss_mb: 1702.78
1597MB 32thread base -> kops/s: 280.059 io_bytes/op: 1350.34 miss_ratio: 0.023289 max_rss_mb: 1675.36
1597MB 32thread new -> kops/s: 283.125 io_bytes/op: 1351.05 miss_ratio: 0.0232797 max_rss_mb: 1703.83
Almost uniformly improving over base revision, especially for hot paths with HyperClockCache, up to 12% higher throughput seen (1597MB, 32thread, hyper). The improvement for that is likely coming from much simplified code for providing context for secondary cache promotion (CreateCallback/CreateContext), and possibly from less branching in block_based_table_reader. And likely a small improvement from not reconstituting key for DeleterFn.
Reviewed By: anand1976
Differential Revision: D42417818
Pulled By: pdillinger
fbshipit-source-id: f86bfdd584dce27c028b151ba56818ad14f7a432
2023-01-11 22:20:40 +00:00
|
|
|
cache/cache_helpers.cc
|
2021-08-24 19:42:31 +00:00
|
|
|
cache/cache_reservation_manager.cc
|
2022-07-19 06:26:57 +00:00
|
|
|
cache/charged_cache.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
cache/clock_cache.cc
|
2022-04-11 20:28:33 +00:00
|
|
|
cache/compressed_secondary_cache.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
cache/lru_cache.cc
|
2022-11-22 00:17:36 +00:00
|
|
|
cache/secondary_cache.cc
|
HyperClockCache support for SecondaryCache, with refactoring (#11301)
Summary:
Internally refactors SecondaryCache integration out of LRUCache specifically and into a wrapper/adapter class that works with various Cache implementations. Notably, this relies on separating the notion of async lookup handles from other cache handles, so that HyperClockCache doesn't have to deal with the problem of allocating handles from the hash table for lookups that might fail anyway, and might be on the same key without support for coalescing. (LRUCache's hash table can incorporate previously allocated handles thanks to its pointer indirection.) Specifically, I'm worried about the case in which hundreds of threads try to access the same block and probing in the hash table degrades to linear search on the pile of entries with the same key.
This change is a big step in the direction of supporting stacked SecondaryCaches, but there are obstacles to completing that. Especially, there is no SecondaryCache hook for evictions to pass from one to the next. It has been proposed that evictions be transmitted simply as the persisted data (as in SaveToCallback), but given the current structure provided by the CacheItemHelpers, that would require an extra copy of the block data, because there's intentionally no way to ask for a contiguous Slice of the data (to allow for flexibility in storage). `AsyncLookupHandle` and the re-worked `WaitAll()` should be essentially prepared for stacked SecondaryCaches, but several "TODO with stacked secondaries" issues remain in various places.
It could be argued that the stacking instead be done as a SecondaryCache adapter that wraps two (or more) SecondaryCaches, but at least with the current API that would require an extra heap allocation on SecondaryCache Lookup for a wrapper SecondaryCacheResultHandle that can transfer a Lookup between secondaries. We could also consider trying to unify the Cache and SecondaryCache APIs, though that might be difficult if `AsyncLookupHandle` is kept a fixed struct.
## cache.h (public API)
Moves `secondary_cache` option from LRUCacheOptions to ShardedCacheOptions so that it is applicable to HyperClockCache.
## advanced_cache.h (advanced public API)
* Add `Cache::CreateStandalone()` so that the SecondaryCache support wrapper can use it.
* Add `SetEvictionCallback()` / `eviction_callback_` so that the SecondaryCache support wrapper can use it. Only a single callback is supported for efficiency. If there is ever a need for more than one, hopefully that can be handled with a broadcast callback wrapper.
These are essentially the two "extra" pieces of `Cache` for pulling out specific SecondaryCache support from the `Cache` implementation. I think it's a good trade-off as these are reasonable, limited, and reusable "cut points" into the `Cache` implementations.
* Remove async capability from standard `Lookup()` (getting rid of awkward restrictions on pending Handles) and add `AsyncLookupHandle` and `StartAsyncLookup()`. As noted in the comments, the full struct of `AsyncLookupHandle` is exposed so that it can be stack allocated, for efficiency, though more data is being copied around than before, which could impact performance. (Lookup info -> AsyncLookupHandle -> Handle vs. Lookup info -> Handle)
I could foresee a future in which a Cache internally saves a pointer to the AsyncLookupHandle, which means it's dangerous to allow it to be copyable or even movable. It also means it's not compatible with std::vector (which I don't like requiring as an API parameter anyway), so `WaitAll()` expects any contiguous array of AsyncLookupHandles. I believe this is best for common case efficiency, while behaving well in other cases also. For example, `WaitAll()` has no effect on default-constructed AsyncLookupHandles, which look like a completed cache miss.
## cacheable_entry.h
A couple of functions are obsolete because Cache::Handle can no longer be pending.
## cache.cc
Provides default implementations for new or revamped Cache functions, especially appropriate for non-blocking caches.
## secondary_cache_adapter.{h,cc}
The full details of the Cache wrapper adding SecondaryCache support. Essentially replicates the SecondaryCache handling that was in LRUCache, but obviously refactored. There is a bit of logic duplication, where Lookup() is essentially a manually optimized version of StartAsyncLookup() and Wait(), but it's roughly a dozen lines of code.
## sharded_cache.h, typed_cache.h, charged_cache.{h,cc}, sim_cache.cc
Simply updated for Cache API changes.
## lru_cache.{h,cc}
Carefully remove SecondaryCache logic, implement `CreateStandalone` and eviction handler functionality.
## clock_cache.{h,cc}
Expose existing `CreateStandalone` functionality, add eviction handler functionality. Light refactoring.
## block_based_table_reader*
Mostly re-worked the only usage of async Lookup, which is in BlockBasedTable::MultiGet. Used arrays in place of autovector in some places for efficiency. Simplified some logic by not trying to process some cache results before they're all ready.
Created new function `BlockBasedTable::GetCachePriority()` to reduce some pre-existing code duplication (and avoid making it worse).
Fixed at least one small bug from the prior confusing mixture of async and sync Lookups. In MaybeReadBlockAndLoadToCache(), called by RetrieveBlock(), called by MultiGet() with wait=false, is_cache_hit for the block_cache_tracer entry would not be set to true if the handle was pending after Lookup and before Wait.
## Intended follow-up work
* Figure out if there are any missing stats or block_cache_tracer work in refactored BlockBasedTable::MultiGet
* Stacked secondary caches (see above discussion)
* See if we can make up for the small MultiGet performance regression.
* Study more performance with SecondaryCache
* Items evicted from over-full LRUCache in Release were not being demoted to SecondaryCache, and still aren't to minimize unit test churn. Ideally they would be demoted, but it's an exceptional case so not a big deal.
* Use CreateStandalone for cache reservations (save unnecessary hash table operations). Not a big deal, but worthy cleanup.
* Somehow I got the contract for SecondaryCache::Insert wrong in #10945. (Doesn't take ownership!) That API comment needs to be fixed, but didn't want to mingle that in here.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/11301
Test Plan:
## Unit tests
Generally updated to include HCC in SecondaryCache tests, though HyperClockCache has some different, less strict behaviors that leads to some tests not really being set up to work with it. Some of the tests remain disabled with it, but I think we have good coverage without them.
## Crash/stress test
Updated to use the new combination.
## Performance
First, let's check for regression on caches without secondary cache configured. Adding support for the eviction callback is likely to have a tiny effect, but it shouldn't be worrisome. LRUCache could benefit slightly from less logic around SecondaryCache handling. We can test with cache_bench default settings, built with DEBUG_LEVEL=0 and PORTABLE=0.
```
(while :; do base/cache_bench --cache_type=hyper_clock_cache | grep Rough; done) | awk '{ sum += $9; count++; print $0; print "Average: " int(sum / count) }'
```
**Before** this and #11299 (which could also have a small effect), running for about an hour, before & after running concurrently for each cache type:
HyperClockCache: 3168662 (average parallel ops/sec)
LRUCache: 2940127
**After** this and #11299, running for about an hour:
HyperClockCache: 3164862 (average parallel ops/sec) (0.12% slower)
LRUCache: 2940928 (0.03% faster)
This is an acceptable difference IMHO.
Next, let's consider essentially the worst case of new CPU overhead affecting overall performance. MultiGet uses the async lookup interface regardless of whether SecondaryCache or folly are used. We can configure a benchmark where all block cache queries are for data blocks, and all are hits.
Create DB and test (before and after tests running simultaneously):
```
TEST_TMPDIR=/dev/shm ./db_bench -benchmarks=fillrandom -num=30000000 -disable_wal=1 -bloom_bits=16
TEST_TMPDIR=/dev/shm base/db_bench -benchmarks=multireadrandom[-X30] -readonly -multiread_batched -batch_size=32 -num=30000000 -bloom_bits=16 -cache_size=6789000000 -duration 20 -threads=16
```
**Before**:
multireadrandom [AVG 30 runs] : 3444202 (± 57049) ops/sec; 240.9 (± 4.0) MB/sec
multireadrandom [MEDIAN 30 runs] : 3514443 ops/sec; 245.8 MB/sec
**After**:
multireadrandom [AVG 30 runs] : 3291022 (± 58851) ops/sec; 230.2 (± 4.1) MB/sec
multireadrandom [MEDIAN 30 runs] : 3366179 ops/sec; 235.4 MB/sec
So that's roughly a 3% regression, on kind of a *worst case* test of MultiGet CPU. Similar story with HyperClockCache:
**Before**:
multireadrandom [AVG 30 runs] : 3933777 (± 41840) ops/sec; 275.1 (± 2.9) MB/sec
multireadrandom [MEDIAN 30 runs] : 3970667 ops/sec; 277.7 MB/sec
**After**:
multireadrandom [AVG 30 runs] : 3755338 (± 30391) ops/sec; 262.6 (± 2.1) MB/sec
multireadrandom [MEDIAN 30 runs] : 3785696 ops/sec; 264.8 MB/sec
Roughly a 4-5% regression. Not ideal, but not the whole story, fortunately.
Let's also look at Get() in db_bench:
```
TEST_TMPDIR=/dev/shm ./db_bench -benchmarks=readrandom[-X30] -readonly -num=30000000 -bloom_bits=16 -cache_size=6789000000 -duration 20 -threads=16
```
**Before**:
readrandom [AVG 30 runs] : 2198685 (± 13412) ops/sec; 153.8 (± 0.9) MB/sec
readrandom [MEDIAN 30 runs] : 2209498 ops/sec; 154.5 MB/sec
**After**:
readrandom [AVG 30 runs] : 2292814 (± 43508) ops/sec; 160.3 (± 3.0) MB/sec
readrandom [MEDIAN 30 runs] : 2365181 ops/sec; 165.4 MB/sec
That's showing roughly a 4% improvement, perhaps because of the secondary cache code that is no longer part of LRUCache. But weirdly, HyperClockCache is also showing 2-3% improvement:
**Before**:
readrandom [AVG 30 runs] : 2272333 (± 9992) ops/sec; 158.9 (± 0.7) MB/sec
readrandom [MEDIAN 30 runs] : 2273239 ops/sec; 159.0 MB/sec
**After**:
readrandom [AVG 30 runs] : 2332407 (± 11252) ops/sec; 163.1 (± 0.8) MB/sec
readrandom [MEDIAN 30 runs] : 2335329 ops/sec; 163.3 MB/sec
Reviewed By: ltamasi
Differential Revision: D44177044
Pulled By: pdillinger
fbshipit-source-id: e808e48ff3fe2f792a79841ba617be98e48689f5
2023-03-18 03:23:49 +00:00
|
|
|
cache/secondary_cache_adapter.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
cache/sharded_cache.cc
|
Support compressed and local flash secondary cache stacking (#11812)
Summary:
This PR implements support for a three tier cache - primary block cache, compressed secondary cache, and a nvm (local flash) secondary cache. This allows more effective utilization of the nvm cache, and minimizes the number of reads from local flash by caching compressed blocks in the compressed secondary cache.
The basic design is as follows -
1. A new secondary cache implementation, ```TieredSecondaryCache```, is introduced. It keeps the compressed and nvm secondary caches and manages the movement of blocks between them and the primary block cache. To setup a three tier cache, we allocate a ```CacheWithSecondaryAdapter```, with a ```TieredSecondaryCache``` instance as the secondary cache.
2. The table reader passes both the uncompressed and compressed block to ```FullTypedCacheInterface::InsertFull```, allowing the block cache to optionally store the compressed block.
3. When there's a miss, the block object is constructed and inserted in the primary cache, and the compressed block is inserted into the nvm cache by calling ```InsertSaved```. This avoids the overhead of recompressing the block, as well as avoiding putting more memory pressure on the compressed secondary cache.
4. When there's a hit in the nvm cache, we attempt to insert the block in the compressed secondary cache and the primary cache, subject to the admission policy of those caches (i.e admit on second access). Blocks/items evicted from any tier are simply discarded.
We can easily implement additional admission policies if desired.
Todo (In a subsequent PR):
1. Add to db_bench and run benchmarks
2. Add to db_stress
Pull Request resolved: https://github.com/facebook/rocksdb/pull/11812
Reviewed By: pdillinger
Differential Revision: D49461842
Pulled By: anand1976
fbshipit-source-id: b40ac1330ef7cd8c12efa0a3ca75128e602e3a0b
2023-09-22 03:30:53 +00:00
|
|
|
cache/tiered_secondary_cache.cc
|
2019-09-13 20:48:04 +00:00
|
|
|
db/arena_wrapped_db_iter.cc
|
2022-08-25 23:45:48 +00:00
|
|
|
db/blob/blob_contents.cc
|
2021-06-10 19:55:29 +00:00
|
|
|
db/blob/blob_fetcher.cc
|
2020-03-12 17:58:27 +00:00
|
|
|
db/blob/blob_file_addition.cc
|
2020-08-27 18:54:43 +00:00
|
|
|
db/blob/blob_file_builder.cc
|
2020-10-15 20:02:44 +00:00
|
|
|
db/blob/blob_file_cache.cc
|
2020-03-12 17:58:27 +00:00
|
|
|
db/blob/blob_file_garbage.cc
|
Add blob files to VersionStorageInfo/VersionBuilder (#6597)
Summary:
The patch adds a couple of classes to represent metadata about
blob files: `SharedBlobFileMetaData` contains the information elements
that are immutable (once the blob file is closed), e.g. blob file number,
total number and size of blob files, checksum method/value, while
`BlobFileMetaData` contains attributes that can vary across versions like
the amount of garbage in the file. There is a single `SharedBlobFileMetaData`
for each blob file, which is jointly owned by the `BlobFileMetaData` objects
that point to it; `BlobFileMetaData` objects, in turn, are owned by `Version`s
and can also be shared if the (immutable _and_ mutable) state of the blob file
is the same in two versions.
In addition, the patch adds the blob file metadata to `VersionStorageInfo`, and extends
`VersionBuilder` so that it can apply blob file related `VersionEdit`s (i.e. those
containing `BlobFileAddition`s and/or `BlobFileGarbage`), and save blob file metadata
to a new `VersionStorageInfo`. Consistency checks are also extended to ensure
that table files point to blob files that are part of the `Version`, and that all blob files
that are part of any given `Version` have at least some _non_-garbage data in them.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6597
Test Plan: `make check`
Reviewed By: riversand963
Differential Revision: D20656803
Pulled By: ltamasi
fbshipit-source-id: f1f74d135045b3b42d0146f03ee576ef0a4bfd80
2020-03-27 01:48:55 +00:00
|
|
|
db/blob/blob_file_meta.cc
|
Introduce a blob file reader class (#7461)
Summary:
The patch adds a class called `BlobFileReader` that can be used to retrieve blobs
using the information available in blob references (e.g. blob file number, offset, and
size). This will come in handy when implementing blob support for `Get`, `MultiGet`,
and iterators, and also for compaction/garbage collection.
When a `BlobFileReader` object is created (using the factory method `Create`),
it first checks whether the specified file is potentially valid by comparing the file
size against the combined size of the blob file header and footer (files smaller than
the threshold are considered malformed). Then, it opens the file, and reads and verifies
the header and footer. The verification involves magic number/CRC checks
as well as checking for unexpected header/footer fields, e.g. incorrect column family ID
or TTL blob files.
Blobs can be retrieved using `GetBlob`. `GetBlob` validates the offset and compression
type passed by the caller (because of the presence of the header and footer, the
specified offset cannot be too close to the start/end of the file; also, the compression type
has to match the one in the blob file header), and retrieves and potentially verifies and
uncompresses the blob. In particular, when `ReadOptions::verify_checksums` is set,
`BlobFileReader` reads the blob record header as well (as opposed to just the blob itself)
and verifies the key/value size, the key itself, as well as the CRC of the blob record header
and the key/value pair.
In addition, the patch exposes the compression type from `BlobIndex` (both using an
accessor and via `DebugString`), and adds a blob file read latency histogram to
`InternalStats` that can be used with `BlobFileReader`.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/7461
Test Plan: `make check`
Reviewed By: riversand963
Differential Revision: D23999219
Pulled By: ltamasi
fbshipit-source-id: deb6b1160d251258b308d5156e2ec063c3e12e5e
2020-10-07 22:43:23 +00:00
|
|
|
db/blob/blob_file_reader.cc
|
2021-06-22 05:24:23 +00:00
|
|
|
db/blob/blob_garbage_meter.cc
|
2020-06-09 22:12:59 +00:00
|
|
|
db/blob/blob_log_format.cc
|
2020-10-08 00:46:50 +00:00
|
|
|
db/blob/blob_log_sequential_reader.cc
|
2020-06-09 22:12:59 +00:00
|
|
|
db/blob/blob_log_writer.cc
|
2022-06-17 22:22:59 +00:00
|
|
|
db/blob/blob_source.cc
|
2021-11-20 01:52:42 +00:00
|
|
|
db/blob/prefetch_buffer_collection.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/builder.cc
|
|
|
|
db/c.cc
|
|
|
|
db/column_family.cc
|
2019-05-31 18:52:59 +00:00
|
|
|
db/compaction/compaction.cc
|
|
|
|
db/compaction/compaction_iterator.cc
|
2019-06-05 20:56:46 +00:00
|
|
|
db/compaction/compaction_picker.cc
|
2019-05-31 18:52:59 +00:00
|
|
|
db/compaction/compaction_job.cc
|
|
|
|
db/compaction/compaction_picker_fifo.cc
|
|
|
|
db/compaction/compaction_picker_level.cc
|
|
|
|
db/compaction/compaction_picker_universal.cc
|
2022-07-14 03:54:49 +00:00
|
|
|
db/compaction/compaction_service_job.cc
|
|
|
|
db/compaction/compaction_state.cc
|
|
|
|
db/compaction/compaction_outputs.cc
|
2020-07-24 20:43:14 +00:00
|
|
|
db/compaction/sst_partitioner.cc
|
2022-07-14 03:54:49 +00:00
|
|
|
db/compaction/subcompaction_state.cc
|
2015-07-15 21:51:51 +00:00
|
|
|
db/convenience.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/db_filesnapshot.cc
|
2021-03-23 20:47:56 +00:00
|
|
|
db/db_impl/compacted_db_impl.cc
|
2019-05-31 18:52:59 +00:00
|
|
|
db/db_impl/db_impl.cc
|
|
|
|
db/db_impl/db_impl_write.cc
|
|
|
|
db/db_impl/db_impl_compaction_flush.cc
|
|
|
|
db/db_impl/db_impl_files.cc
|
|
|
|
db/db_impl/db_impl_open.cc
|
|
|
|
db/db_impl/db_impl_debug.cc
|
|
|
|
db/db_impl/db_impl_experimental.cc
|
|
|
|
db/db_impl/db_impl_readonly.cc
|
|
|
|
db/db_impl/db_impl_secondary.cc
|
2016-01-26 01:49:58 +00:00
|
|
|
db/db_info_dumper.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/db_iter.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
db/dbformat.cc
|
2018-06-28 19:23:57 +00:00
|
|
|
db/error_handler.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/event_helpers.cc
|
|
|
|
db/experimental.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
db/external_sst_file_ingestion_job.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/file_indexer.cc
|
|
|
|
db/flush_job.cc
|
|
|
|
db/flush_scheduler.cc
|
|
|
|
db/forward_iterator.cc
|
2019-07-24 00:08:26 +00:00
|
|
|
db/import_column_family_job.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/internal_stats.cc
|
Skip deleted WALs during recovery
Summary:
This patch record min log number to keep to the manifest while flushing SST files to ignore them and any WAL older than them during recovery. This is to avoid scenarios when we have a gap between the WAL files are fed to the recovery procedure. The gap could happen by for example out-of-order WAL deletion. Such gap could cause problems in 2PC recovery where the prepared and commit entry are placed into two separate WAL and gap in the WALs could result into not processing the WAL with the commit entry and hence breaking the 2PC recovery logic.
Before the commit, for 2PC case, we determined which log number to keep in FindObsoleteFiles(). We looked at the earliest logs with outstanding prepare entries, or prepare entries whose respective commit or abort are in memtable. With the commit, the same calculation is done while we apply the SST flush. Just before installing the flush file, we precompute the earliest log file to keep after the flush finishes using the same logic (but skipping the memtables just flushed), record this information to the manifest entry for this new flushed SST file. This pre-computed value is also remembered in memory, and will later be used to determine whether a log file can be deleted. This value is unlikely to change until next flush because the commit entry will stay in memtable. (In WritePrepared, we could have removed the older log files as soon as all prepared entries are committed. It's not yet done anyway. Even if we do it, the only thing we loss with this new approach is earlier log deletion between two flushes, which does not guarantee to happen anyway because the obsolete file clean-up function is only executed after flush or compaction)
This min log number to keep is stored in the manifest using the safely-ignore customized field of AddFile entry, in order to guarantee that the DB generated using newer release can be opened by previous releases no older than 4.2.
Closes https://github.com/facebook/rocksdb/pull/3765
Differential Revision: D7747618
Pulled By: siying
fbshipit-source-id: d00c92105b4f83852e9754a1b70d6b64cb590729
2018-05-03 22:35:11 +00:00
|
|
|
db/logs_with_prep_tracker.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/log_reader.cc
|
|
|
|
db/log_writer.cc
|
2017-06-01 05:41:44 +00:00
|
|
|
db/malloc_stats.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/memtable.cc
|
|
|
|
db/memtable_list.cc
|
|
|
|
db/merge_helper.cc
|
|
|
|
db/merge_operator.cc
|
Introduce MultiCfIterator (#12153)
Summary:
This PR introduces a new implementation of `Iterator` via a new public API called `NewMultiCfIterator()`. The new API takes a vector of column family handles to build a cross-column-family iterator, which internally maintains multiple `DBIter`s as child iterators from a consistent database state. When a key exists in multiple column families, the iterator selects the value (and wide columns) from the first column family containing the key, following the order provided in the `column_families` parameter. Similar to the merging iterator, a min heap is used to iterate across the child iterators. Backward iteration and direction change functionalities will be implemented in future PRs.
The comparator used to compare keys across different column families will be derived from the iterator of the first column family specified in `column_families`. This comparator will be checked against the comparators from all other column families that the iterator will traverse. If there's a mismatch with any of the comparators, the initialization of the iterator will fail.
Please note that this PR is not enough for users to start using `MultiCfIterator`. The `MultiCfIterator` and related APIs are still marked as "**DO NOT USE - UNDER CONSTRUCTION**". This PR is just the first of many PRs that will follow soon.
This PR includes the following:
- Introduction and partial implementation of the `MultiCfIterator`, which implements the generic `Iterator` interface. The implementation includes the construction of the iterator, `SeekToFirst()`, `Next()`, `Valid()`, `key()`, `value()`, and `columns()`.
- Unit tests to verify iteration across multiple column families in two distinct scenarios: (1) keys are unique across all column families, and (2) the same keys exist in multiple column families.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/12153
Reviewed By: pdillinger
Differential Revision: D52308697
Pulled By: jaykorean
fbshipit-source-id: b03e69f13b40af5a8f0598d0f43a0bec01ef8294
2024-03-05 18:22:43 +00:00
|
|
|
db/multi_cf_iterator.cc
|
2020-10-01 17:08:52 +00:00
|
|
|
db/output_validator.cc
|
2022-08-26 01:52:37 +00:00
|
|
|
db/periodic_task_scheduler.cc
|
Compaction Support for Range Deletion
Summary:
This diff introduces RangeDelAggregator, which takes ownership of iterators
provided to it via AddTombstones(). The tombstones are organized in a two-level
map (snapshot stripe -> begin key -> tombstone). Tombstone creation avoids data
copy by holding Slices returned by the iterator, which remain valid thanks to pinning.
For compaction, we create a hierarchical range tombstone iterator with structure
matching the iterator over compaction input data. An aggregator based on that
iterator is used by CompactionIterator to determine which keys are covered by
range tombstones. In case of merge operand, the same aggregator is used by
MergeHelper. Upon finishing each file in the compaction, relevant range tombstones
are added to the output file's range tombstone metablock and file boundaries are
updated accordingly.
To check whether a key is covered by range tombstone, RangeDelAggregator::ShouldDelete()
considers tombstones in the key's snapshot stripe. When this function is used outside of
compaction, it also checks newer stripes, which can contain covering tombstones. Currently
the intra-stripe check involves a linear scan; however, in the future we plan to collapse ranges
within a stripe such that binary search can be used.
RangeDelAggregator::AddToBuilder() adds all range tombstones in the table's key-range
to a new table's range tombstone meta-block. Since range tombstones may fall in the gap
between files, we may need to extend some files' key-ranges. The strategy is (1) first file
extends as far left as possible and other files do not extend left, (2) all files extend right
until either the start of the next file or the end of the last range tombstone in the gap,
whichever comes first.
One other notable change is adding release/move semantics to ScopedArenaIterator
such that it can be used to transfer ownership of an arena-allocated iterator, similar to
how unique_ptr is used for malloc'd data.
Depends on D61473
Test Plan: compaction_iterator_test, mock_table, end-to-end tests in D63927
Reviewers: sdong, IslamAbdelRahman, wanning, yhchiang, lightmark
Reviewed By: lightmark
Subscribers: andrewkr, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D62205
2016-10-18 19:04:56 +00:00
|
|
|
db/range_del_aggregator.cc
|
Use only "local" range tombstones during Get (#4449)
Summary:
Previously, range tombstones were accumulated from every level, which
was necessary if a range tombstone in a higher level covered a key in a lower
level. However, RangeDelAggregator::AddTombstones's complexity is based on
the number of tombstones that are currently stored in it, which is wasteful in
the Get case, where we only need to know the highest sequence number of range
tombstones that cover the key from higher levels, and compute the highest covering
sequence number at the current level. This change introduces this optimization, and
removes the use of RangeDelAggregator from the Get path.
In the benchmark results, the following command was used to initialize the database:
```
./db_bench -db=/dev/shm/5k-rts -use_existing_db=false -benchmarks=filluniquerandom -write_buffer_size=1048576 -compression_type=lz4 -target_file_size_base=1048576 -max_bytes_for_level_base=4194304 -value_size=112 -key_size=16 -block_size=4096 -level_compaction_dynamic_level_bytes=true -num=5000000 -max_background_jobs=12 -benchmark_write_rate_limit=20971520 -range_tombstone_width=100 -writes_per_range_tombstone=100 -max_num_range_tombstones=50000 -bloom_bits=8
```
...and the following command was used to measure read throughput:
```
./db_bench -db=/dev/shm/5k-rts/ -use_existing_db=true -benchmarks=readrandom -disable_auto_compactions=true -num=5000000 -reads=100000 -threads=32
```
The filluniquerandom command was only run once, and the resulting database was used
to measure read performance before and after the PR. Both binaries were compiled with
`DEBUG_LEVEL=0`.
Readrandom results before PR:
```
readrandom : 4.544 micros/op 220090 ops/sec; 16.9 MB/s (63103 of 100000 found)
```
Readrandom results after PR:
```
readrandom : 11.147 micros/op 89707 ops/sec; 6.9 MB/s (63103 of 100000 found)
```
So it's actually slower right now, but this PR paves the way for future optimizations (see #4493).
----
Pull Request resolved: https://github.com/facebook/rocksdb/pull/4449
Differential Revision: D10370575
Pulled By: abhimadan
fbshipit-source-id: 9a2e152be1ef36969055c0e9eb4beb0d96c11f4d
2018-10-24 19:29:29 +00:00
|
|
|
db/range_tombstone_fragmenter.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/repair.cc
|
2022-07-15 04:49:34 +00:00
|
|
|
db/seqno_to_time_mapping.cc
|
2015-08-11 20:44:47 +00:00
|
|
|
db/snapshot_impl.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/table_cache.cc
|
|
|
|
db/table_properties_collector.cc
|
|
|
|
db/transaction_log_impl.cc
|
Refactor trimming logic for immutable memtables (#5022)
Summary:
MyRocks currently sets `max_write_buffer_number_to_maintain` in order to maintain enough history for transaction conflict checking. The effectiveness of this approach depends on the size of memtables. When memtables are small, it may not keep enough history; when memtables are large, this may consume too much memory.
We are proposing a new way to configure memtable list history: by limiting the memory usage of immutable memtables. The new option is `max_write_buffer_size_to_maintain` and it will take precedence over the old `max_write_buffer_number_to_maintain` if they are both set to non-zero values. The new option accounts for the total memory usage of flushed immutable memtables and mutable memtable. When the total usage exceeds the limit, RocksDB may start dropping immutable memtables (which is also called trimming history), starting from the oldest one.
The semantics of the old option actually works both as an upper bound and lower bound. History trimming will start if number of immutable memtables exceeds the limit, but it will never go below (limit-1) due to history trimming.
In order the mimic the behavior with the new option, history trimming will stop if dropping the next immutable memtable causes the total memory usage go below the size limit. For example, assuming the size limit is set to 64MB, and there are 3 immutable memtables with sizes of 20, 30, 30. Although the total memory usage is 80MB > 64MB, dropping the oldest memtable will reduce the memory usage to 60MB < 64MB, so in this case no memtable will be dropped.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5022
Differential Revision: D14394062
Pulled By: miasantreble
fbshipit-source-id: 60457a509c6af89d0993f988c9b5c2aa9e45f5c5
2019-08-23 20:54:09 +00:00
|
|
|
db/trim_history_scheduler.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/version_builder.cc
|
|
|
|
db/version_edit.cc
|
2020-03-21 02:17:54 +00:00
|
|
|
db/version_edit_handler.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/version_set.cc
|
Define WAL related classes to be used in VersionEdit and VersionSet (#7164)
Summary:
`WalAddition`, `WalDeletion` are defined in `wal_version.h` and used in `VersionEdit`.
`WalAddition` is used to represent events of creating a new WAL (no size, just log number), or closing a WAL (with size).
`WalDeletion` is used to represent events of deleting or archiving a WAL, it means the WAL is no longer alive (won't be replayed during recovery).
`WalSet` is the set of alive WALs kept in `VersionSet`.
1. Why use `WalDeletion` instead of relying on `MinLogNumber` to identify outdated WALs
On recovery, we can compute `MinLogNumber()` based on the log numbers kept in MANIFEST, any log with number < MinLogNumber can be ignored. So it seems that we don't need to persist `WalDeletion` to MANIFEST, since we can ignore the WALs based on MinLogNumber.
But the `MinLogNumber()` is actually a lower bound, it does not exactly mean that logs starting from MinLogNumber must exist. This is because in a corner case, when a column family is empty and never flushed, its log number is set to the largest log number, but not persisted in MANIFEST. So let's say there are 2 column families, when creating the DB, the first WAL has log number 1, so it's persisted to MANIFEST for both column families. Then CF 0 is empty and never flushed, CF 1 is updated and flushed, so a new WAL with log number 2 is created and persisted to MANIFEST for CF 1. But CF 0's log number in MANIFEST is still 1. So on recovery, MinLogNumber is 1, but since log 1 only contains data for CF 1, and CF 1 is flushed, log 1 might have already been deleted from disk.
We can make `MinLogNumber()` be the exactly minimum log number that must exist, by persisting the most recent log number for empty column families that are not flushed. But if there are N such column families, then every time a new WAL is created, we need to add N records to MANIFEST.
In current design, a record is persisted to MANIFEST only when WAL is created, closed, or deleted/archived, so the number of WAL related records are bounded to 3x number of WALs.
2. Why keep `WalSet` in `VersionSet` instead of applying the `VersionEdit`s to `VersionStorageInfo`
`VersionEdit`s are originally designed to track the addition and deletion of SST files. The SST files are related to column families, each column family has a list of `Version`s, and each `Version` keeps the set of active SST files in `VersionStorageInfo`.
But WALs are a concept of DB, they are not bounded to specific column families. So logically it does not make sense to store WALs in a column family's `Version`s.
Also, `Version`'s purpose is to keep reference to SST / blob files, so that they are not deleted until there is no version referencing them. But a WAL is deleted regardless of version references.
So we keep the WALs in `VersionSet` for the purpose of writing out the DB state's snapshot when creating new MANIFESTs.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/7164
Test Plan:
make version_edit_test && ./version_edit_test
make wal_edit_test && ./wal_edit_test
Reviewed By: ltamasi
Differential Revision: D22677936
Pulled By: cheng-chang
fbshipit-source-id: 5a3b6890140e572ffd79eb37e6e4c3c32361a859
2020-08-05 23:32:26 +00:00
|
|
|
db/wal_edit.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/wal_manager.cc
|
2022-06-04 03:54:48 +00:00
|
|
|
db/wide/wide_column_serialization.cc
|
Add support for wide-column point lookups (#10540)
Summary:
The patch adds a new API `GetEntity` that can be used to perform
wide-column point lookups. It also extends the `Get` code path and
the `MemTable` / `MemTableList` and `Version` / `GetContext` logic
accordingly so that wide-column entities can be served from both
memtables and SSTs. If the result of a lookup is a wide-column entity
(`kTypeWideColumnEntity`), it is passed to the application in deserialized
form; if it is a plain old key-value (`kTypeValue`), it is presented as a
wide-column entity with a single default (anonymous) column.
(In contrast, regular `Get` returns plain old key-values as-is, and
returns the value of the default column for wide-column entities, see
https://github.com/facebook/rocksdb/issues/10483 .)
The result of `GetEntity` is a self-contained `PinnableWideColumns` object.
`PinnableWideColumns` contains a `PinnableSlice`, which either stores the
underlying data in its own buffer or holds on to a cache handle. It also contains
a `WideColumns` instance, which indexes the contents of the `PinnableSlice`,
so applications can access the values of columns efficiently.
There are several pieces of functionality which are currently not supported
for wide-column entities: there is currently no `MultiGetEntity` or wide-column
iterator; also, `Merge` and `GetMergeOperands` are not supported, and there
is no `GetEntity` implementation for read-only and secondary instances.
We plan to implement these in future PRs.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/10540
Test Plan: `make check`
Reviewed By: akankshamahajan15
Differential Revision: D38847474
Pulled By: ltamasi
fbshipit-source-id: 42311a34ccdfe88b3775e847a5e2a5296e002b5b
2022-08-19 18:51:12 +00:00
|
|
|
db/wide/wide_columns.cc
|
Wide Column support in ldb (#11754)
Summary:
wide_columns can now be pretty-printed in the following commands
- `./ldb dump_wal`
- `./ldb dump`
- `./ldb idump`
- `./ldb dump_live_files`
- `./ldb scan`
- `./sst_dump --command=scan`
There are opportunities to refactor to reduce some nearly identical code. This PR is initial change to add wide column support in `ldb` and `sst_dump` tool. More PRs to come for the refactor.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/11754
Test Plan:
**New Tests added**
- `WideColumnsHelperTest::DumpWideColumns`
- `WideColumnsHelperTest::DumpSliceAsWideColumns`
**Changes added to existing tests**
- `ExternalSSTFileTest::BasicMixed` added to cover mixed case (This test should have been added in https://github.com/facebook/rocksdb/issues/11688). This test does not verify the ldb or sst_dump output. This test was used to create test SST files having some rows with wide columns and some without and the generated SST files were used to manually test sst_dump_tool.
- `createSST()` in `sst_dump_test` now takes `wide_column_one_in` to add wide column value in SST
**dump_wal**
```
./ldb dump_wal --walfile=/tmp/rocksdbtest-226125/db_wide_basic_test_2675429_2308393776696827948/000004.log --print_value --header
```
```
Sequence,Count,ByteSize,Physical Offset,Key(s) : value
1,1,59,0,PUT_ENTITY(0) : 0x:0x68656C6C6F 0x617474725F6E616D6531:0x666F6F 0x617474725F6E616D6532:0x626172
2,1,34,42,PUT_ENTITY(0) : 0x617474725F6F6E65:0x74776F 0x617474725F7468726565:0x666F7572
3,1,17,7d,PUT(0) : 0x7468697264 : 0x62617A
```
**idump**
```
./ldb --db=/tmp/rocksdbtest-226125/db_wide_basic_test_3481961_2308393776696827948/ idump
```
```
'first' seq:1, type:22 => :hello attr_name1:foo attr_name2:bar
'second' seq:2, type:22 => attr_one:two attr_three:four
'third' seq:3, type:1 => baz
Internal keys in range: 3
```
**SST Dump from dump_live_files**
```
./ldb --db=/tmp/rocksdbtest-226125/db_wide_basic_test_3481961_2308393776696827948/ compact
./ldb --db=/tmp/rocksdbtest-226125/db_wide_basic_test_3481961_2308393776696827948/ dump_live_files
```
```
...
==============================
SST Files
==============================
/tmp/rocksdbtest-226125/db_wide_basic_test_3481961_2308393776696827948/000013.sst level:1
------------------------------
Process /tmp/rocksdbtest-226125/db_wide_basic_test_3481961_2308393776696827948/000013.sst
Sst file format: block-based
'first' seq:0, type:22 => :hello attr_name1:foo attr_name2:bar
'second' seq:0, type:22 => attr_one:two attr_three:four
'third' seq:0, type:1 => baz
...
```
**dump**
```
./ldb --db=/tmp/rocksdbtest-226125/db_wide_basic_test_3481961_2308393776696827948/ dump
```
```
first ==> :hello attr_name1:foo attr_name2:bar
second ==> attr_one:two attr_three:four
third ==> baz
Keys in range: 3
```
**scan**
```
./ldb --db=/tmp/rocksdbtest-226125/db_wide_basic_test_3481961_2308393776696827948/ scan
```
```
first : :hello attr_name1:foo attr_name2:bar
second : attr_one:two attr_three:four
third : baz
```
**sst_dump**
```
./sst_dump --file=/tmp/rocksdbtest-226125/db_wide_basic_test_3481961_2308393776696827948/000013.sst --command=scan
```
```
options.env is 0x7ff54b296000
Process /tmp/rocksdbtest-226125/db_wide_basic_test_3481961_2308393776696827948/000013.sst
Sst file format: block-based
from [] to []
'first' seq:0, type:22 => :hello attr_name1:foo attr_name2:bar
'second' seq:0, type:22 => attr_one:two attr_three:four
'third' seq:0, type:1 => baz
```
Reviewed By: ltamasi
Differential Revision: D48837999
Pulled By: jaykorean
fbshipit-source-id: b0280f0589d2b9716bb9b50530ffcabb397d140f
2023-08-30 19:45:52 +00:00
|
|
|
db/wide/wide_columns_helper.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/write_batch.cc
|
|
|
|
db/write_batch_base.cc
|
|
|
|
db/write_controller.cc
|
2023-03-18 16:51:58 +00:00
|
|
|
db/write_stall_stats.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/write_thread.cc
|
2021-01-26 06:07:26 +00:00
|
|
|
env/composite_env.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
env/env.cc
|
|
|
|
env/env_chroot.cc
|
2017-06-26 23:52:06 +00:00
|
|
|
env/env_encryption.cc
|
Introduce a new storage specific Env API (#5761)
Summary:
The current Env API encompasses both storage/file operations, as well as OS related operations. Most of the APIs return a Status, which does not have enough metadata about an error, such as whether its retry-able or not, scope (i.e fault domain) of the error etc., that may be required in order to properly handle a storage error. The file APIs also do not provide enough control over the IO SLA, such as timeout, prioritization, hinting about placement and redundancy etc.
This PR separates out the file/storage APIs from Env into a new FileSystem class. The APIs are updated to return an IOStatus with metadata about the error, as well as to take an IOOptions structure as input in order to allow more control over the IO.
The user can set both ```options.env``` and ```options.file_system``` to specify that RocksDB should use the former for OS related operations and the latter for storage operations. Internally, a ```CompositeEnvWrapper``` has been introduced that inherits from ```Env``` and redirects individual methods to either an ```Env``` implementation or the ```FileSystem``` as appropriate. When options are sanitized during ```DB::Open```, ```options.env``` is replaced with a newly allocated ```CompositeEnvWrapper``` instance if both env and file_system have been specified. This way, the rest of the RocksDB code can continue to function as before.
This PR also ports PosixEnv to the new API by splitting it into two - PosixEnv and PosixFileSystem. PosixEnv is defined as a sub-class of CompositeEnvWrapper, and threading/time functions are overridden with Posix specific implementations in order to avoid an extra level of indirection.
The ```CompositeEnvWrapper``` translates ```IOStatus``` return code to ```Status```, and sets the severity to ```kSoftError``` if the io_status is retryable. The error handling code in RocksDB can then recover the DB automatically.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5761
Differential Revision: D18868376
Pulled By: anand1976
fbshipit-source-id: 39efe18a162ea746fabac6360ff529baba48486f
2019-12-13 22:47:08 +00:00
|
|
|
env/file_system.cc
|
2020-08-05 01:40:19 +00:00
|
|
|
env/file_system_tracer.cc
|
Make backups openable as read-only DBs (#8142)
Summary:
A current limitation of backups is that you don't know the
exact database state of when the backup was taken. With this new
feature, you can at least inspect the backup's DB state without
restoring it by opening it as a read-only DB.
Rather than add something like OpenAsReadOnlyDB to the BackupEngine API,
which would inhibit opening stackable DB implementations read-only
(if/when their APIs support it), we instead provide a DB name and Env
that can be used to open as a read-only DB.
Possible follow-up work:
* Add a version of GetBackupInfo for a single backup.
* Let CreateNewBackup return the BackupID of the newly-created backup.
Implementation details:
Refactored ChrootFileSystem to split off new base class RemapFileSystem,
which allows more general remapping of files. We use this base class to
implement BackupEngineImpl::RemapSharedFileSystem.
To minimize API impact, I decided to just add these fields `name_for_open`
and `env_for_open` to those set by GetBackupInfo when
include_file_details=true. Creating the RemapSharedFileSystem adds a bit
to the memory consumption, perhaps unnecessarily in some cases, but this
has been mitigated by (a) only initialize the RemapSharedFileSystem
lazily when GetBackupInfo with include_file_details=true is called, and
(b) using the existing `shared_ptr<FileInfo>` objects to hold most of the
mapping data.
To enhance API safety, RemapSharedFileSystem is wrapped by new
ReadOnlyFileSystem which rejects any attempts to write. This uncovered a
couple of places in which DB::OpenForReadOnly would write to the
filesystem, so I fixed these. Added a release note because this affects
logging.
Additional minor refactoring in backupable_db.cc to support the new
functionality.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/8142
Test Plan:
new test (run with ASAN and UBSAN), added to stress test and
ran it for a while with amplified backup_one_in
Reviewed By: ajkr
Differential Revision: D27535408
Pulled By: pdillinger
fbshipit-source-id: 04666d310aa0261ef6b2385c43ca793ce1dfd148
2021-04-06 21:36:45 +00:00
|
|
|
env/fs_remap.cc
|
2017-06-01 22:30:27 +00:00
|
|
|
env/mock_env.cc
|
Experimental support for SST unique IDs (#8990)
Summary:
* New public header unique_id.h and function GetUniqueIdFromTableProperties
which computes a universally unique identifier based on table properties
of table files from recent RocksDB versions.
* Generation of DB session IDs is refactored so that they are
guaranteed unique in the lifetime of a process running RocksDB.
(SemiStructuredUniqueIdGen, new test included.) Along with file numbers,
this enables SST unique IDs to be guaranteed unique among SSTs generated
in a single process, and "better than random" between processes.
See https://github.com/pdillinger/unique_id
* In addition to public API producing 'external' unique IDs, there is a function
for producing 'internal' unique IDs, with functions for converting between the
two. In short, the external ID is "safe" for things people might do with it, and
the internal ID enables more "power user" features for the future. Specifically,
the external ID goes through a hashing layer so that any subset of bits in the
external ID can be used as a hash of the full ID, while also preserving
uniqueness guarantees in the first 128 bits (bijective both on first 128 bits
and on full 192 bits).
Intended follow-up:
* Use the internal unique IDs in cache keys. (Avoid conflicts with https://github.com/facebook/rocksdb/issues/8912) (The file offset can be XORed into
the third 64-bit value of the unique ID.)
* Publish the external unique IDs in FileStorageInfo (https://github.com/facebook/rocksdb/issues/8968)
Pull Request resolved: https://github.com/facebook/rocksdb/pull/8990
Test Plan:
Unit tests added, and checking of unique ids in stress test.
NOTE in stress test we do not generate nearly enough files to thoroughly
stress uniqueness, but the test trims off pieces of the ID to check for
uniqueness so that we can infer (with some assumptions) stronger
properties in the aggregate.
Reviewed By: zhichao-cao, mrambacher
Differential Revision: D31582865
Pulled By: pdillinger
fbshipit-source-id: 1f620c4c86af9abe2a8d177b9ccf2ad2b9f48243
2021-10-19 06:28:28 +00:00
|
|
|
env/unique_id_gen.cc
|
2019-05-30 03:44:08 +00:00
|
|
|
file/delete_scheduler.cc
|
2019-09-16 17:31:27 +00:00
|
|
|
file/file_prefetch_buffer.cc
|
2019-05-30 03:44:08 +00:00
|
|
|
file/file_util.cc
|
|
|
|
file/filename.cc
|
2021-03-10 04:10:51 +00:00
|
|
|
file/line_file_reader.cc
|
2019-09-16 17:31:27 +00:00
|
|
|
file/random_access_file_reader.cc
|
|
|
|
file/read_write_util.cc
|
|
|
|
file/readahead_raf.cc
|
|
|
|
file/sequence_file_reader.cc
|
2019-05-30 03:44:08 +00:00
|
|
|
file/sst_file_manager_impl.cc
|
2019-09-16 17:31:27 +00:00
|
|
|
file/writable_file_writer.cc
|
2019-06-01 00:19:43 +00:00
|
|
|
logging/auto_roll_logger.cc
|
|
|
|
logging/event_logger.cc
|
|
|
|
logging/log_buffer.cc
|
2019-05-31 00:39:43 +00:00
|
|
|
memory/arena.cc
|
|
|
|
memory/concurrent_arena.cc
|
|
|
|
memory/jemalloc_nodump_allocator.cc
|
Provide an allocator for new memory type to be used with RocksDB block cache (#6214)
Summary:
New memory technologies are being developed by various hardware vendors (Intel DCPMM is one such technology currently available). These new memory types require different libraries for allocation and management (such as PMDK and memkind). The high capacities available make it possible to provision large caches (up to several TBs in size), beyond what is achievable with DRAM.
The new allocator provided in this PR uses the memkind library to allocate memory on different media.
**Performance**
We tested the new allocator using db_bench.
- For each test, we vary the size of the block cache (relative to the size of the uncompressed data in the database).
- The database is filled sequentially. Throughput is then measured with a readrandom benchmark.
- We use a uniform distribution as a worst-case scenario.
The plot shows throughput (ops/s) relative to a configuration with no block cache and default allocator.
For all tests, p99 latency is below 500 us.
![image](https://user-images.githubusercontent.com/26400080/71108594-42479100-2178-11ea-8231-8a775bbc92db.png)
**Changes**
- Add MemkindKmemAllocator
- Add --use_cache_memkind_kmem_allocator db_bench option (to create an LRU block cache with the new allocator)
- Add detection of memkind library with KMEM DAX support
- Add test for MemkindKmemAllocator
**Minimum Requirements**
- kernel 5.3.12
- ndctl v67 - https://github.com/pmem/ndctl
- memkind v1.10.0 - https://github.com/memkind/memkind
**Memory Configuration**
The allocator uses the MEMKIND_DAX_KMEM memory kind. Follow the instructions on[ memkind’s GitHub page](https://github.com/memkind/memkind) to set up NVDIMM memory accordingly.
Note on memory allocation with NVDIMM memory exposed as system memory.
- The MemkindKmemAllocator will only allocate from NVDIMM memory (using memkind_malloc with MEMKIND_DAX_KMEM kind).
- The default allocator is not restricted to RAM by default. Based on NUMA node latency, the kernel should allocate from local RAM preferentially, but it’s a kernel decision. numactl --preferred/--membind can be used to allocate preferentially/exclusively from the local RAM node.
**Usage**
When creating an LRU cache, pass a MemkindKmemAllocator object as argument.
For example (replace capacity with the desired value in bytes):
```
#include "rocksdb/cache.h"
#include "memory/memkind_kmem_allocator.h"
NewLRUCache(
capacity /*size_t*/,
6 /*cache_numshardbits*/,
false /*strict_capacity_limit*/,
false /*cache_high_pri_pool_ratio*/,
std::make_shared<MemkindKmemAllocator>());
```
Refer to [RocksDB’s block cache documentation](https://github.com/facebook/rocksdb/wiki/Block-Cache) to assign the LRU cache as block cache for a database.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6214
Reviewed By: cheng-chang
Differential Revision: D19292435
fbshipit-source-id: 7202f47b769e7722b539c86c2ffd669f64d7b4e1
2020-04-10 03:45:17 +00:00
|
|
|
memory/memkind_kmem_allocator.cc
|
2021-12-17 12:19:34 +00:00
|
|
|
memory/memory_allocator.cc
|
2017-06-02 21:13:59 +00:00
|
|
|
memtable/alloc_tracker.cc
|
2015-10-16 21:10:33 +00:00
|
|
|
memtable/hash_linklist_rep.cc
|
|
|
|
memtable/hash_skiplist_rep.cc
|
2016-01-26 01:49:58 +00:00
|
|
|
memtable/skiplistrep.cc
|
|
|
|
memtable/vectorrep.cc
|
2017-06-02 21:13:59 +00:00
|
|
|
memtable/write_buffer_manager.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
monitoring/histogram.cc
|
|
|
|
monitoring/histogram_windowing.cc
|
2019-06-17 22:17:43 +00:00
|
|
|
monitoring/in_memory_stats_history.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
monitoring/instrumented_mutex.cc
|
|
|
|
monitoring/iostats_context.cc
|
|
|
|
monitoring/perf_context.cc
|
|
|
|
monitoring/perf_level.cc
|
2019-06-17 22:17:43 +00:00
|
|
|
monitoring/persistent_stats_history.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
monitoring/statistics.cc
|
|
|
|
monitoring/thread_status_impl.cc
|
|
|
|
monitoring/thread_status_updater.cc
|
|
|
|
monitoring/thread_status_util.cc
|
|
|
|
monitoring/thread_status_util_debug.cc
|
|
|
|
options/cf_options.cc
|
2020-09-14 23:59:00 +00:00
|
|
|
options/configurable.cc
|
2020-11-11 23:09:14 +00:00
|
|
|
options/customizable.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
options/db_options.cc
|
2023-10-27 22:56:48 +00:00
|
|
|
options/offpeak_time_info.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
options/options.cc
|
|
|
|
options/options_helper.cc
|
|
|
|
options/options_parser.cc
|
2022-10-18 00:10:16 +00:00
|
|
|
port/mmap.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
port/stack_trace.cc
|
2019-05-30 21:47:29 +00:00
|
|
|
table/adaptive/adaptive_table_factory.cc
|
2020-03-13 04:39:36 +00:00
|
|
|
table/block_based/binary_search_index_reader.cc
|
2019-05-30 21:47:29 +00:00
|
|
|
table/block_based/block.cc
|
|
|
|
table/block_based/block_based_table_builder.cc
|
|
|
|
table/block_based/block_based_table_factory.cc
|
De-template block based table iterator (#6531)
Summary:
Right now block based table iterator is used as both of iterating data for block based table, and for the index iterator for partitioend index. This was initially convenient for introducing a new iterator and block type for new index format, while reducing code change. However, these two usage doesn't go with each other very well. For example, Prev() is never called for partitioned index iterator, and some other complexity is maintained in block based iterators, which is not needed for index iterator but maintainers will always need to reason about it. Furthermore, the template usage is not following Google C++ Style which we are following, and makes a large chunk of code tangled together. This commit separate the two iterators. Right now, here is what it is done:
1. Copy the block based iterator code into partitioned index iterator, and de-template them.
2. Remove some code not needed for partitioned index. The upper bound check and tricks are removed. We never tested performance for those tricks when partitioned index is enabled in the first place. It's unlikelyl to generate performance regression, as creating new partitioned index block is much rarer than data blocks.
3. Separate out the prefetch logic to a helper class and both classes call them.
This commit will enable future follow-ups. One direction is that we might separate index iterator interface for data blocks and index blocks, as they are quite different.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6531
Test Plan: build using make and cmake. And build release
Differential Revision: D20473108
fbshipit-source-id: e48011783b339a4257c204cc07507b171b834b0f
2020-03-16 19:17:34 +00:00
|
|
|
table/block_based/block_based_table_iterator.cc
|
2019-05-30 21:47:29 +00:00
|
|
|
table/block_based/block_based_table_reader.cc
|
|
|
|
table/block_based/block_builder.cc
|
Major Cache refactoring, CPU efficiency improvement (#10975)
Summary:
This is several refactorings bundled into one to avoid having to incrementally re-modify uses of Cache several times. Overall, there are breaking changes to Cache class, and it becomes more of low-level interface for implementing caches, especially block cache. New internal APIs make using Cache cleaner than before, and more insulated from block cache evolution. Hopefully, this is the last really big block cache refactoring, because of rather effectively decoupling the implementations from the uses. This change also removes the EXPERIMENTAL designation on the SecondaryCache support in Cache. It seems reasonably mature at this point but still subject to change/evolution (as I warn in the API docs for Cache).
The high-level motivation for this refactoring is to minimize code duplication / compounding complexity in adding SecondaryCache support to HyperClockCache (in a later PR). Other benefits listed below.
* static_cast lines of code +29 -35 (net removed 6)
* reinterpret_cast lines of code +6 -32 (net removed 26)
## cache.h and secondary_cache.h
* Always use CacheItemHelper with entries instead of just a Deleter. There are several motivations / justifications:
* Simpler for implementations to deal with just one Insert and one Lookup.
* Simpler and more efficient implementation because we don't have to track which entries are using helpers and which are using deleters
* Gets rid of hack to classify cache entries by their deleter. Instead, the CacheItemHelper includes a CacheEntryRole. This simplifies a lot of code (cache_entry_roles.h almost eliminated). Fixes https://github.com/facebook/rocksdb/issues/9428.
* Makes it trivial to adjust SecondaryCache behavior based on kind of block (e.g. don't re-compress filter blocks).
* It is arguably less convenient for many direct users of Cache, but direct users of Cache are now rare with introduction of typed_cache.h (below).
* I considered and rejected an alternative approach in which we reduce customizability by assuming each secondary cache compatible value starts with a Slice referencing the uncompressed block contents (already true or mostly true), but we apparently intend to stack secondary caches. Saving an entry from a compressed secondary to a lower tier requires custom handling offered by SaveToCallback, etc.
* Make CreateCallback part of the helper and introduce CreateContext to work with it (alternative to https://github.com/facebook/rocksdb/issues/10562). This cleans up the interface while still allowing context to be provided for loading/parsing values into primary cache. This model works for async lookup in BlockBasedTable reader (reader owns a CreateContext) under the assumption that it always waits on secondary cache operations to finish. (Otherwise, the CreateContext could be destroyed while async operation depending on it continues.) This likely contributes most to the observed performance improvement because it saves an std::function backed by a heap allocation.
* Use char* for serialized data, e.g. in SaveToCallback, where void* was confusingly used. (We use `char*` for serialized byte data all over RocksDB, with many advantages over `void*`. `memcpy` etc. are legacy APIs that should not be mimicked.)
* Add a type alias Cache::ObjectPtr = void*, so that we can better indicate the intent of the void* when it is to be the object associated with a Cache entry. Related: started (but did not complete) a refactoring to move away from "value" of a cache entry toward "object" or "obj". (It is confusing to call Cache a key-value store (like DB) when it is really storing arbitrary in-memory objects, not byte strings.)
* Remove unnecessary key param from DeleterFn. This is good for efficiency in HyperClockCache, which does not directly store the cache key in memory. (Alternative to https://github.com/facebook/rocksdb/issues/10774)
* Add allocator to Cache DeleterFn. This is a kind of future-proofing change in case we get more serious about using the Cache allocator for memory tracked by the Cache. Right now, only the uncompressed block contents are allocated using the allocator, and a pointer to that allocator is saved as part of the cached object so that the deleter can use it. (See CacheAllocationPtr.) If in the future we are able to "flatten out" our Cache objects some more, it would be good not to have to track the allocator as part of each object.
* Removes legacy `ApplyToAllCacheEntries` and changes `ApplyToAllEntries` signature for Deleter->CacheItemHelper change.
## typed_cache.h
Adds various "typed" interfaces to the Cache as internal APIs, so that most uses of Cache can use simple type safe code without casting and without explicit deleters, etc. Almost all of the non-test, non-glue code uses of Cache have been migrated. (Follow-up work: CompressedSecondaryCache deserves deeper attention to migrate.) This change expands RocksDB's internal usage of metaprogramming and SFINAE (https://en.cppreference.com/w/cpp/language/sfinae).
The existing usages of Cache are divided up at a high level into these new interfaces. See updated existing uses of Cache for examples of how these are used.
* PlaceholderCacheInterface - Used for making cache reservations, with entries that have a charge but no value.
* BasicTypedCacheInterface<TValue> - Used for primary cache storage of objects of type TValue, which can be cleaned up with std::default_delete<TValue>. The role is provided by TValue::kCacheEntryRole or given in an optional template parameter.
* FullTypedCacheInterface<TValue, TCreateContext> - Used for secondary cache compatible storage of objects of type TValue. In addition to BasicTypedCacheInterface constraints, we require TValue::ContentSlice() to return persistable data. This simplifies usage for the normal case of simple secondary cache compatibility (can give you a Slice to the data already in memory). In addition to TCreateContext performing the role of Cache::CreateContext, it is also expected to provide a factory function for creating TValue.
* For each of these, there's a "Shared" version (e.g. FullTypedSharedCacheInterface) that holds a shared_ptr to the Cache, rather than assuming external ownership by holding only a raw `Cache*`.
These interfaces introduce specific handle types for each interface instantiation, so that it's easy to see what kind of object is controlled by a handle. (Ultimately, this might not be worth the extra complexity, but it seems OK so far.)
Note: I attempted to make the cache 'charge' automatically inferred from the cache object type, such as by expecting an ApproximateMemoryUsage() function, but this is not so clean because there are cases where we need to compute the charge ahead of time and don't want to re-compute it.
## block_cache.h
This header is essentially the replacement for the old block_like_traits.h. It includes various things to support block cache access with typed_cache.h for block-based table.
## block_based_table_reader.cc
Before this change, accessing the block cache here was an awkward mix of static polymorphism (template TBlocklike) and switch-case on a dynamic BlockType value. This change mostly unifies on static polymorphism, relying on minor hacks in block_cache.h to distinguish variants of Block. We still check BlockType in some places (especially for stats, which could be improved in follow-up work) but at least the BlockType is a static constant from the template parameter. (No more awkward partial redundancy between static and dynamic info.) This likely contributes to the overall performance improvement, but hasn't been tested in isolation.
The other key source of simplification here is a more unified system of creating block cache objects: for directly populating from primary cache and for promotion from secondary cache. Both use BlockCreateContext, for context and for factory functions.
## block_based_table_builder.cc, cache_dump_load_impl.cc
Before this change, warming caches was super ugly code. Both of these source files had switch statements to basically transition from the dynamic BlockType world to the static TBlocklike world. None of that mess is needed anymore as there's a new, untyped WarmInCache function that handles all the details just as promotion from SecondaryCache would. (Fixes `TODO akanksha: Dedup below code` in block_based_table_builder.cc.)
## Everything else
Mostly just updating Cache users to use new typed APIs when reasonably possible, or changed Cache APIs when not.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/10975
Test Plan:
tests updated
Performance test setup similar to https://github.com/facebook/rocksdb/issues/10626 (by cache size, LRUCache when not "hyper" for HyperClockCache):
34MB 1thread base.hyper -> kops/s: 0.745 io_bytes/op: 2.52504e+06 miss_ratio: 0.140906 max_rss_mb: 76.4844
34MB 1thread new.hyper -> kops/s: 0.751 io_bytes/op: 2.5123e+06 miss_ratio: 0.140161 max_rss_mb: 79.3594
34MB 1thread base -> kops/s: 0.254 io_bytes/op: 1.36073e+07 miss_ratio: 0.918818 max_rss_mb: 45.9297
34MB 1thread new -> kops/s: 0.252 io_bytes/op: 1.36157e+07 miss_ratio: 0.918999 max_rss_mb: 44.1523
34MB 32thread base.hyper -> kops/s: 7.272 io_bytes/op: 2.88323e+06 miss_ratio: 0.162532 max_rss_mb: 516.602
34MB 32thread new.hyper -> kops/s: 7.214 io_bytes/op: 2.99046e+06 miss_ratio: 0.168818 max_rss_mb: 518.293
34MB 32thread base -> kops/s: 3.528 io_bytes/op: 1.35722e+07 miss_ratio: 0.914691 max_rss_mb: 264.926
34MB 32thread new -> kops/s: 3.604 io_bytes/op: 1.35744e+07 miss_ratio: 0.915054 max_rss_mb: 264.488
233MB 1thread base.hyper -> kops/s: 53.909 io_bytes/op: 2552.35 miss_ratio: 0.0440566 max_rss_mb: 241.984
233MB 1thread new.hyper -> kops/s: 62.792 io_bytes/op: 2549.79 miss_ratio: 0.044043 max_rss_mb: 241.922
233MB 1thread base -> kops/s: 1.197 io_bytes/op: 2.75173e+06 miss_ratio: 0.103093 max_rss_mb: 241.559
233MB 1thread new -> kops/s: 1.199 io_bytes/op: 2.73723e+06 miss_ratio: 0.10305 max_rss_mb: 240.93
233MB 32thread base.hyper -> kops/s: 1298.69 io_bytes/op: 2539.12 miss_ratio: 0.0440307 max_rss_mb: 371.418
233MB 32thread new.hyper -> kops/s: 1421.35 io_bytes/op: 2538.75 miss_ratio: 0.0440307 max_rss_mb: 347.273
233MB 32thread base -> kops/s: 9.693 io_bytes/op: 2.77304e+06 miss_ratio: 0.103745 max_rss_mb: 569.691
233MB 32thread new -> kops/s: 9.75 io_bytes/op: 2.77559e+06 miss_ratio: 0.103798 max_rss_mb: 552.82
1597MB 1thread base.hyper -> kops/s: 58.607 io_bytes/op: 1449.14 miss_ratio: 0.0249324 max_rss_mb: 1583.55
1597MB 1thread new.hyper -> kops/s: 69.6 io_bytes/op: 1434.89 miss_ratio: 0.0247167 max_rss_mb: 1584.02
1597MB 1thread base -> kops/s: 60.478 io_bytes/op: 1421.28 miss_ratio: 0.024452 max_rss_mb: 1589.45
1597MB 1thread new -> kops/s: 63.973 io_bytes/op: 1416.07 miss_ratio: 0.0243766 max_rss_mb: 1589.24
1597MB 32thread base.hyper -> kops/s: 1436.2 io_bytes/op: 1357.93 miss_ratio: 0.0235353 max_rss_mb: 1692.92
1597MB 32thread new.hyper -> kops/s: 1605.03 io_bytes/op: 1358.04 miss_ratio: 0.023538 max_rss_mb: 1702.78
1597MB 32thread base -> kops/s: 280.059 io_bytes/op: 1350.34 miss_ratio: 0.023289 max_rss_mb: 1675.36
1597MB 32thread new -> kops/s: 283.125 io_bytes/op: 1351.05 miss_ratio: 0.0232797 max_rss_mb: 1703.83
Almost uniformly improving over base revision, especially for hot paths with HyperClockCache, up to 12% higher throughput seen (1597MB, 32thread, hyper). The improvement for that is likely coming from much simplified code for providing context for secondary cache promotion (CreateCallback/CreateContext), and possibly from less branching in block_based_table_reader. And likely a small improvement from not reconstituting key for DeleterFn.
Reviewed By: anand1976
Differential Revision: D42417818
Pulled By: pdillinger
fbshipit-source-id: f86bfdd584dce27c028b151ba56818ad14f7a432
2023-01-11 22:20:40 +00:00
|
|
|
table/block_based/block_cache.cc
|
De-template block based table iterator (#6531)
Summary:
Right now block based table iterator is used as both of iterating data for block based table, and for the index iterator for partitioend index. This was initially convenient for introducing a new iterator and block type for new index format, while reducing code change. However, these two usage doesn't go with each other very well. For example, Prev() is never called for partitioned index iterator, and some other complexity is maintained in block based iterators, which is not needed for index iterator but maintainers will always need to reason about it. Furthermore, the template usage is not following Google C++ Style which we are following, and makes a large chunk of code tangled together. This commit separate the two iterators. Right now, here is what it is done:
1. Copy the block based iterator code into partitioned index iterator, and de-template them.
2. Remove some code not needed for partitioned index. The upper bound check and tricks are removed. We never tested performance for those tricks when partitioned index is enabled in the first place. It's unlikelyl to generate performance regression, as creating new partitioned index block is much rarer than data blocks.
3. Separate out the prefetch logic to a helper class and both classes call them.
This commit will enable future follow-ups. One direction is that we might separate index iterator interface for data blocks and index blocks, as they are quite different.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6531
Test Plan: build using make and cmake. And build release
Differential Revision: D20473108
fbshipit-source-id: e48011783b339a4257c204cc07507b171b834b0f
2020-03-16 19:17:34 +00:00
|
|
|
table/block_based/block_prefetcher.cc
|
2019-05-30 21:47:29 +00:00
|
|
|
table/block_based/block_prefix_index.cc
|
|
|
|
table/block_based/data_block_hash_index.cc
|
|
|
|
table/block_based/data_block_footer.cc
|
Move the filter readers out of the block cache (#5504)
Summary:
Currently, when the block cache is used for the filter block, it is not
really the block itself that is stored in the cache but a FilterBlockReader
object. Since this object is not pure data (it has, for instance, pointers that
might dangle, including in one case a back pointer to the TableReader), it's not
really sharable. To avoid the issues around this, the current code erases the
cache entries when the TableReader is closed (which, BTW, is not sufficient
since a concurrent TableReader might have picked up the object in the meantime).
Instead of doing this, the patch moves the FilterBlockReader out of the cache
altogether, and decouples the filter reader object from the filter block.
In particular, instead of the TableReader owning, or caching/pinning the
FilterBlockReader (based on the customer's settings), with the change the
TableReader unconditionally owns the FilterBlockReader, which in turn
owns/caches/pins the filter block. This change also enables us to reuse the code
paths historically used for data blocks for filters as well.
Note:
Eviction statistics for filter blocks are temporarily broken. We plan to fix this in a
separate phase.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5504
Test Plan: make asan_check
Differential Revision: D16036974
Pulled By: ltamasi
fbshipit-source-id: 770f543c5fb4ed126fd1e04bfd3809cf4ff9c091
2019-07-16 20:11:23 +00:00
|
|
|
table/block_based/filter_block_reader_common.cc
|
2019-10-24 22:43:27 +00:00
|
|
|
table/block_based/filter_policy.cc
|
2019-05-30 21:47:29 +00:00
|
|
|
table/block_based/flush_block_policy.cc
|
|
|
|
table/block_based/full_filter_block.cc
|
2020-03-13 04:39:36 +00:00
|
|
|
table/block_based/hash_index_reader.cc
|
2019-05-30 21:47:29 +00:00
|
|
|
table/block_based/index_builder.cc
|
2020-03-13 04:39:36 +00:00
|
|
|
table/block_based/index_reader_common.cc
|
2019-10-19 02:30:47 +00:00
|
|
|
table/block_based/parsed_full_filter_block.cc
|
2019-05-30 21:47:29 +00:00
|
|
|
table/block_based/partitioned_filter_block.cc
|
De-template block based table iterator (#6531)
Summary:
Right now block based table iterator is used as both of iterating data for block based table, and for the index iterator for partitioend index. This was initially convenient for introducing a new iterator and block type for new index format, while reducing code change. However, these two usage doesn't go with each other very well. For example, Prev() is never called for partitioned index iterator, and some other complexity is maintained in block based iterators, which is not needed for index iterator but maintainers will always need to reason about it. Furthermore, the template usage is not following Google C++ Style which we are following, and makes a large chunk of code tangled together. This commit separate the two iterators. Right now, here is what it is done:
1. Copy the block based iterator code into partitioned index iterator, and de-template them.
2. Remove some code not needed for partitioned index. The upper bound check and tricks are removed. We never tested performance for those tricks when partitioned index is enabled in the first place. It's unlikelyl to generate performance regression, as creating new partitioned index block is much rarer than data blocks.
3. Separate out the prefetch logic to a helper class and both classes call them.
This commit will enable future follow-ups. One direction is that we might separate index iterator interface for data blocks and index blocks, as they are quite different.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6531
Test Plan: build using make and cmake. And build release
Differential Revision: D20473108
fbshipit-source-id: e48011783b339a4257c204cc07507b171b834b0f
2020-03-16 19:17:34 +00:00
|
|
|
table/block_based/partitioned_index_iterator.cc
|
2020-03-13 04:39:36 +00:00
|
|
|
table/block_based/partitioned_index_reader.cc
|
|
|
|
table/block_based/reader_common.cc
|
2019-07-23 22:57:43 +00:00
|
|
|
table/block_based/uncompression_dict_reader.cc
|
2017-12-11 23:16:37 +00:00
|
|
|
table/block_fetcher.cc
|
2019-05-30 21:47:29 +00:00
|
|
|
table/cuckoo/cuckoo_table_builder.cc
|
|
|
|
table/cuckoo/cuckoo_table_factory.cc
|
|
|
|
table/cuckoo/cuckoo_table_reader.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
table/format.cc
|
|
|
|
table/get_context.cc
|
|
|
|
table/iterator.cc
|
2017-02-03 00:38:40 +00:00
|
|
|
table/merging_iterator.cc
|
2023-02-22 20:28:18 +00:00
|
|
|
table/compaction_merging_iterator.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
table/meta_blocks.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
table/persistent_cache_helper.cc
|
2019-09-05 17:03:42 +00:00
|
|
|
table/plain/plain_table_bloom.cc
|
2019-05-30 21:47:29 +00:00
|
|
|
table/plain/plain_table_builder.cc
|
|
|
|
table/plain/plain_table_factory.cc
|
|
|
|
table/plain/plain_table_index.cc
|
|
|
|
table/plain/plain_table_key_coding.cc
|
|
|
|
table/plain/plain_table_reader.cc
|
2020-06-25 02:30:15 +00:00
|
|
|
table/sst_file_dumper.cc
|
2018-11-27 20:59:27 +00:00
|
|
|
table/sst_file_reader.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
table/sst_file_writer.cc
|
2020-09-14 23:59:00 +00:00
|
|
|
table/table_factory.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
table/table_properties.cc
|
|
|
|
table/two_level_iterator.cc
|
Experimental support for SST unique IDs (#8990)
Summary:
* New public header unique_id.h and function GetUniqueIdFromTableProperties
which computes a universally unique identifier based on table properties
of table files from recent RocksDB versions.
* Generation of DB session IDs is refactored so that they are
guaranteed unique in the lifetime of a process running RocksDB.
(SemiStructuredUniqueIdGen, new test included.) Along with file numbers,
this enables SST unique IDs to be guaranteed unique among SSTs generated
in a single process, and "better than random" between processes.
See https://github.com/pdillinger/unique_id
* In addition to public API producing 'external' unique IDs, there is a function
for producing 'internal' unique IDs, with functions for converting between the
two. In short, the external ID is "safe" for things people might do with it, and
the internal ID enables more "power user" features for the future. Specifically,
the external ID goes through a hashing layer so that any subset of bits in the
external ID can be used as a hash of the full ID, while also preserving
uniqueness guarantees in the first 128 bits (bijective both on first 128 bits
and on full 192 bits).
Intended follow-up:
* Use the internal unique IDs in cache keys. (Avoid conflicts with https://github.com/facebook/rocksdb/issues/8912) (The file offset can be XORed into
the third 64-bit value of the unique ID.)
* Publish the external unique IDs in FileStorageInfo (https://github.com/facebook/rocksdb/issues/8968)
Pull Request resolved: https://github.com/facebook/rocksdb/pull/8990
Test Plan:
Unit tests added, and checking of unique ids in stress test.
NOTE in stress test we do not generate nearly enough files to thoroughly
stress uniqueness, but the test trims off pieces of the ID to check for
uniqueness so that we can infer (with some assumptions) stronger
properties in the aggregate.
Reviewed By: zhichao-cao, mrambacher
Differential Revision: D31582865
Pulled By: pdillinger
fbshipit-source-id: 1f620c4c86af9abe2a8d177b9ccf2ad2b9f48243
2021-10-19 06:28:28 +00:00
|
|
|
table/unique_id.cc
|
2019-05-30 18:21:38 +00:00
|
|
|
test_util/sync_point.cc
|
|
|
|
test_util/sync_point_impl.cc
|
|
|
|
test_util/testutil.cc
|
|
|
|
test_util/transaction_test_util.cc
|
Block cache simulator: Add pysim to simulate caches using reinforcement learning. (#5610)
Summary:
This PR implements cache eviction using reinforcement learning. It includes two implementations:
1. An implementation of Thompson Sampling for the Bernoulli Bandit [1].
2. An implementation of LinUCB with disjoint linear models [2].
The idea is that a cache uses multiple eviction policies, e.g., MRU, LRU, and LFU. The cache learns which eviction policy is the best and uses it upon a cache miss.
Thompson Sampling is contextless and does not include any features.
LinUCB includes features such as level, block type, caller, column family id to decide which eviction policy to use.
[1] Daniel J. Russo, Benjamin Van Roy, Abbas Kazerouni, Ian Osband, and Zheng Wen. 2018. A Tutorial on Thompson Sampling. Found. Trends Mach. Learn. 11, 1 (July 2018), 1-96. DOI: https://doi.org/10.1561/2200000070
[2] Lihong Li, Wei Chu, John Langford, and Robert E. Schapire. 2010. A contextual-bandit approach to personalized news article recommendation. In Proceedings of the 19th international conference on World wide web (WWW '10). ACM, New York, NY, USA, 661-670. DOI=http://dx.doi.org/10.1145/1772690.1772758
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5610
Differential Revision: D16435067
Pulled By: HaoyuHuang
fbshipit-source-id: 6549239ae14115c01cb1e70548af9e46d8dc21bb
2019-07-26 21:36:16 +00:00
|
|
|
tools/block_cache_analyzer/block_cache_trace_analyzer.cc
|
2015-10-06 22:52:09 +00:00
|
|
|
tools/dump/db_dump_tool.cc
|
2020-09-23 22:49:11 +00:00
|
|
|
tools/io_tracer_parser_tool.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
tools/ldb_cmd.cc
|
|
|
|
tools/ldb_tool.cc
|
|
|
|
tools/sst_dump_tool.cc
|
RocksDB Trace Analyzer (#4091)
Summary:
A framework of trace analyzing for RocksDB
After collecting the trace by using the tool of [PR #3837](https://github.com/facebook/rocksdb/pull/3837). User can use the Trace Analyzer to interpret, analyze, and characterize the collected workload.
**Input:**
1. trace file
2. Whole keys space file
**Statistics:**
1. Access count of each operation (Get, Put, Delete, SingleDelete, DeleteRange, Merge) in each column family.
2. Key hotness (access count) of each one
3. Key space separation based on given prefix
4. Key size distribution
5. Value size distribution if appliable
6. Top K accessed keys
7. QPS statistics including the average QPS and peak QPS
8. Top K accessed prefix
9. The query correlation analyzing, output the number of X after Y and the corresponding average time
intervals
**Output:**
1. key access heat map (either in the accessed key space or whole key space)
2. trace sequence file (interpret the raw trace file to line base text file for future use)
3. Time serial (The key space ID and its access time)
4. Key access count distritbution
5. Key size distribution
6. Value size distribution (in each intervals)
7. whole key space separation by the prefix
8. Accessed key space separation by the prefix
9. QPS of each operation and each column family
10. Top K QPS and their accessed prefix range
**Test:**
1. Added the unit test of analyzing Get, Put, Delete, SingleDelete, DeleteRange, Merge
2. Generated the trace and analyze the trace
**Implemented but not tested (due to the limitation of trace_replay):**
1. Analyzing Iterator, supporting Seek() and SeekForPrev() analyzing
2. Analyzing the number of Key found by Get
**Future Work:**
1. Support execution time analyzing of each requests
2. Support cache hit situation and block read situation of Get
Pull Request resolved: https://github.com/facebook/rocksdb/pull/4091
Differential Revision: D9256157
Pulled By: zhichao-cao
fbshipit-source-id: f0ceacb7eedbc43a3eee6e85b76087d7832a8fe6
2018-08-13 18:32:04 +00:00
|
|
|
tools/trace_analyzer_tool.cc
|
2019-06-06 18:21:11 +00:00
|
|
|
trace_replay/block_cache_tracer.cc
|
2020-08-05 01:40:19 +00:00
|
|
|
trace_replay/io_tracer.cc
|
2021-08-12 02:31:44 +00:00
|
|
|
trace_replay/trace_record_handler.cc
|
2021-08-19 00:04:36 +00:00
|
|
|
trace_replay/trace_record_result.cc
|
2021-08-12 02:31:44 +00:00
|
|
|
trace_replay/trace_record.cc
|
|
|
|
trace_replay/trace_replay.cc
|
Multi file concurrency in MultiGet using coroutines and async IO (#9968)
Summary:
This PR implements a coroutine version of batched MultiGet in order to concurrently read from multiple SST files in a level using async IO, thus reducing the latency of the MultiGet. The API from the user perspective is still synchronous and single threaded, with the RocksDB part of the processing happening in the context of the caller's thread. In Version::MultiGet, the decision is made whether to call synchronous or coroutine code.
A good way to review this PR is to review the first 4 commits in order - de773b3, 70c2f70, 10b50e1, and 377a597 - before reviewing the rest.
TODO:
1. Figure out how to build it in CircleCI (requires some dependencies to be installed)
2. Do some stress testing with coroutines enabled
No regression in synchronous MultiGet between this branch and main -
```
./db_bench -use_existing_db=true --db=/data/mysql/rocksdb/prefix_scan -benchmarks="readseq,multireadrandom" -key_size=32 -value_size=512 -num=5000000 -batch_size=64 -multiread_batched=true -use_direct_reads=false -duration=60 -ops_between_duration_checks=1 -readonly=true -adaptive_readahead=true -threads=16 -cache_size=10485760000 -async_io=false -multiread_stride=40000 -statistics
```
Branch - ```multireadrandom : 4.025 micros/op 3975111 ops/sec 60.001 seconds 238509056 operations; 2062.3 MB/s (14767808 of 14767808 found)```
Main - ```multireadrandom : 3.987 micros/op 4013216 ops/sec 60.001 seconds 240795392 operations; 2082.1 MB/s (15231040 of 15231040 found)```
More benchmarks in various scenarios are given below. The measurements were taken with ```async_io=false``` (no coroutines) and ```async_io=true``` (use coroutines). For an IO bound workload (with every key requiring an IO), the coroutines version shows a clear benefit, being ~2.6X faster. For CPU bound workloads, the coroutines version has ~6-15% higher CPU utilization, depending on how many keys overlap an SST file.
1. Single thread IO bound workload on remote storage with sparse MultiGet batch keys (~1 key overlap/file) -
No coroutines - ```multireadrandom : 831.774 micros/op 1202 ops/sec 60.001 seconds 72136 operations; 0.6 MB/s (72136 of 72136 found)```
Using coroutines - ```multireadrandom : 318.742 micros/op 3137 ops/sec 60.003 seconds 188248 operations; 1.6 MB/s (188248 of 188248 found)```
2. Single thread CPU bound workload (all data cached) with ~1 key overlap/file -
No coroutines - ```multireadrandom : 4.127 micros/op 242322 ops/sec 60.000 seconds 14539384 operations; 125.7 MB/s (14539384 of 14539384 found)```
Using coroutines - ```multireadrandom : 4.741 micros/op 210935 ops/sec 60.000 seconds 12656176 operations; 109.4 MB/s (12656176 of 12656176 found)```
3. Single thread CPU bound workload with ~2 key overlap/file -
No coroutines - ```multireadrandom : 3.717 micros/op 269000 ops/sec 60.000 seconds 16140024 operations; 139.6 MB/s (16140024 of 16140024 found)```
Using coroutines - ```multireadrandom : 4.146 micros/op 241204 ops/sec 60.000 seconds 14472296 operations; 125.1 MB/s (14472296 of 14472296 found)```
4. CPU bound multi-threaded (16 threads) with ~4 key overlap/file -
No coroutines - ```multireadrandom : 4.534 micros/op 3528792 ops/sec 60.000 seconds 211728728 operations; 1830.7 MB/s (12737024 of 12737024 found) ```
Using coroutines - ```multireadrandom : 4.872 micros/op 3283812 ops/sec 60.000 seconds 197030096 operations; 1703.6 MB/s (12548032 of 12548032 found) ```
Pull Request resolved: https://github.com/facebook/rocksdb/pull/9968
Reviewed By: akankshamahajan15
Differential Revision: D36348563
Pulled By: anand1976
fbshipit-source-id: c0ce85a505fd26ebfbb09786cbd7f25202038696
2022-05-19 22:36:27 +00:00
|
|
|
util/async_file_reader.cc
|
Eliminate unnecessary (slow) block cache Ref()ing in MultiGet (#9899)
Summary:
When MultiGet() determines that multiple query keys can be
served by examining the same data block in block cache (one Lookup()),
each PinnableSlice referring to data in that data block needs to hold
on to the block in cache so that they can be released at arbitrary
times by the API user. Historically this is accomplished with extra
calls to Ref() on the Handle from Lookup(), with each PinnableSlice
cleanup calling Release() on the Handle, but this creates extra
contention on the block cache for the extra Ref()s and Release()es,
especially because they hit the same cache shard repeatedly.
In the case of merge operands (possibly more cases?), the problem was
compounded by doing an extra Ref()+eventual Release() for each merge
operand for a key reusing a block (which could be the same key!), rather
than one Ref() per key. (Note: the non-shared case with `biter` was
already one per key.)
This change optimizes MultiGet not to rely on these extra, contentious
Ref()+Release() calls by instead, in the shared block case, wrapping
the cache Release() cleanup in a refcounted object referenced by the
PinnableSlices, such that after the last wrapped reference is released,
the cache entry is Release()ed. Relaxed atomic refcounts should be
much faster than mutex-guarded Ref() and Release(), and much less prone
to a performance cliff when MultiGet() does a lot of block sharing.
Note that I did not use std::shared_ptr, because that would require an
extra indirection object (shared_ptr itself new/delete) in order to
associate a ref increment/decrement with a Cleanable cleanup entry. (If
I assumed it was the size of two pointers, I could do some hackery to
make it work without the extra indirection, but that's too fragile.)
Some details:
* Fixed (removed) extra block cache tracing entries in cases of cache
entry reuse in MultiGet, but it's likely that in some other cases traces
are missing (XXX comment inserted)
* Moved existing implementations for cleanable.h from iterator.cc to
new cleanable.cc
* Improved API comments on Cleanable
* Added a public SharedCleanablePtr class to cleanable.h in case others
could benefit from the same pattern (potentially many Cleanables and/or
smart pointers referencing a shared Cleanable)
* Add a typedef for MultiGetContext::Mask
* Some variable renaming for clarity
Pull Request resolved: https://github.com/facebook/rocksdb/pull/9899
Test Plan:
Added unit tests for SharedCleanablePtr.
Greatly enhanced ability of existing tests to detect cache use-after-free.
* Release PinnableSlices from MultiGet as they are read rather than in
bulk (in db_test_util wrapper).
* In ASAN build, default to using a trivially small LRUCache for block_cache
so that entries are immediately erased when unreferenced. (Updated two
tests that depend on caching.) New ASAN testsuite running time seems
OK to me.
If I introduce a bug into my implementation where we skip the shared
cleanups on block reuse, ASAN detects the bug in
`db_basic_test *MultiGet*`. If I remove either of the above testing
enhancements, the bug is not detected.
Consider for follow-up work: manipulate or randomize ordering of
PinnableSlice use and release from MultiGet db_test_util wrapper. But in
typical cases, natural ordering gives pretty good functional coverage.
Performance test:
In the extreme (but possible) case of MultiGetting the same or adjacent keys
in a batch, throughput can improve by an order of magnitude.
`./db_bench -benchmarks=multireadrandom -db=/dev/shm/testdb -readonly -num=5 -duration=10 -threads=20 -multiread_batched -batch_size=200`
Before ops/sec, num=5: 1,384,394
Before ops/sec, num=500: 6,423,720
After ops/sec, num=500: 10,658,794
After ops/sec, num=5: 16,027,257
Also note that previously, with high parallelism, having query keys
concentrated in a single block was worse than spreading them out a bit. Now
concentrated in a single block is faster than spread out, which is hopefully
consistent with natural expectation.
Random query performance: with num=1000000, over 999 x 10s runs running before & after simultaneously (each -threads=12):
Before: multireadrandom [AVG 999 runs] : 1088699 (± 7344) ops/sec; 120.4 (± 0.8 ) MB/sec
After: multireadrandom [AVG 999 runs] : 1090402 (± 7230) ops/sec; 120.6 (± 0.8 ) MB/sec
Possibly better, possibly in the noise.
Reviewed By: anand1976
Differential Revision: D35907003
Pulled By: pdillinger
fbshipit-source-id: bbd244d703649a8ca12d476f2d03853ed9d1a17e
2022-04-27 04:59:24 +00:00
|
|
|
util/cleanable.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
util/coding.cc
|
|
|
|
util/compaction_job_stats_impl.cc
|
|
|
|
util/comparator.cc
|
2022-02-24 07:45:04 +00:00
|
|
|
util/compression.cc
|
2018-06-04 19:04:52 +00:00
|
|
|
util/compression_context_cache.cc
|
Concurrent task limiter for compaction thread control (#4332)
Summary:
The PR is targeting to resolve the issue of:
https://github.com/facebook/rocksdb/issues/3972#issue-330771918
We have a rocksdb created with leveled-compaction with multiple column families (CFs), some of CFs are using HDD to store big and less frequently accessed data and others are using SSD.
When there are continuously write traffics going on to all CFs, the compaction thread pool is mostly occupied by those slow HDD compactions, which blocks fully utilize SSD bandwidth.
Since atomic write and transaction is needed across CFs, so splitting it to multiple rocksdb instance is not an option for us.
With the compaction thread control, we got 30%+ HDD write throughput gain, and also a lot smooth SSD write since less write stall happening.
ConcurrentTaskLimiter can be shared with multi-CFs across rocksdb instances, so the feature does not only work for multi-CFs scenarios, but also for multi-rocksdbs scenarios, who need disk IO resource control per tenant.
The usage is straight forward:
e.g.:
//
// Enable compaction thread limiter thru ColumnFamilyOptions
//
std::shared_ptr<ConcurrentTaskLimiter> ctl(NewConcurrentTaskLimiter("foo_limiter", 4));
Options options;
ColumnFamilyOptions cf_opt(options);
cf_opt.compaction_thread_limiter = ctl;
...
//
// Compaction thread limiter can be tuned or disabled on-the-fly
//
ctl->SetMaxOutstandingTask(12); // enlarge to 12 tasks
...
ctl->ResetMaxOutstandingTask(); // disable (bypass) thread limiter
ctl->SetMaxOutstandingTask(-1); // Same as above
...
ctl->SetMaxOutstandingTask(0); // full throttle (0 task)
//
// Sharing compaction thread limiter among CFs (to resolve multiple storage perf issue)
//
std::shared_ptr<ConcurrentTaskLimiter> ctl_ssd(NewConcurrentTaskLimiter("ssd_limiter", 8));
std::shared_ptr<ConcurrentTaskLimiter> ctl_hdd(NewConcurrentTaskLimiter("hdd_limiter", 4));
Options options;
ColumnFamilyOptions cf_opt_ssd1(options);
ColumnFamilyOptions cf_opt_ssd2(options);
ColumnFamilyOptions cf_opt_hdd1(options);
ColumnFamilyOptions cf_opt_hdd2(options);
ColumnFamilyOptions cf_opt_hdd3(options);
// SSD CFs
cf_opt_ssd1.compaction_thread_limiter = ctl_ssd;
cf_opt_ssd2.compaction_thread_limiter = ctl_ssd;
// HDD CFs
cf_opt_hdd1.compaction_thread_limiter = ctl_hdd;
cf_opt_hdd2.compaction_thread_limiter = ctl_hdd;
cf_opt_hdd3.compaction_thread_limiter = ctl_hdd;
...
//
// The limiter is disabled by default (or set to nullptr explicitly)
//
Options options;
ColumnFamilyOptions cf_opt(options);
cf_opt.compaction_thread_limiter = nullptr;
Pull Request resolved: https://github.com/facebook/rocksdb/pull/4332
Differential Revision: D13226590
Pulled By: siying
fbshipit-source-id: 14307aec55b8bd59c8223d04aa6db3c03d1b0c1d
2018-12-13 21:16:04 +00:00
|
|
|
util/concurrent_task_limiter_impl.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
util/crc32c.cc
|
2023-02-09 04:14:57 +00:00
|
|
|
util/data_structure.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
util/dynamic_bloom.cc
|
|
|
|
util/hash.cc
|
|
|
|
util/murmurhash.cc
|
2015-11-06 16:07:08 +00:00
|
|
|
util/random.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
util/rate_limiter.cc
|
Refine Ribbon configuration, improve testing, add Homogeneous (#7879)
Summary:
This change only affects non-schema-critical aspects of the production candidate Ribbon filter. Specifically, it refines choice of internal configuration parameters based on inputs. The changes are minor enough that the schema tests in bloom_test, some of which depend on this, are unaffected. There are also some minor optimizations and refactorings.
This would be a schema change for "smash" Ribbon, to fix some known issues with small filters, but "smash" Ribbon is not accessible in public APIs. Unit test CompactnessAndBacktrackAndFpRate updated to test small and medium-large filters. Run with --thoroughness=100 or so for much better detection power (not appropriate for continuous regression testing).
Homogenous Ribbon:
This change adds internally a Ribbon filter variant we call Homogeneous Ribbon, in collaboration with Stefan Walzer. The expected "result" value for every key is zero, instead of computed from a hash. Entropy for queries not to be false positives comes from free variables ("overhead") in the solution structure, which are populated pseudorandomly. Construction is slightly faster for not tracking result values, and never fails. Instead, FP rate can jump up whenever and whereever entries are packed too tightly. For small structures, we can choose overhead to make this FP rate jump unlikely, as seen in updated unit test CompactnessAndBacktrackAndFpRate.
Unlike standard Ribbon, Homogeneous Ribbon seems to scale to arbitrary number of keys when accepting an FP rate penalty for small pockets of high FP rate in the structure. For example, 64-bit ribbon with 8 solution columns and 10% allocated space overhead for slots seems to achieve about 10.5% space overhead vs. information-theoretic minimum based on its observed FP rate with expected pockets of degradation. (FP rate is close to 1/256.) If targeting a higher FP rate with fewer solution columns, Homogeneous Ribbon can be even more space efficient, because the penalty from degradation is relatively smaller. If targeting a lower FP rate, Homogeneous Ribbon is less space efficient, as more allocated overhead is needed to keep the FP rate impact of degradation relatively under control. The new OptimizeHomogAtScale tool in ribbon_test helps to find these optimal allocation overheads for different numbers of solution columns. And Ribbon widths, with 128-bit Ribbon apparently cutting space overheads in half vs. 64-bit.
Other misc item specifics:
* Ribbon APIs in util/ribbon_config.h now provide configuration data for not just 5% construction failure rate (95% success), but also 50% and 0.1%.
* Note that the Ribbon structure does not exhibit "threshold" behavior as standard Xor filter does, so there is a roughly fixed space penalty to cut construction failure rate in half. Thus, there isn't really an "almost sure" setting.
* Although we can extrapolate settings for large filters, we don't have a good formula for configuring smaller filters (< 2^17 slots or so), and efforts to summarize with a formula have failed. Thus, small data is hard-coded from updated FindOccupancy tool.
* Enhances ApproximateNumEntries for public API Ribbon using more precise data (new API GetNumToAdd), thus a more accurate but not perfect reversal of CalculateSpace. (bloom_test updated to expect the greater precision)
* Move EndianSwapValue from coding.h to coding_lean.h to keep Ribbon code easily transferable from RocksDB
* Add some missing 'const' to member functions
* Small optimization to 128-bit BitParity
* Small refactoring of BandingStorage in ribbon_alg.h to support Homogeneous Ribbon
* CompactnessAndBacktrackAndFpRate now has an "expand" test: on construction failure, a possible alternative to re-seeding hash functions is simply to increase the number of slots (allocated space overhead) and try again with essentially the same hash values. (Start locations will be different roundings of the same scaled hash values--because fastrange not mod.) This seems to be as effective or more effective than re-seeding, as long as we increase the number of slots (m) by roughly m += m/w where w is the Ribbon width. This way, there is effectively an expansion by one slot for each ribbon-width window in the banding. (This approach assumes that getting "bad data" from your hash function is as unlikely as it naturally should be, e.g. no adversary.)
* 32-bit and 16-bit Ribbon configurations are added to ribbon_test for understanding their behavior, e.g. with FindOccupancy. They are not considered useful at this time and not tested with CompactnessAndBacktrackAndFpRate.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/7879
Test Plan: unit test updates included
Reviewed By: jay-zhuang
Differential Revision: D26371245
Pulled By: pdillinger
fbshipit-source-id: da6600d90a3785b99ad17a88b2a3027710b4ea3a
2021-02-26 16:48:55 +00:00
|
|
|
util/ribbon_config.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
util/slice.cc
|
2020-02-10 23:42:46 +00:00
|
|
|
util/file_checksum_helper.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
util/status.cc
|
2022-08-30 04:09:36 +00:00
|
|
|
util/stderr_logger.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
util/string_util.cc
|
|
|
|
util/thread_local.cc
|
2016-08-26 17:41:35 +00:00
|
|
|
util/threadpool_imp.cc
|
2023-05-22 21:28:58 +00:00
|
|
|
util/udt_util.cc
|
|
|
|
util/write_batch_util.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
util/xxhash.cc
|
2022-04-16 06:24:05 +00:00
|
|
|
utilities/agg_merge/agg_merge.cc
|
2022-04-05 16:52:33 +00:00
|
|
|
utilities/backup/backup_engine.cc
|
2018-03-06 19:46:20 +00:00
|
|
|
utilities/blob_db/blob_compaction_filter.cc
|
2016-08-09 17:16:32 +00:00
|
|
|
utilities/blob_db/blob_db.cc
|
2017-05-10 21:54:35 +00:00
|
|
|
utilities/blob_db/blob_db_impl.cc
|
2018-08-27 17:56:28 +00:00
|
|
|
utilities/blob_db/blob_db_impl_filesnapshot.cc
|
2017-05-31 05:16:32 +00:00
|
|
|
utilities/blob_db/blob_dump_tool.cc
|
2017-05-11 16:43:59 +00:00
|
|
|
utilities/blob_db/blob_file.cc
|
2021-10-07 18:40:20 +00:00
|
|
|
utilities/cache_dump_load.cc
|
|
|
|
utilities/cache_dump_load_impl.cc
|
2017-07-21 21:42:32 +00:00
|
|
|
utilities/cassandra/cassandra_compaction_filter.cc
|
|
|
|
utilities/cassandra/format.cc
|
|
|
|
utilities/cassandra/merge_operator.cc
|
2017-04-24 21:57:27 +00:00
|
|
|
utilities/checkpoint/checkpoint_impl.cc
|
2021-08-06 15:26:23 +00:00
|
|
|
utilities/compaction_filters.cc
|
2016-01-28 14:44:31 +00:00
|
|
|
utilities/compaction_filters/remove_emptyvalue_compactionfilter.cc
|
2022-02-03 23:00:03 +00:00
|
|
|
utilities/counted_fs.cc
|
2017-05-12 21:59:57 +00:00
|
|
|
utilities/debug.cc
|
2015-11-19 19:47:12 +00:00
|
|
|
utilities/env_mirror.cc
|
2017-04-04 18:12:47 +00:00
|
|
|
utilities/env_timed.cc
|
2020-07-09 21:33:42 +00:00
|
|
|
utilities/fault_injection_env.cc
|
|
|
|
utilities/fault_injection_fs.cc
|
2021-11-08 18:26:48 +00:00
|
|
|
utilities/fault_injection_secondary_cache.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
utilities/leveldb_options/leveldb_options.cc
|
2015-11-04 01:52:17 +00:00
|
|
|
utilities/memory/memory_util.cc
|
2021-08-06 15:26:23 +00:00
|
|
|
utilities/merge_operators.cc
|
2018-03-06 18:20:52 +00:00
|
|
|
utilities/merge_operators/bytesxor.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
utilities/merge_operators/max.cc
|
|
|
|
utilities/merge_operators/put.cc
|
New API to get all merge operands for a Key (#5604)
Summary:
This is a new API added to db.h to allow for fetching all merge operands associated with a Key. The main motivation for this API is to support use cases where doing a full online merge is not necessary as it is performance sensitive. Example use-cases:
1. Update subset of columns and read subset of columns -
Imagine a SQL Table, a row is encoded as a K/V pair (as it is done in MyRocks). If there are many columns and users only updated one of them, we can use merge operator to reduce write amplification. While users only read one or two columns in the read query, this feature can avoid a full merging of the whole row, and save some CPU.
2. Updating very few attributes in a value which is a JSON-like document -
Updating one attribute can be done efficiently using merge operator, while reading back one attribute can be done more efficiently if we don't need to do a full merge.
----------------------------------------------------------------------------------------------------
API :
Status GetMergeOperands(
const ReadOptions& options, ColumnFamilyHandle* column_family,
const Slice& key, PinnableSlice* merge_operands,
GetMergeOperandsOptions* get_merge_operands_options,
int* number_of_operands)
Example usage :
int size = 100;
int number_of_operands = 0;
std::vector<PinnableSlice> values(size);
GetMergeOperandsOptions merge_operands_info;
db_->GetMergeOperands(ReadOptions(), db_->DefaultColumnFamily(), "k1", values.data(), merge_operands_info, &number_of_operands);
Description :
Returns all the merge operands corresponding to the key. If the number of merge operands in DB is greater than merge_operands_options.expected_max_number_of_operands no merge operands are returned and status is Incomplete. Merge operands returned are in the order of insertion.
merge_operands-> Points to an array of at-least merge_operands_options.expected_max_number_of_operands and the caller is responsible for allocating it. If the status returned is Incomplete then number_of_operands will contain the total number of merge operands found in DB for key.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5604
Test Plan:
Added unit test and perf test in db_bench that can be run using the command:
./db_bench -benchmarks=getmergeoperands --merge_operator=sortlist
Differential Revision: D16657366
Pulled By: vjnadimpalli
fbshipit-source-id: 0faadd752351745224ee12d4ae9ef3cb529951bf
2019-08-06 21:22:34 +00:00
|
|
|
utilities/merge_operators/sortlist.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
utilities/merge_operators/string_append/stringappend.cc
|
|
|
|
utilities/merge_operators/string_append/stringappend2.cc
|
|
|
|
utilities/merge_operators/uint64add.cc
|
2019-07-24 00:08:26 +00:00
|
|
|
utilities/object_registry.cc
|
2016-07-14 04:08:15 +00:00
|
|
|
utilities/option_change_migration/option_change_migration.cc
|
Add OptionsUtil::LoadOptionsFromFile() API
Summary:
This patch adds OptionsUtil::LoadOptionsFromFile() and
OptionsUtil::LoadLatestOptionsFromDB(), which allow developers
to construct DBOptions and ColumnFamilyOptions from a RocksDB
options file. Note that most pointer-typed options such as
merge_operator will not be constructed.
With this API, developers no longer need to remember all the
options in order to reopen an existing rocksdb instance like
the following:
DBOptions db_options;
std::vector<std::string> cf_names;
std::vector<ColumnFamilyOptions> cf_opts;
// Load primitive-typed options from an existing DB
OptionsUtil::LoadLatestOptionsFromDB(
dbname, &db_options, &cf_names, &cf_opts);
// Initialize necessary pointer-typed options
cf_opts[0].merge_operator.reset(new MyMergeOperator());
...
// Construct the vector of ColumnFamilyDescriptor
std::vector<ColumnFamilyDescriptor> cf_descs;
for (size_t i = 0; i < cf_opts.size(); ++i) {
cf_descs.emplace_back(cf_names[i], cf_opts[i]);
}
// Open the DB
DB* db = nullptr;
std::vector<ColumnFamilyHandle*> cf_handles;
auto s = DB::Open(db_options, dbname, cf_descs,
&handles, &db);
Test Plan:
Augment existing tests in column_family_test
options_test
db_test
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D49095
2015-11-12 14:52:43 +00:00
|
|
|
utilities/options/options_util.cc
|
2016-08-03 00:15:18 +00:00
|
|
|
utilities/persistent_cache/block_cache_tier.cc
|
|
|
|
utilities/persistent_cache/block_cache_tier_file.cc
|
|
|
|
utilities/persistent_cache/block_cache_tier_metadata.cc
|
2016-04-21 19:20:05 +00:00
|
|
|
utilities/persistent_cache/persistent_cache_tier.cc
|
2016-06-07 23:07:30 +00:00
|
|
|
utilities/persistent_cache/volatile_tier_impl.cc
|
2019-07-01 19:43:14 +00:00
|
|
|
utilities/simulator_cache/cache_simulator.cc
|
2016-06-30 01:44:22 +00:00
|
|
|
utilities/simulator_cache/sim_cache.cc
|
2015-08-04 03:42:55 +00:00
|
|
|
utilities/table_properties_collectors/compact_on_deletion_collector.cc
|
2018-08-01 07:14:43 +00:00
|
|
|
utilities/trace/file_trace_reader_writer.cc
|
2021-08-12 02:31:44 +00:00
|
|
|
utilities/trace/replayer_impl.cc
|
2020-10-19 17:12:53 +00:00
|
|
|
utilities/transactions/lock/lock_manager.cc
|
|
|
|
utilities/transactions/lock/point/point_lock_tracker.cc
|
|
|
|
utilities/transactions/lock/point/point_lock_manager.cc
|
2020-12-23 03:10:56 +00:00
|
|
|
utilities/transactions/lock/range/range_tree/range_tree_lock_manager.cc
|
|
|
|
utilities/transactions/lock/range/range_tree/range_tree_lock_tracker.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
utilities/transactions/optimistic_transaction_db_impl.cc
|
2017-08-07 23:07:40 +00:00
|
|
|
utilities/transactions/optimistic_transaction.cc
|
2017-10-06 17:26:38 +00:00
|
|
|
utilities/transactions/pessimistic_transaction.cc
|
2017-08-06 00:17:48 +00:00
|
|
|
utilities/transactions/pessimistic_transaction_db.cc
|
2017-10-06 17:26:38 +00:00
|
|
|
utilities/transactions/snapshot_checker.cc
|
|
|
|
utilities/transactions/transaction_base.cc
|
2015-09-08 19:36:48 +00:00
|
|
|
utilities/transactions/transaction_db_mutex_impl.cc
|
Pessimistic Transactions
Summary:
Initial implementation of Pessimistic Transactions. This diff contains the api changes discussed in D38913. This diff is pretty large, so let me know if people would prefer to meet up to discuss it.
MyRocks folks: please take a look at the API in include/rocksdb/utilities/transaction[_db].h and let me know if you have any issues.
Also, you'll notice a couple of TODOs in the implementation of RollbackToSavePoint(). After chatting with Siying, I'm going to send out a separate diff for an alternate implementation of this feature that implements the rollback inside of WriteBatch/WriteBatchWithIndex. We can then decide which route is preferable.
Next, I'm planning on doing some perf testing and then integrating this diff into MongoRocks for further testing.
Test Plan: Unit tests, db_bench parallel testing.
Reviewers: igor, rven, sdong, yhchiang, yoshinorim
Reviewed By: sdong
Subscribers: hermanlee4, maykov, spetrunia, leveldb, dhruba
Differential Revision: https://reviews.facebook.net/D40869
2015-05-26 00:37:33 +00:00
|
|
|
utilities/transactions/transaction_util.cc
|
2017-08-07 23:07:40 +00:00
|
|
|
utilities/transactions/write_prepared_txn.cc
|
2017-11-02 18:05:55 +00:00
|
|
|
utilities/transactions/write_prepared_txn_db.cc
|
2018-05-31 17:42:44 +00:00
|
|
|
utilities/transactions/write_unprepared_txn.cc
|
|
|
|
utilities/transactions/write_unprepared_txn_db.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
utilities/ttl/db_ttl_impl.cc
|
2021-09-28 12:30:32 +00:00
|
|
|
utilities/wal_filter.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
utilities/write_batch_with_index/write_batch_with_index.cc
|
2021-01-29 01:40:24 +00:00
|
|
|
utilities/write_batch_with_index/write_batch_with_index_internal.cc)
|
2016-09-28 18:53:15 +00:00
|
|
|
|
2020-12-23 03:10:56 +00:00
|
|
|
list(APPEND SOURCES
|
2020-12-09 20:09:46 +00:00
|
|
|
utilities/transactions/lock/range/range_tree/lib/locktree/concurrent_tree.cc
|
|
|
|
utilities/transactions/lock/range/range_tree/lib/locktree/keyrange.cc
|
|
|
|
utilities/transactions/lock/range/range_tree/lib/locktree/lock_request.cc
|
|
|
|
utilities/transactions/lock/range/range_tree/lib/locktree/locktree.cc
|
|
|
|
utilities/transactions/lock/range/range_tree/lib/locktree/manager.cc
|
|
|
|
utilities/transactions/lock/range/range_tree/lib/locktree/range_buffer.cc
|
|
|
|
utilities/transactions/lock/range/range_tree/lib/locktree/treenode.cc
|
|
|
|
utilities/transactions/lock/range/range_tree/lib/locktree/txnid_set.cc
|
|
|
|
utilities/transactions/lock/range/range_tree/lib/locktree/wfg.cc
|
|
|
|
utilities/transactions/lock/range/range_tree/lib/standalone_port.cc
|
|
|
|
utilities/transactions/lock/range/range_tree/lib/util/dbt.cc
|
|
|
|
utilities/transactions/lock/range/range_tree/lib/util/memarena.cc)
|
|
|
|
|
2021-12-01 01:15:53 +00:00
|
|
|
message(STATUS "ROCKSDB_PLUGINS: ${ROCKSDB_PLUGINS}")
|
|
|
|
if ( ROCKSDB_PLUGINS )
|
|
|
|
string(REPLACE " " ";" PLUGINS ${ROCKSDB_PLUGINS})
|
|
|
|
foreach (plugin ${PLUGINS})
|
|
|
|
add_subdirectory("plugin/${plugin}")
|
|
|
|
foreach (src ${${plugin}_SOURCES})
|
|
|
|
list(APPEND SOURCES plugin/${plugin}/${src})
|
|
|
|
set_source_files_properties(
|
|
|
|
plugin/${plugin}/${src}
|
|
|
|
PROPERTIES COMPILE_FLAGS "${${plugin}_COMPILE_FLAGS}")
|
|
|
|
endforeach()
|
2022-12-31 00:55:58 +00:00
|
|
|
foreach (test ${${plugin}_TESTS})
|
|
|
|
list(APPEND PLUGIN_TESTS plugin/${plugin}/${test})
|
|
|
|
set_source_files_properties(
|
|
|
|
plugin/${plugin}/${test}
|
|
|
|
PROPERTIES COMPILE_FLAGS "${${plugin}_COMPILE_FLAGS}")
|
|
|
|
endforeach()
|
2021-12-01 01:15:53 +00:00
|
|
|
foreach (path ${${plugin}_INCLUDE_PATHS})
|
|
|
|
include_directories(${path})
|
|
|
|
endforeach()
|
|
|
|
foreach (lib ${${plugin}_LIBS})
|
|
|
|
list(APPEND THIRDPARTY_LIBS ${lib})
|
|
|
|
endforeach()
|
|
|
|
foreach (link_path ${${plugin}_LINK_PATHS})
|
|
|
|
link_directories(AFTER ${link_path})
|
|
|
|
endforeach()
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${${plugin}_CMAKE_SHARED_LINKER_FLAGS}")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${${plugin}_CMAKE_EXE_LINKER_FLAGS}")
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2020-03-11 19:31:06 +00:00
|
|
|
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64")
|
2018-01-24 00:44:09 +00:00
|
|
|
list(APPEND SOURCES
|
|
|
|
util/crc32c_ppc.c
|
|
|
|
util/crc32c_ppc_asm.S)
|
2020-03-11 19:31:06 +00:00
|
|
|
endif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64")
|
2018-01-24 00:44:09 +00:00
|
|
|
|
2019-05-15 20:24:36 +00:00
|
|
|
if(HAS_ARMV8_CRC)
|
|
|
|
list(APPEND SOURCES
|
|
|
|
util/crc32c_arm64.cc)
|
|
|
|
endif(HAS_ARMV8_CRC)
|
|
|
|
|
2016-09-28 18:53:15 +00:00
|
|
|
if(WIN32)
|
|
|
|
list(APPEND SOURCES
|
|
|
|
port/win/io_win.cc
|
|
|
|
port/win/env_win.cc
|
|
|
|
port/win/env_default.cc
|
|
|
|
port/win/port_win.cc
|
2021-06-29 13:51:11 +00:00
|
|
|
port/win/win_logger.cc
|
|
|
|
port/win/win_thread.cc)
|
2018-05-01 20:38:36 +00:00
|
|
|
if(WITH_XPRESS)
|
|
|
|
list(APPEND SOURCES
|
2016-09-28 18:53:15 +00:00
|
|
|
port/win/xpress_win.cc)
|
2018-05-01 20:38:36 +00:00
|
|
|
endif()
|
2017-11-02 18:05:55 +00:00
|
|
|
|
2017-10-27 20:14:07 +00:00
|
|
|
if(WITH_JEMALLOC)
|
|
|
|
list(APPEND SOURCES
|
|
|
|
port/win/win_jemalloc.cc)
|
|
|
|
endif()
|
2017-11-02 18:05:55 +00:00
|
|
|
|
2016-09-28 18:53:15 +00:00
|
|
|
else()
|
|
|
|
list(APPEND SOURCES
|
|
|
|
port/port_posix.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
env/env_posix.cc
|
Introduce a new storage specific Env API (#5761)
Summary:
The current Env API encompasses both storage/file operations, as well as OS related operations. Most of the APIs return a Status, which does not have enough metadata about an error, such as whether its retry-able or not, scope (i.e fault domain) of the error etc., that may be required in order to properly handle a storage error. The file APIs also do not provide enough control over the IO SLA, such as timeout, prioritization, hinting about placement and redundancy etc.
This PR separates out the file/storage APIs from Env into a new FileSystem class. The APIs are updated to return an IOStatus with metadata about the error, as well as to take an IOOptions structure as input in order to allow more control over the IO.
The user can set both ```options.env``` and ```options.file_system``` to specify that RocksDB should use the former for OS related operations and the latter for storage operations. Internally, a ```CompositeEnvWrapper``` has been introduced that inherits from ```Env``` and redirects individual methods to either an ```Env``` implementation or the ```FileSystem``` as appropriate. When options are sanitized during ```DB::Open```, ```options.env``` is replaced with a newly allocated ```CompositeEnvWrapper``` instance if both env and file_system have been specified. This way, the rest of the RocksDB code can continue to function as before.
This PR also ports PosixEnv to the new API by splitting it into two - PosixEnv and PosixFileSystem. PosixEnv is defined as a sub-class of CompositeEnvWrapper, and threading/time functions are overridden with Posix specific implementations in order to avoid an extra level of indirection.
The ```CompositeEnvWrapper``` translates ```IOStatus``` return code to ```Status```, and sets the severity to ```kSoftError``` if the io_status is retryable. The error handling code in RocksDB can then recover the DB automatically.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5761
Differential Revision: D18868376
Pulled By: anand1976
fbshipit-source-id: 39efe18a162ea746fabac6360ff529baba48486f
2019-12-13 22:47:08 +00:00
|
|
|
env/fs_posix.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
env/io_posix.cc)
|
2016-09-28 18:53:15 +00:00
|
|
|
endif()
|
2015-07-01 23:13:49 +00:00
|
|
|
|
2022-09-12 04:40:11 +00:00
|
|
|
if(USE_FOLLY_LITE)
|
2019-08-07 21:29:35 +00:00
|
|
|
list(APPEND SOURCES
|
Meta-internal folly integration with F14FastMap (#9546)
Summary:
Especially after updating to C++17, I don't see a compelling case for
*requiring* any folly components in RocksDB. I was able to purge the existing
hard dependencies, and it can be quite difficult to strip out non-trivial components
from folly for use in RocksDB. (The prospect of doing that on F14 has changed
my mind on the best approach here.)
But this change creates an optional integration where we can plug in
components from folly at compile time, starting here with F14FastMap to replace
std::unordered_map when possible (probably no public APIs for example). I have
replaced the biggest CPU users of std::unordered_map with compile-time
pluggable UnorderedMap which will use F14FastMap when USE_FOLLY is set.
USE_FOLLY is always set in the Meta-internal buck build, and a simulation of
that is in the Makefile for public CI testing. A full folly build is not needed, but
checking out the full folly repo is much simpler for getting the dependency,
and anything else we might want to optionally integrate in the future.
Some picky details:
* I don't think the distributed mutex stuff is actually used, so it was easy to remove.
* I implemented an alternative to `folly::constexpr_log2` (which is much easier
in C++17 than C++11) so that I could pull out the hard dependencies on
`ConstexprMath.h`
* I had to add noexcept move constructors/operators to some types to make
F14's complainUnlessNothrowMoveAndDestroy check happy, and I added a
macro to make that easier in some common cases.
* Updated Meta-internal buck build to use folly F14Map (always)
No updates to HISTORY.md nor INSTALL.md as this is not (yet?) considered a
production integration for open source users.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/9546
Test Plan:
CircleCI tests updated so that a couple of them use folly.
Most internal unit & stress/crash tests updated to use Meta-internal latest folly.
(Note: they should probably use buck but they currently use Makefile.)
Example performance improvement: when filter partitions are pinned in cache,
they are tracked by PartitionedFilterBlockReader::filter_map_ and we can build
a test that exercises that heavily. Build DB with
```
TEST_TMPDIR=/dev/shm/rocksdb ./db_bench -benchmarks=fillrandom -num=10000000 -disable_wal=1 -write_buffer_size=30000000 -bloom_bits=16 -compaction_style=2 -fifo_compaction_max_table_files_size_mb=10000 -fifo_compaction_allow_compaction=0 -partition_index_and_filters
```
and test with (simultaneous runs with & without folly, ~20 times each to see
convergence)
```
TEST_TMPDIR=/dev/shm/rocksdb ./db_bench_folly -readonly -use_existing_db -benchmarks=readrandom -num=10000000 -bloom_bits=16 -compaction_style=2 -fifo_compaction_max_table_files_size_mb=10000 -fifo_compaction_allow_compaction=0 -partition_index_and_filters -duration=40 -pin_l0_filter_and_index_blocks_in_cache
```
Average ops/s no folly: 26229.2
Average ops/s with folly: 26853.3 (+2.4%)
Reviewed By: ajkr
Differential Revision: D34181736
Pulled By: pdillinger
fbshipit-source-id: ffa6ad5104c2880321d8a1aa7187e00ab0d02e94
2022-04-13 14:34:01 +00:00
|
|
|
third-party/folly/folly/container/detail/F14Table.cpp
|
2022-06-17 20:08:45 +00:00
|
|
|
third-party/folly/folly/detail/Futex.cpp
|
Meta-internal folly integration with F14FastMap (#9546)
Summary:
Especially after updating to C++17, I don't see a compelling case for
*requiring* any folly components in RocksDB. I was able to purge the existing
hard dependencies, and it can be quite difficult to strip out non-trivial components
from folly for use in RocksDB. (The prospect of doing that on F14 has changed
my mind on the best approach here.)
But this change creates an optional integration where we can plug in
components from folly at compile time, starting here with F14FastMap to replace
std::unordered_map when possible (probably no public APIs for example). I have
replaced the biggest CPU users of std::unordered_map with compile-time
pluggable UnorderedMap which will use F14FastMap when USE_FOLLY is set.
USE_FOLLY is always set in the Meta-internal buck build, and a simulation of
that is in the Makefile for public CI testing. A full folly build is not needed, but
checking out the full folly repo is much simpler for getting the dependency,
and anything else we might want to optionally integrate in the future.
Some picky details:
* I don't think the distributed mutex stuff is actually used, so it was easy to remove.
* I implemented an alternative to `folly::constexpr_log2` (which is much easier
in C++17 than C++11) so that I could pull out the hard dependencies on
`ConstexprMath.h`
* I had to add noexcept move constructors/operators to some types to make
F14's complainUnlessNothrowMoveAndDestroy check happy, and I added a
macro to make that easier in some common cases.
* Updated Meta-internal buck build to use folly F14Map (always)
No updates to HISTORY.md nor INSTALL.md as this is not (yet?) considered a
production integration for open source users.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/9546
Test Plan:
CircleCI tests updated so that a couple of them use folly.
Most internal unit & stress/crash tests updated to use Meta-internal latest folly.
(Note: they should probably use buck but they currently use Makefile.)
Example performance improvement: when filter partitions are pinned in cache,
they are tracked by PartitionedFilterBlockReader::filter_map_ and we can build
a test that exercises that heavily. Build DB with
```
TEST_TMPDIR=/dev/shm/rocksdb ./db_bench -benchmarks=fillrandom -num=10000000 -disable_wal=1 -write_buffer_size=30000000 -bloom_bits=16 -compaction_style=2 -fifo_compaction_max_table_files_size_mb=10000 -fifo_compaction_allow_compaction=0 -partition_index_and_filters
```
and test with (simultaneous runs with & without folly, ~20 times each to see
convergence)
```
TEST_TMPDIR=/dev/shm/rocksdb ./db_bench_folly -readonly -use_existing_db -benchmarks=readrandom -num=10000000 -bloom_bits=16 -compaction_style=2 -fifo_compaction_max_table_files_size_mb=10000 -fifo_compaction_allow_compaction=0 -partition_index_and_filters -duration=40 -pin_l0_filter_and_index_blocks_in_cache
```
Average ops/s no folly: 26229.2
Average ops/s with folly: 26853.3 (+2.4%)
Reviewed By: ajkr
Differential Revision: D34181736
Pulled By: pdillinger
fbshipit-source-id: ffa6ad5104c2880321d8a1aa7187e00ab0d02e94
2022-04-13 14:34:01 +00:00
|
|
|
third-party/folly/folly/lang/SafeAssert.cpp
|
|
|
|
third-party/folly/folly/lang/ToAscii.cpp
|
2022-06-17 20:08:45 +00:00
|
|
|
third-party/folly/folly/ScopeGuard.cpp
|
|
|
|
third-party/folly/folly/synchronization/AtomicNotification.cpp
|
|
|
|
third-party/folly/folly/synchronization/DistributedMutex.cpp
|
|
|
|
third-party/folly/folly/synchronization/ParkingLot.cpp)
|
2022-09-12 04:40:11 +00:00
|
|
|
include_directories(${PROJECT_SOURCE_DIR}/third-party/folly)
|
|
|
|
add_definitions(-DUSE_FOLLY -DFOLLY_NO_CONFIG)
|
|
|
|
list(APPEND THIRDPARTY_LIBS glog)
|
2019-08-07 21:29:35 +00:00
|
|
|
endif()
|
|
|
|
|
2017-05-05 23:09:24 +00:00
|
|
|
set(ROCKSDB_STATIC_LIB rocksdb${ARTIFACT_SUFFIX})
|
|
|
|
set(ROCKSDB_SHARED_LIB rocksdb-shared${ARTIFACT_SUFFIX})
|
2019-12-10 23:19:24 +00:00
|
|
|
|
2018-04-15 20:14:26 +00:00
|
|
|
|
2017-01-20 21:16:22 +00:00
|
|
|
if(WIN32)
|
2019-11-26 18:57:29 +00:00
|
|
|
set(SYSTEM_LIBS ${SYSTEM_LIBS} shlwapi.lib rpcrt4.lib)
|
2017-01-20 21:16:22 +00:00
|
|
|
else()
|
cross-platform compatibility improvements
Summary:
We've had a couple CockroachDB users fail to build RocksDB on exotic platforms, so I figured I'd try my hand at solving these issues upstream. The problems stem from a) `USE_SSE=1` being too aggressive about turning on SSE4.2, even on toolchains that don't support SSE4.2 and b) RocksDB attempting to detect support for thread-local storage based on OS, even though it can vary by compiler on the same OS.
See the individual commit messages for details. Regarding SSE support, this PR should change virtually nothing for non-CMake based builds. `make`, `PORTABLE=1 make`, `USE_SSE=1 make`, and `PORTABLE=1 USE_SSE=1 make` function exactly as before, except that SSE support will be automatically disabled when a simple SSE4.2-using test program fails to compile, as it does on OpenBSD. (OpenBSD's ports GCC supports SSE4.2, but its binutils do not, so `__SSE_4_2__` is defined but an SSE4.2-using program will fail to assemble.) A warning is emitted in this case. The CMake build is modified to support the same set of options, except that `USE_SSE` is spelled `FORCE_SSE42` because `USE_SSE` is rather useless now that we can automatically detect SSE support, and I figure changing options in the CMake build is less disruptive than changing the non-CMake build.
I've tested these changes on all the platforms I can get my hands on (macOS, Windows MSVC, Windows MinGW, and OpenBSD) and it all works splendidly. Let me know if there's anything you object to—I obviously don't mean to break any of your build pipelines in the process of fixing ours downstream.
Closes https://github.com/facebook/rocksdb/pull/2199
Differential Revision: D5054042
Pulled By: yiwu-arbug
fbshipit-source-id: 938e1fc665c049c02ae15698e1409155b8e72171
2017-05-15 21:42:32 +00:00
|
|
|
set(SYSTEM_LIBS ${CMAKE_THREAD_LIBS_INIT})
|
2017-01-20 21:16:22 +00:00
|
|
|
endif()
|
|
|
|
|
2022-04-11 20:44:09 +00:00
|
|
|
set(ROCKSDB_PLUGIN_EXTERNS "")
|
|
|
|
set(ROCKSDB_PLUGIN_BUILTINS "")
|
|
|
|
message(STATUS "ROCKSDB PLUGINS TO BUILD ${ROCKSDB_PLUGINS}")
|
|
|
|
foreach(PLUGIN IN LISTS PLUGINS)
|
2022-08-03 18:06:27 +00:00
|
|
|
set(PLUGIN_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/plugin/${PLUGIN}/")
|
2022-09-29 19:42:52 +00:00
|
|
|
message(STATUS "PLUGIN ${PLUGIN} including rocksb plugin ${PLUGIN_ROOT}")
|
2022-04-11 20:44:09 +00:00
|
|
|
set(PLUGINMKFILE "${PLUGIN_ROOT}${PLUGIN}.mk")
|
|
|
|
if (NOT EXISTS ${PLUGINMKFILE})
|
2022-09-29 19:42:52 +00:00
|
|
|
message(FATAL_ERROR "PLUGIN ${PLUGIN} Missing plugin makefile: ${PLUGINMKFILE}")
|
2022-04-11 20:44:09 +00:00
|
|
|
endif()
|
|
|
|
file(READ ${PLUGINMKFILE} PLUGINMK)
|
2022-09-29 19:42:52 +00:00
|
|
|
|
2022-04-11 20:44:09 +00:00
|
|
|
string(REGEX MATCH "SOURCES = ([^\n]*)" FOO ${PLUGINMK})
|
|
|
|
set(MK_SOURCES ${CMAKE_MATCH_1})
|
|
|
|
separate_arguments(MK_SOURCES)
|
|
|
|
foreach(MK_FILE IN LISTS MK_SOURCES)
|
|
|
|
list(APPEND SOURCES "${PLUGIN_ROOT}${MK_FILE}")
|
2022-09-29 19:42:52 +00:00
|
|
|
message(STATUS "PLUGIN ${PLUGIN} Appending ${PLUGIN_ROOT}${MK_FILE} to SOURCES")
|
2022-04-11 20:44:09 +00:00
|
|
|
endforeach()
|
2022-09-29 19:42:52 +00:00
|
|
|
|
2022-04-11 20:44:09 +00:00
|
|
|
string(REGEX MATCH "_FUNC = ([^\n]*)" FOO ${PLUGINMK})
|
|
|
|
if (NOT ${CMAKE_MATCH_1} STREQUAL "")
|
|
|
|
string(APPEND ROCKSDB_PLUGIN_BUILTINS "{\"${PLUGIN}\", " ${CMAKE_MATCH_1} "},")
|
|
|
|
string(APPEND ROCKSDB_PLUGIN_EXTERNS "int " ${CMAKE_MATCH_1} "(ROCKSDB_NAMESPACE::ObjectLibrary&, const std::string&); ")
|
|
|
|
endif()
|
2022-09-29 19:42:52 +00:00
|
|
|
|
2022-04-11 20:44:09 +00:00
|
|
|
string(REGEX MATCH "_LIBS = ([^\n]*)" FOO ${PLUGINMK})
|
2022-09-29 19:42:52 +00:00
|
|
|
separate_arguments(CMAKE_MATCH_1)
|
|
|
|
foreach(MK_LIB IN LISTS CMAKE_MATCH_1)
|
|
|
|
list(APPEND THIRDPARTY_LIBS "${MK_LIB}")
|
|
|
|
endforeach()
|
|
|
|
message(STATUS "PLUGIN ${PLUGIN} THIRDPARTY_LIBS=${THIRDPARTY_LIBS}")
|
|
|
|
|
2022-04-11 20:44:09 +00:00
|
|
|
#TODO: We need to set any compile/link-time flags and add any link libraries
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
string(TIMESTAMP TS "%Y-%m-%d %H:%M:%S" UTC)
|
|
|
|
set(BUILD_DATE "${TS}" CACHE STRING "the time we first built rocksdb")
|
|
|
|
|
|
|
|
find_package(Git)
|
|
|
|
|
|
|
|
if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
|
|
|
execute_process(WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_VARIABLE GIT_SHA COMMAND "${GIT_EXECUTABLE}" rev-parse HEAD )
|
|
|
|
execute_process(WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" RESULT_VARIABLE GIT_MOD COMMAND "${GIT_EXECUTABLE}" diff-index HEAD --quiet)
|
|
|
|
execute_process(WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_VARIABLE GIT_DATE COMMAND "${GIT_EXECUTABLE}" log -1 --date=format:"%Y-%m-%d %T" --format="%ad")
|
|
|
|
execute_process(WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_VARIABLE GIT_TAG RESULT_VARIABLE rv COMMAND "${GIT_EXECUTABLE}" symbolic-ref -q --short HEAD OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
if (rv AND NOT rv EQUAL 0)
|
|
|
|
execute_process(WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" OUTPUT_VARIABLE GIT_TAG COMMAND "${GIT_EXECUTABLE}" describe --tags --exact-match OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(GIT_SHA 0)
|
|
|
|
set(GIT_MOD 1)
|
|
|
|
endif()
|
|
|
|
string(REGEX REPLACE "[^0-9a-fA-F]+" "" GIT_SHA "${GIT_SHA}")
|
|
|
|
string(REGEX REPLACE "[^0-9: /-]+" "" GIT_DATE "${GIT_DATE}")
|
|
|
|
|
|
|
|
set(BUILD_VERSION_CC ${CMAKE_BINARY_DIR}/build_version.cc)
|
|
|
|
configure_file(util/build_version.cc.in ${BUILD_VERSION_CC} @ONLY)
|
|
|
|
|
2021-01-29 01:40:24 +00:00
|
|
|
add_library(${ROCKSDB_STATIC_LIB} STATIC ${SOURCES} ${BUILD_VERSION_CC})
|
2023-11-09 18:41:38 +00:00
|
|
|
target_include_directories(${ROCKSDB_STATIC_LIB} PUBLIC
|
|
|
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
|
2020-05-13 04:05:50 +00:00
|
|
|
target_link_libraries(${ROCKSDB_STATIC_LIB} PRIVATE
|
2016-09-28 18:53:15 +00:00
|
|
|
${THIRDPARTY_LIBS} ${SYSTEM_LIBS})
|
|
|
|
|
2019-12-10 23:19:24 +00:00
|
|
|
if(ROCKSDB_BUILD_SHARED)
|
2021-01-29 01:40:24 +00:00
|
|
|
add_library(${ROCKSDB_SHARED_LIB} SHARED ${SOURCES} ${BUILD_VERSION_CC})
|
2023-11-09 18:41:38 +00:00
|
|
|
target_include_directories(${ROCKSDB_SHARED_LIB} PUBLIC
|
|
|
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
|
2020-05-13 04:05:50 +00:00
|
|
|
target_link_libraries(${ROCKSDB_SHARED_LIB} PRIVATE
|
2017-01-20 21:16:22 +00:00
|
|
|
${THIRDPARTY_LIBS} ${SYSTEM_LIBS})
|
2019-12-10 23:19:24 +00:00
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
set_target_properties(${ROCKSDB_SHARED_LIB} PROPERTIES
|
|
|
|
COMPILE_DEFINITIONS "ROCKSDB_DLL;ROCKSDB_LIBRARY_EXPORTS")
|
|
|
|
if(MSVC)
|
|
|
|
set_target_properties(${ROCKSDB_STATIC_LIB} PROPERTIES
|
|
|
|
COMPILE_FLAGS "/Fd${CMAKE_CFG_INTDIR}/${ROCKSDB_STATIC_LIB}.pdb")
|
|
|
|
set_target_properties(${ROCKSDB_SHARED_LIB} PROPERTIES
|
|
|
|
COMPILE_FLAGS "/Fd${CMAKE_CFG_INTDIR}/${ROCKSDB_SHARED_LIB}.pdb")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set_target_properties(${ROCKSDB_SHARED_LIB} PROPERTIES
|
|
|
|
LINKER_LANGUAGE CXX
|
|
|
|
VERSION ${rocksdb_VERSION}
|
|
|
|
SOVERSION ${rocksdb_VERSION_MAJOR}
|
2021-01-21 16:33:13 +00:00
|
|
|
OUTPUT_NAME "rocksdb${ARTIFACT_SUFFIX}")
|
2017-03-30 23:47:19 +00:00
|
|
|
endif()
|
2016-09-28 18:53:15 +00:00
|
|
|
endif()
|
|
|
|
|
2019-12-10 23:19:24 +00:00
|
|
|
if(ROCKSDB_BUILD_SHARED AND NOT WIN32)
|
|
|
|
set(ROCKSDB_LIB ${ROCKSDB_SHARED_LIB})
|
|
|
|
else()
|
|
|
|
set(ROCKSDB_LIB ${ROCKSDB_STATIC_LIB})
|
|
|
|
endif()
|
|
|
|
|
2016-09-28 18:53:15 +00:00
|
|
|
option(WITH_JNI "build with JNI" OFF)
|
2020-06-04 01:18:38 +00:00
|
|
|
# Tests are excluded from Release builds
|
|
|
|
CMAKE_DEPENDENT_OPTION(WITH_TESTS "build with tests" ON
|
|
|
|
"CMAKE_BUILD_TYPE STREQUAL Debug" OFF)
|
|
|
|
option(WITH_BENCHMARK_TOOLS "build with benchmarks" ON)
|
|
|
|
option(WITH_CORE_TOOLS "build with ldb and sst_dump" ON)
|
|
|
|
option(WITH_TOOLS "build with tools" ON)
|
|
|
|
|
|
|
|
if(WITH_TESTS OR WITH_BENCHMARK_TOOLS OR WITH_TOOLS OR WITH_JNI OR JNI)
|
|
|
|
include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/third-party/gtest-1.8.1/fused-src)
|
|
|
|
endif()
|
2016-09-28 18:53:15 +00:00
|
|
|
if(WITH_JNI OR JNI)
|
|
|
|
message(STATUS "JNI library is enabled")
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/java)
|
2016-01-28 14:44:31 +00:00
|
|
|
else()
|
|
|
|
message(STATUS "JNI library is disabled")
|
|
|
|
endif()
|
|
|
|
|
2017-08-21 21:41:11 +00:00
|
|
|
# Installation and packaging
|
|
|
|
if(WIN32)
|
|
|
|
option(ROCKSDB_INSTALL_ON_WINDOWS "Enable install target on Windows" OFF)
|
|
|
|
endif()
|
|
|
|
if(NOT WIN32 OR ROCKSDB_INSTALL_ON_WINDOWS)
|
|
|
|
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
|
|
|
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
|
|
|
# Change default installation prefix on Linux to /usr
|
|
|
|
set(CMAKE_INSTALL_PREFIX /usr CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
include(GNUInstallDirs)
|
2017-08-28 23:56:49 +00:00
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
|
|
|
|
set(package_config_destination ${CMAKE_INSTALL_LIBDIR}/cmake/rocksdb)
|
|
|
|
|
|
|
|
configure_package_config_file(
|
2018-01-16 22:13:38 +00:00
|
|
|
${CMAKE_CURRENT_LIST_DIR}/cmake/RocksDBConfig.cmake.in RocksDBConfig.cmake
|
2017-08-28 23:56:49 +00:00
|
|
|
INSTALL_DESTINATION ${package_config_destination}
|
|
|
|
)
|
|
|
|
|
|
|
|
write_basic_package_version_file(
|
|
|
|
RocksDBConfigVersion.cmake
|
2019-08-06 02:47:33 +00:00
|
|
|
VERSION ${rocksdb_VERSION}
|
2017-08-28 23:56:49 +00:00
|
|
|
COMPATIBILITY SameMajorVersion
|
|
|
|
)
|
|
|
|
|
2022-05-05 16:03:31 +00:00
|
|
|
configure_file(
|
2022-05-30 19:46:40 +00:00
|
|
|
${PROJECT_NAME}.pc.in
|
|
|
|
${PROJECT_NAME}.pc
|
2022-05-05 16:03:31 +00:00
|
|
|
@ONLY
|
|
|
|
)
|
|
|
|
|
2017-08-28 23:56:49 +00:00
|
|
|
install(DIRECTORY include/rocksdb COMPONENT devel DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
|
|
|
|
2022-05-23 16:53:36 +00:00
|
|
|
foreach (plugin ${PLUGINS})
|
|
|
|
foreach (header ${${plugin}_HEADERS})
|
|
|
|
install(FILES plugin/${plugin}/${header} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocksdb/plugin/${plugin})
|
|
|
|
endforeach()
|
|
|
|
endforeach()
|
|
|
|
|
2020-05-13 04:16:50 +00:00
|
|
|
install(DIRECTORY "${PROJECT_SOURCE_DIR}/cmake/modules" COMPONENT devel DESTINATION ${package_config_destination})
|
|
|
|
|
2017-08-28 23:56:49 +00:00
|
|
|
install(
|
|
|
|
TARGETS ${ROCKSDB_STATIC_LIB}
|
|
|
|
EXPORT RocksDBTargets
|
|
|
|
COMPONENT devel
|
|
|
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
|
|
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
|
|
|
)
|
|
|
|
|
2019-12-10 23:19:24 +00:00
|
|
|
if(ROCKSDB_BUILD_SHARED)
|
|
|
|
install(
|
|
|
|
TARGETS ${ROCKSDB_SHARED_LIB}
|
|
|
|
EXPORT RocksDBTargets
|
|
|
|
COMPONENT runtime
|
|
|
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
|
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
|
|
|
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
|
|
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
|
|
|
)
|
|
|
|
endif()
|
2017-08-28 23:56:49 +00:00
|
|
|
|
|
|
|
install(
|
|
|
|
EXPORT RocksDBTargets
|
|
|
|
COMPONENT devel
|
|
|
|
DESTINATION ${package_config_destination}
|
|
|
|
NAMESPACE RocksDB::
|
|
|
|
)
|
|
|
|
|
|
|
|
install(
|
|
|
|
FILES
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/RocksDBConfig.cmake
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/RocksDBConfigVersion.cmake
|
|
|
|
COMPONENT devel
|
|
|
|
DESTINATION ${package_config_destination}
|
|
|
|
)
|
2022-05-05 16:03:31 +00:00
|
|
|
|
|
|
|
install(
|
|
|
|
FILES
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
|
|
|
|
COMPONENT devel
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
|
|
|
|
)
|
2017-08-21 21:41:11 +00:00
|
|
|
endif()
|
|
|
|
|
2020-06-13 00:04:35 +00:00
|
|
|
option(WITH_ALL_TESTS "Build all test, rather than a small subset" ON)
|
|
|
|
|
2020-07-09 01:50:58 +00:00
|
|
|
if(WITH_TESTS OR WITH_BENCHMARK_TOOLS)
|
2020-06-03 22:53:09 +00:00
|
|
|
add_subdirectory(third-party/gtest-1.8.1/fused-src/gtest)
|
2020-02-08 01:06:43 +00:00
|
|
|
add_library(testharness STATIC
|
2020-09-23 18:32:44 +00:00
|
|
|
test_util/mock_time_env.cc
|
2023-03-16 00:51:44 +00:00
|
|
|
test_util/secondary_cache_test_util.cc
|
2020-02-08 01:06:43 +00:00
|
|
|
test_util/testharness.cc)
|
|
|
|
target_link_libraries(testharness gtest)
|
2020-07-09 01:50:58 +00:00
|
|
|
endif()
|
2020-08-05 01:40:19 +00:00
|
|
|
|
2020-07-09 01:50:58 +00:00
|
|
|
if(WITH_TESTS)
|
2017-08-29 01:36:35 +00:00
|
|
|
set(TESTS
|
2020-06-13 00:04:35 +00:00
|
|
|
db/db_basic_test.cc
|
|
|
|
env/env_basic_test.cc
|
|
|
|
)
|
|
|
|
if(WITH_ALL_TESTS)
|
|
|
|
list(APPEND TESTS
|
2021-08-24 19:42:31 +00:00
|
|
|
cache/cache_reservation_manager_test.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
cache/cache_test.cc
|
2022-04-11 20:28:33 +00:00
|
|
|
cache/compressed_secondary_cache_test.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
cache/lru_cache_test.cc
|
Support compressed and local flash secondary cache stacking (#11812)
Summary:
This PR implements support for a three tier cache - primary block cache, compressed secondary cache, and a nvm (local flash) secondary cache. This allows more effective utilization of the nvm cache, and minimizes the number of reads from local flash by caching compressed blocks in the compressed secondary cache.
The basic design is as follows -
1. A new secondary cache implementation, ```TieredSecondaryCache```, is introduced. It keeps the compressed and nvm secondary caches and manages the movement of blocks between them and the primary block cache. To setup a three tier cache, we allocate a ```CacheWithSecondaryAdapter```, with a ```TieredSecondaryCache``` instance as the secondary cache.
2. The table reader passes both the uncompressed and compressed block to ```FullTypedCacheInterface::InsertFull```, allowing the block cache to optionally store the compressed block.
3. When there's a miss, the block object is constructed and inserted in the primary cache, and the compressed block is inserted into the nvm cache by calling ```InsertSaved```. This avoids the overhead of recompressing the block, as well as avoiding putting more memory pressure on the compressed secondary cache.
4. When there's a hit in the nvm cache, we attempt to insert the block in the compressed secondary cache and the primary cache, subject to the admission policy of those caches (i.e admit on second access). Blocks/items evicted from any tier are simply discarded.
We can easily implement additional admission policies if desired.
Todo (In a subsequent PR):
1. Add to db_bench and run benchmarks
2. Add to db_stress
Pull Request resolved: https://github.com/facebook/rocksdb/pull/11812
Reviewed By: pdillinger
Differential Revision: D49461842
Pulled By: anand1976
fbshipit-source-id: b40ac1330ef7cd8c12efa0a3ca75128e602e3a0b
2023-09-22 03:30:53 +00:00
|
|
|
cache/tiered_secondary_cache_test.cc
|
2021-06-23 17:24:39 +00:00
|
|
|
db/blob/blob_counting_iterator_test.cc
|
2020-03-12 17:58:27 +00:00
|
|
|
db/blob/blob_file_addition_test.cc
|
2020-08-27 18:54:43 +00:00
|
|
|
db/blob/blob_file_builder_test.cc
|
2020-10-15 20:02:44 +00:00
|
|
|
db/blob/blob_file_cache_test.cc
|
2020-03-12 17:58:27 +00:00
|
|
|
db/blob/blob_file_garbage_test.cc
|
Introduce a blob file reader class (#7461)
Summary:
The patch adds a class called `BlobFileReader` that can be used to retrieve blobs
using the information available in blob references (e.g. blob file number, offset, and
size). This will come in handy when implementing blob support for `Get`, `MultiGet`,
and iterators, and also for compaction/garbage collection.
When a `BlobFileReader` object is created (using the factory method `Create`),
it first checks whether the specified file is potentially valid by comparing the file
size against the combined size of the blob file header and footer (files smaller than
the threshold are considered malformed). Then, it opens the file, and reads and verifies
the header and footer. The verification involves magic number/CRC checks
as well as checking for unexpected header/footer fields, e.g. incorrect column family ID
or TTL blob files.
Blobs can be retrieved using `GetBlob`. `GetBlob` validates the offset and compression
type passed by the caller (because of the presence of the header and footer, the
specified offset cannot be too close to the start/end of the file; also, the compression type
has to match the one in the blob file header), and retrieves and potentially verifies and
uncompresses the blob. In particular, when `ReadOptions::verify_checksums` is set,
`BlobFileReader` reads the blob record header as well (as opposed to just the blob itself)
and verifies the key/value size, the key itself, as well as the CRC of the blob record header
and the key/value pair.
In addition, the patch exposes the compression type from `BlobIndex` (both using an
accessor and via `DebugString`), and adds a blob file read latency histogram to
`InternalStats` that can be used with `BlobFileReader`.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/7461
Test Plan: `make check`
Reviewed By: riversand963
Differential Revision: D23999219
Pulled By: ltamasi
fbshipit-source-id: deb6b1160d251258b308d5156e2ec063c3e12e5e
2020-10-07 22:43:23 +00:00
|
|
|
db/blob/blob_file_reader_test.cc
|
2021-06-22 05:24:23 +00:00
|
|
|
db/blob/blob_garbage_meter_test.cc
|
2022-06-17 22:22:59 +00:00
|
|
|
db/blob/blob_source_test.cc
|
2020-10-15 20:02:44 +00:00
|
|
|
db/blob/db_blob_basic_test.cc
|
2021-02-26 00:30:27 +00:00
|
|
|
db/blob/db_blob_compaction_test.cc
|
2021-02-23 06:07:59 +00:00
|
|
|
db/blob/db_blob_corruption_test.cc
|
2020-03-12 17:58:27 +00:00
|
|
|
db/blob/db_blob_index_test.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/column_family_test.cc
|
|
|
|
db/compact_files_test.cc
|
2021-06-09 22:40:16 +00:00
|
|
|
db/compaction/clipping_iterator_test.cc
|
2019-05-31 18:52:59 +00:00
|
|
|
db/compaction/compaction_job_stats_test.cc
|
|
|
|
db/compaction/compaction_job_test.cc
|
|
|
|
db/compaction/compaction_iterator_test.cc
|
|
|
|
db/compaction/compaction_picker_test.cc
|
2021-05-20 04:40:43 +00:00
|
|
|
db/compaction/compaction_service_test.cc
|
2022-07-14 03:54:49 +00:00
|
|
|
db/compaction/tiered_compaction_test.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/comparator_db_test.cc
|
|
|
|
db/corruption_test.cc
|
|
|
|
db/cuckoo_table_db_test.cc
|
2022-05-20 01:39:41 +00:00
|
|
|
db/db_readonly_with_timestamp_test.cc
|
2020-03-13 18:33:04 +00:00
|
|
|
db/db_with_timestamp_basic_test.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
db/db_block_cache_test.cc
|
|
|
|
db/db_bloom_filter_test.cc
|
2015-07-14 23:03:47 +00:00
|
|
|
db/db_compaction_filter_test.cc
|
2015-07-21 10:05:57 +00:00
|
|
|
db/db_compaction_test.cc
|
2023-05-18 20:25:01 +00:00
|
|
|
db/db_clip_test.cc
|
2015-07-14 23:03:47 +00:00
|
|
|
db/db_dynamic_level_test.cc
|
2022-02-19 02:18:49 +00:00
|
|
|
db/db_encryption_test.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
db/db_flush_test.cc
|
2015-07-20 23:05:28 +00:00
|
|
|
db/db_inplace_update_test.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
db/db_io_failure_test.cc
|
2016-01-20 23:17:52 +00:00
|
|
|
db/db_iter_test.cc
|
Change and clarify the relationship between Valid(), status() and Seek*() for all iterators. Also fix some bugs
Summary:
Before this PR, Iterator/InternalIterator may simultaneously have non-ok status() and Valid() = true. That state means that the last operation failed, but the iterator is nevertheless positioned on some unspecified record. Likely intended uses of that are:
* If some sst files are corrupted, a normal iterator can be used to read the data from files that are not corrupted.
* When using read_tier = kBlockCacheTier, read the data that's in block cache, skipping over the data that is not.
However, this behavior wasn't documented well (and until recently the wiki on github had misleading incorrect information). In the code there's a lot of confusion about the relationship between status() and Valid(), and about whether Seek()/SeekToLast()/etc reset the status or not. There were a number of bugs caused by this confusion, both inside rocksdb and in the code that uses rocksdb (including ours).
This PR changes the convention to:
* If status() is not ok, Valid() always returns false.
* Any seek operation resets status. (Before the PR, it depended on iterator type and on particular error.)
This does sacrifice the two use cases listed above, but siying said it's ok.
Overview of the changes:
* A commit that adds missing status checks in MergingIterator. This fixes a bug that actually affects us, and we need it fixed. `DBIteratorTest.NonBlockingIterationBugRepro` explains the scenario.
* Changes to lots of iterator types to make all of them conform to the new convention. Some bug fixes along the way. By far the biggest changes are in DBIter, which is a big messy piece of code; I tried to make it less big and messy but mostly failed.
* A stress-test for DBIter, to gain some confidence that I didn't break it. It does a few million random operations on the iterator, while occasionally modifying the underlying data (like ForwardIterator does) and occasionally returning non-ok status from internal iterator.
To find the iterator types that needed changes I searched for "public .*Iterator" in the code. Here's an overview of all 27 iterator types:
Iterators that didn't need changes:
* status() is always ok(), or Valid() is always false: MemTableIterator, ModelIter, TestIterator, KVIter (2 classes with this name anonymous namespaces), LoggingForwardVectorIterator, VectorIterator, MockTableIterator, EmptyIterator, EmptyInternalIterator.
* Thin wrappers that always pass through Valid() and status(): ArenaWrappedDBIter, TtlIterator, InternalIteratorFromIterator.
Iterators with changes (see inline comments for details):
* DBIter - an overhaul:
- It used to silently skip corrupted keys (`FindParseableKey()`), which seems dangerous. This PR makes it just stop immediately after encountering a corrupted key, just like it would for other kinds of corruption. Let me know if there was actually some deeper meaning in this behavior and I should put it back.
- It had a few code paths silently discarding subiterator's status. The stress test caught a few.
- The backwards iteration code path was expecting the internal iterator's set of keys to be immutable. It's probably always true in practice at the moment, since ForwardIterator doesn't support backwards iteration, but this PR fixes it anyway. See added DBIteratorTest.ReverseToForwardBug for an example.
- Some parts of backwards iteration code path even did things like `assert(iter_->Valid())` after a seek, which is never a safe assumption.
- It used to not reset status on seek for some types of errors.
- Some simplifications and better comments.
- Some things got more complicated from the added error handling. I'm open to ideas for how to make it nicer.
* MergingIterator - check status after every operation on every subiterator, and in some places assert that valid subiterators have ok status.
* ForwardIterator - changed to the new convention, also slightly simplified.
* ForwardLevelIterator - fixed some bugs and simplified.
* LevelIterator - simplified.
* TwoLevelIterator - changed to the new convention. Also fixed a bug that would make SeekForPrev() sometimes silently ignore errors from first_level_iter_.
* BlockBasedTableIterator - minor changes.
* BlockIter - replaced `SetStatus()` with `Invalidate()` to make sure non-ok BlockIter is always invalid.
* PlainTableIterator - some seeks used to not reset status.
* CuckooTableIterator - tiny code cleanup.
* ManagedIterator - fixed some bugs.
* BaseDeltaIterator - changed to the new convention and fixed a bug.
* BlobDBIterator - seeks used to not reset status.
* KeyConvertingIterator - some small change.
Closes https://github.com/facebook/rocksdb/pull/3810
Differential Revision: D7888019
Pulled By: al13n321
fbshipit-source-id: 4aaf6d3421c545d16722a815b2fa2e7912bc851d
2018-05-17 09:44:14 +00:00
|
|
|
db/db_iter_stress_test.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
db/db_iterator_test.cc
|
Integrity protection for live updates to WriteBatch (#7748)
Summary:
This PR adds the foundation classes for key-value integrity protection and the first use case: protecting live updates from the source buffers added to `WriteBatch` through the destination buffer in `MemTable`. The width of the protection info is not yet configurable -- only eight bytes per key is supported. This PR allows users to enable protection by constructing `WriteBatch` with `protection_bytes_per_key == 8`. It does not yet expose a way for users to get integrity protection via other write APIs (e.g., `Put()`, `Merge()`, `Delete()`, etc.).
The foundation classes (`ProtectionInfo.*`) embed the coverage info in their type, and provide `Protect.*()` and `Strip.*()` functions to navigate between types with different coverage. For making bytes per key configurable (for powers of two up to eight) in the future, these classes are templated on the unsigned integer type used to store the protection info. That integer contains the XOR'd result of hashes with independent seeds for all covered fields. For integer fields, the hash is computed on the raw unadjusted bytes, so the result is endian-dependent. The most significant bytes are truncated when the hash value (8 bytes) is wider than the protection integer.
When `WriteBatch` is constructed with `protection_bytes_per_key == 8`, we hold a `ProtectionInfoKVOTC` (i.e., one that covers key, value, optype aka `ValueType`, timestamp, and CF ID) for each entry added to the batch. The protection info is generated from the original buffers passed by the user, as well as the original metadata generated internally. When writing to memtable, each entry is transformed to a `ProtectionInfoKVOTS` (i.e., dropping coverage of CF ID and adding coverage of sequence number), since at that point we know the sequence number, and have already selected a memtable corresponding to a particular CF. This protection info is verified once the entry is encoded in the `MemTable` buffer.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/7748
Test Plan:
- an integration test to verify a wide variety of single-byte changes to the encoded `MemTable` buffer are caught
- add to stress/crash test to verify it works in variety of configs/operations without intentional corruption
- [deferred] unit tests for `ProtectionInfo.*` classes for edge cases like KV swap, `SliceParts` and `Slice` APIs are interchangeable, etc.
Reviewed By: pdillinger
Differential Revision: D25754492
Pulled By: ajkr
fbshipit-source-id: e481bac6c03c2ab268be41359730f1ceb9964866
2021-01-29 20:17:17 +00:00
|
|
|
db/db_kv_checksum_test.cc
|
2015-07-20 22:51:33 +00:00
|
|
|
db/db_log_iter_test.cc
|
2016-11-14 02:58:17 +00:00
|
|
|
db/db_memtable_test.cc
|
2016-12-16 19:00:03 +00:00
|
|
|
db/db_merge_operator_test.cc
|
New API to get all merge operands for a Key (#5604)
Summary:
This is a new API added to db.h to allow for fetching all merge operands associated with a Key. The main motivation for this API is to support use cases where doing a full online merge is not necessary as it is performance sensitive. Example use-cases:
1. Update subset of columns and read subset of columns -
Imagine a SQL Table, a row is encoded as a K/V pair (as it is done in MyRocks). If there are many columns and users only updated one of them, we can use merge operator to reduce write amplification. While users only read one or two columns in the read query, this feature can avoid a full merging of the whole row, and save some CPU.
2. Updating very few attributes in a value which is a JSON-like document -
Updating one attribute can be done efficiently using merge operator, while reading back one attribute can be done more efficiently if we don't need to do a full merge.
----------------------------------------------------------------------------------------------------
API :
Status GetMergeOperands(
const ReadOptions& options, ColumnFamilyHandle* column_family,
const Slice& key, PinnableSlice* merge_operands,
GetMergeOperandsOptions* get_merge_operands_options,
int* number_of_operands)
Example usage :
int size = 100;
int number_of_operands = 0;
std::vector<PinnableSlice> values(size);
GetMergeOperandsOptions merge_operands_info;
db_->GetMergeOperands(ReadOptions(), db_->DefaultColumnFamily(), "k1", values.data(), merge_operands_info, &number_of_operands);
Description :
Returns all the merge operands corresponding to the key. If the number of merge operands in DB is greater than merge_operands_options.expected_max_number_of_operands no merge operands are returned and status is Incomplete. Merge operands returned are in the order of insertion.
merge_operands-> Points to an array of at-least merge_operands_options.expected_max_number_of_operands and the caller is responsible for allocating it. If the status returned is Incomplete then number_of_operands will contain the total number of merge operands found in DB for key.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5604
Test Plan:
Added unit test and perf test in db_bench that can be run using the command:
./db_bench -benchmarks=getmergeoperands --merge_operator=sortlist
Differential Revision: D16657366
Pulled By: vjnadimpalli
fbshipit-source-id: 0faadd752351745224ee12d4ae9ef3cb529951bf
2019-08-06 21:22:34 +00:00
|
|
|
db/db_merge_operand_test.cc
|
2016-07-12 22:30:38 +00:00
|
|
|
db/db_options_test.cc
|
2016-01-20 23:17:52 +00:00
|
|
|
db/db_properties_test.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
db/db_range_del_test.cc
|
2022-02-17 07:17:03 +00:00
|
|
|
db/db_rate_limiter_test.cc
|
2021-03-15 22:01:27 +00:00
|
|
|
db/db_secondary_test.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
db/db_sst_test.cc
|
2017-04-26 21:18:58 +00:00
|
|
|
db/db_statistics_test.cc
|
2016-01-20 23:17:52 +00:00
|
|
|
db/db_table_properties_test.cc
|
|
|
|
db/db_tailing_iter_test.cc
|
|
|
|
db/db_test.cc
|
2016-03-01 02:38:03 +00:00
|
|
|
db/db_test2.cc
|
2020-03-12 01:36:43 +00:00
|
|
|
db/db_logical_block_size_cache_test.cc
|
2015-07-15 01:24:45 +00:00
|
|
|
db/db_universal_compaction_test.cc
|
2015-08-05 18:56:19 +00:00
|
|
|
db/db_wal_test.cc
|
2020-04-10 23:03:33 +00:00
|
|
|
db/db_with_timestamp_compaction_test.cc
|
2022-02-19 02:18:49 +00:00
|
|
|
db/db_write_buffer_manager_test.cc
|
2017-05-31 17:45:47 +00:00
|
|
|
db/db_write_test.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/dbformat_test.cc
|
|
|
|
db/deletefile_test.cc
|
2020-03-04 20:30:34 +00:00
|
|
|
db/error_handler_fs_test.cc
|
2018-03-28 17:23:31 +00:00
|
|
|
db/obsolete_files_test.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
db/external_sst_file_basic_test.cc
|
|
|
|
db/external_sst_file_test.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/fault_injection_test.cc
|
|
|
|
db/file_indexer_test.cc
|
|
|
|
db/filename_test.cc
|
|
|
|
db/flush_job_test.cc
|
2022-02-19 02:18:49 +00:00
|
|
|
db/import_column_family_test.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/listener_test.cc
|
|
|
|
db/log_test.cc
|
2015-10-14 18:06:27 +00:00
|
|
|
db/manual_compaction_test.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/memtable_list_test.cc
|
2015-07-22 01:04:28 +00:00
|
|
|
db/merge_helper_test.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
db/merge_test.cc
|
Introduce MultiCfIterator (#12153)
Summary:
This PR introduces a new implementation of `Iterator` via a new public API called `NewMultiCfIterator()`. The new API takes a vector of column family handles to build a cross-column-family iterator, which internally maintains multiple `DBIter`s as child iterators from a consistent database state. When a key exists in multiple column families, the iterator selects the value (and wide columns) from the first column family containing the key, following the order provided in the `column_families` parameter. Similar to the merging iterator, a min heap is used to iterate across the child iterators. Backward iteration and direction change functionalities will be implemented in future PRs.
The comparator used to compare keys across different column families will be derived from the iterator of the first column family specified in `column_families`. This comparator will be checked against the comparators from all other column families that the iterator will traverse. If there's a mismatch with any of the comparators, the initialization of the iterator will fail.
Please note that this PR is not enough for users to start using `MultiCfIterator`. The `MultiCfIterator` and related APIs are still marked as "**DO NOT USE - UNDER CONSTRUCTION**". This PR is just the first of many PRs that will follow soon.
This PR includes the following:
- Introduction and partial implementation of the `MultiCfIterator`, which implements the generic `Iterator` interface. The implementation includes the construction of the iterator, `SeekToFirst()`, `Next()`, `Valid()`, `key()`, `value()`, and `columns()`.
- Unit tests to verify iteration across multiple column families in two distinct scenarios: (1) keys are unique across all column families, and (2) the same keys exist in multiple column families.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/12153
Reviewed By: pdillinger
Differential Revision: D52308697
Pulled By: jaykorean
fbshipit-source-id: b03e69f13b40af5a8f0598d0f43a0bec01ef8294
2024-03-05 18:22:43 +00:00
|
|
|
db/multi_cf_iterator_test.cc
|
2015-11-11 06:58:01 +00:00
|
|
|
db/options_file_test.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/perf_context_test.cc
|
2022-08-26 01:52:37 +00:00
|
|
|
db/periodic_task_scheduler_test.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/plain_table_db_test.cc
|
2022-07-15 04:49:34 +00:00
|
|
|
db/seqno_time_test.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/prefix_test.cc
|
Use only "local" range tombstones during Get (#4449)
Summary:
Previously, range tombstones were accumulated from every level, which
was necessary if a range tombstone in a higher level covered a key in a lower
level. However, RangeDelAggregator::AddTombstones's complexity is based on
the number of tombstones that are currently stored in it, which is wasteful in
the Get case, where we only need to know the highest sequence number of range
tombstones that cover the key from higher levels, and compute the highest covering
sequence number at the current level. This change introduces this optimization, and
removes the use of RangeDelAggregator from the Get path.
In the benchmark results, the following command was used to initialize the database:
```
./db_bench -db=/dev/shm/5k-rts -use_existing_db=false -benchmarks=filluniquerandom -write_buffer_size=1048576 -compression_type=lz4 -target_file_size_base=1048576 -max_bytes_for_level_base=4194304 -value_size=112 -key_size=16 -block_size=4096 -level_compaction_dynamic_level_bytes=true -num=5000000 -max_background_jobs=12 -benchmark_write_rate_limit=20971520 -range_tombstone_width=100 -writes_per_range_tombstone=100 -max_num_range_tombstones=50000 -bloom_bits=8
```
...and the following command was used to measure read throughput:
```
./db_bench -db=/dev/shm/5k-rts/ -use_existing_db=true -benchmarks=readrandom -disable_auto_compactions=true -num=5000000 -reads=100000 -threads=32
```
The filluniquerandom command was only run once, and the resulting database was used
to measure read performance before and after the PR. Both binaries were compiled with
`DEBUG_LEVEL=0`.
Readrandom results before PR:
```
readrandom : 4.544 micros/op 220090 ops/sec; 16.9 MB/s (63103 of 100000 found)
```
Readrandom results after PR:
```
readrandom : 11.147 micros/op 89707 ops/sec; 6.9 MB/s (63103 of 100000 found)
```
So it's actually slower right now, but this PR paves the way for future optimizations (see #4493).
----
Pull Request resolved: https://github.com/facebook/rocksdb/pull/4449
Differential Revision: D10370575
Pulled By: abhimadan
fbshipit-source-id: 9a2e152be1ef36969055c0e9eb4beb0d96c11f4d
2018-10-24 19:29:29 +00:00
|
|
|
db/range_del_aggregator_test.cc
|
|
|
|
db/range_tombstone_fragmenter_test.cc
|
2016-03-18 22:18:42 +00:00
|
|
|
db/repair_test.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/table_properties_collector_test.cc
|
|
|
|
db/version_builder_test.cc
|
|
|
|
db/version_edit_test.cc
|
|
|
|
db/version_set_test.cc
|
|
|
|
db/wal_manager_test.cc
|
Define WAL related classes to be used in VersionEdit and VersionSet (#7164)
Summary:
`WalAddition`, `WalDeletion` are defined in `wal_version.h` and used in `VersionEdit`.
`WalAddition` is used to represent events of creating a new WAL (no size, just log number), or closing a WAL (with size).
`WalDeletion` is used to represent events of deleting or archiving a WAL, it means the WAL is no longer alive (won't be replayed during recovery).
`WalSet` is the set of alive WALs kept in `VersionSet`.
1. Why use `WalDeletion` instead of relying on `MinLogNumber` to identify outdated WALs
On recovery, we can compute `MinLogNumber()` based on the log numbers kept in MANIFEST, any log with number < MinLogNumber can be ignored. So it seems that we don't need to persist `WalDeletion` to MANIFEST, since we can ignore the WALs based on MinLogNumber.
But the `MinLogNumber()` is actually a lower bound, it does not exactly mean that logs starting from MinLogNumber must exist. This is because in a corner case, when a column family is empty and never flushed, its log number is set to the largest log number, but not persisted in MANIFEST. So let's say there are 2 column families, when creating the DB, the first WAL has log number 1, so it's persisted to MANIFEST for both column families. Then CF 0 is empty and never flushed, CF 1 is updated and flushed, so a new WAL with log number 2 is created and persisted to MANIFEST for CF 1. But CF 0's log number in MANIFEST is still 1. So on recovery, MinLogNumber is 1, but since log 1 only contains data for CF 1, and CF 1 is flushed, log 1 might have already been deleted from disk.
We can make `MinLogNumber()` be the exactly minimum log number that must exist, by persisting the most recent log number for empty column families that are not flushed. But if there are N such column families, then every time a new WAL is created, we need to add N records to MANIFEST.
In current design, a record is persisted to MANIFEST only when WAL is created, closed, or deleted/archived, so the number of WAL related records are bounded to 3x number of WALs.
2. Why keep `WalSet` in `VersionSet` instead of applying the `VersionEdit`s to `VersionStorageInfo`
`VersionEdit`s are originally designed to track the addition and deletion of SST files. The SST files are related to column families, each column family has a list of `Version`s, and each `Version` keeps the set of active SST files in `VersionStorageInfo`.
But WALs are a concept of DB, they are not bounded to specific column families. So logically it does not make sense to store WALs in a column family's `Version`s.
Also, `Version`'s purpose is to keep reference to SST / blob files, so that they are not deleted until there is no version referencing them. But a WAL is deleted regardless of version references.
So we keep the WALs in `VersionSet` for the purpose of writing out the DB state's snapshot when creating new MANIFESTs.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/7164
Test Plan:
make version_edit_test && ./version_edit_test
make wal_edit_test && ./wal_edit_test
Reviewed By: ltamasi
Differential Revision: D22677936
Pulled By: cheng-chang
fbshipit-source-id: 5a3b6890140e572ffd79eb37e6e4c3c32361a859
2020-08-05 23:32:26 +00:00
|
|
|
db/wal_edit_test.cc
|
2022-06-25 22:30:47 +00:00
|
|
|
db/wide/db_wide_basic_test.cc
|
2022-06-04 03:54:48 +00:00
|
|
|
db/wide/wide_column_serialization_test.cc
|
Wide Column support in ldb (#11754)
Summary:
wide_columns can now be pretty-printed in the following commands
- `./ldb dump_wal`
- `./ldb dump`
- `./ldb idump`
- `./ldb dump_live_files`
- `./ldb scan`
- `./sst_dump --command=scan`
There are opportunities to refactor to reduce some nearly identical code. This PR is initial change to add wide column support in `ldb` and `sst_dump` tool. More PRs to come for the refactor.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/11754
Test Plan:
**New Tests added**
- `WideColumnsHelperTest::DumpWideColumns`
- `WideColumnsHelperTest::DumpSliceAsWideColumns`
**Changes added to existing tests**
- `ExternalSSTFileTest::BasicMixed` added to cover mixed case (This test should have been added in https://github.com/facebook/rocksdb/issues/11688). This test does not verify the ldb or sst_dump output. This test was used to create test SST files having some rows with wide columns and some without and the generated SST files were used to manually test sst_dump_tool.
- `createSST()` in `sst_dump_test` now takes `wide_column_one_in` to add wide column value in SST
**dump_wal**
```
./ldb dump_wal --walfile=/tmp/rocksdbtest-226125/db_wide_basic_test_2675429_2308393776696827948/000004.log --print_value --header
```
```
Sequence,Count,ByteSize,Physical Offset,Key(s) : value
1,1,59,0,PUT_ENTITY(0) : 0x:0x68656C6C6F 0x617474725F6E616D6531:0x666F6F 0x617474725F6E616D6532:0x626172
2,1,34,42,PUT_ENTITY(0) : 0x617474725F6F6E65:0x74776F 0x617474725F7468726565:0x666F7572
3,1,17,7d,PUT(0) : 0x7468697264 : 0x62617A
```
**idump**
```
./ldb --db=/tmp/rocksdbtest-226125/db_wide_basic_test_3481961_2308393776696827948/ idump
```
```
'first' seq:1, type:22 => :hello attr_name1:foo attr_name2:bar
'second' seq:2, type:22 => attr_one:two attr_three:four
'third' seq:3, type:1 => baz
Internal keys in range: 3
```
**SST Dump from dump_live_files**
```
./ldb --db=/tmp/rocksdbtest-226125/db_wide_basic_test_3481961_2308393776696827948/ compact
./ldb --db=/tmp/rocksdbtest-226125/db_wide_basic_test_3481961_2308393776696827948/ dump_live_files
```
```
...
==============================
SST Files
==============================
/tmp/rocksdbtest-226125/db_wide_basic_test_3481961_2308393776696827948/000013.sst level:1
------------------------------
Process /tmp/rocksdbtest-226125/db_wide_basic_test_3481961_2308393776696827948/000013.sst
Sst file format: block-based
'first' seq:0, type:22 => :hello attr_name1:foo attr_name2:bar
'second' seq:0, type:22 => attr_one:two attr_three:four
'third' seq:0, type:1 => baz
...
```
**dump**
```
./ldb --db=/tmp/rocksdbtest-226125/db_wide_basic_test_3481961_2308393776696827948/ dump
```
```
first ==> :hello attr_name1:foo attr_name2:bar
second ==> attr_one:two attr_three:four
third ==> baz
Keys in range: 3
```
**scan**
```
./ldb --db=/tmp/rocksdbtest-226125/db_wide_basic_test_3481961_2308393776696827948/ scan
```
```
first : :hello attr_name1:foo attr_name2:bar
second : attr_one:two attr_three:four
third : baz
```
**sst_dump**
```
./sst_dump --file=/tmp/rocksdbtest-226125/db_wide_basic_test_3481961_2308393776696827948/000013.sst --command=scan
```
```
options.env is 0x7ff54b296000
Process /tmp/rocksdbtest-226125/db_wide_basic_test_3481961_2308393776696827948/000013.sst
Sst file format: block-based
from [] to []
'first' seq:0, type:22 => :hello attr_name1:foo attr_name2:bar
'second' seq:0, type:22 => attr_one:two attr_three:four
'third' seq:0, type:1 => baz
```
Reviewed By: ltamasi
Differential Revision: D48837999
Pulled By: jaykorean
fbshipit-source-id: b0280f0589d2b9716bb9b50530ffcabb397d140f
2023-08-30 19:45:52 +00:00
|
|
|
db/wide/wide_columns_helper_test.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
db/write_batch_test.cc
|
|
|
|
db/write_callback_test.cc
|
|
|
|
db/write_controller_test.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
env/env_test.cc
|
2020-03-12 01:36:43 +00:00
|
|
|
env/io_posix_test.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
env/mock_env_test.cc
|
2019-05-30 03:44:08 +00:00
|
|
|
file/delete_scheduler_test.cc
|
2020-08-28 01:15:11 +00:00
|
|
|
file/prefetch_test.cc
|
Support direct IO in RandomAccessFileReader::MultiRead (#6446)
Summary:
By supporting direct IO in RandomAccessFileReader::MultiRead, the benefits of parallel IO (IO uring) and direct IO can be combined.
In direct IO mode, read requests are aligned and merged together before being issued to RandomAccessFile::MultiRead, so blocks in the original requests might share the same underlying buffer, the shared buffers are returned in `aligned_bufs`, which is a new parameter of the `MultiRead` API.
For example, suppose alignment requirement for direct IO is 4KB, one request is (offset: 1KB, len: 1KB), another request is (offset: 3KB, len: 1KB), then since they all belong to page (offset: 0, len: 4KB), `MultiRead` only reads the page with direct IO into a buffer on heap, and returns 2 Slices referencing regions in that same buffer. See `random_access_file_reader_test.cc` for more examples.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6446
Test Plan: Added a new test `random_access_file_reader_test.cc`.
Reviewed By: anand1976
Differential Revision: D20097518
Pulled By: cheng-chang
fbshipit-source-id: ca48a8faf9c3af146465c102ef6b266a363e78d1
2020-03-20 23:15:40 +00:00
|
|
|
file/random_access_file_reader_test.cc
|
2019-06-01 00:19:43 +00:00
|
|
|
logging/auto_roll_logger_test.cc
|
2019-07-09 21:48:07 +00:00
|
|
|
logging/env_logger_test.cc
|
2019-06-01 00:19:43 +00:00
|
|
|
logging/event_logger_test.cc
|
2019-05-31 00:39:43 +00:00
|
|
|
memory/arena_test.cc
|
2021-12-17 12:19:34 +00:00
|
|
|
memory/memory_allocator_test.cc
|
2017-04-06 20:59:31 +00:00
|
|
|
memtable/inlineskiplist_test.cc
|
|
|
|
memtable/skiplist_test.cc
|
2017-06-02 21:13:59 +00:00
|
|
|
memtable/write_buffer_manager_test.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
monitoring/histogram_test.cc
|
|
|
|
monitoring/iostats_context_test.cc
|
|
|
|
monitoring/statistics_test.cc
|
2019-06-17 22:17:43 +00:00
|
|
|
monitoring/stats_history_test.cc
|
2020-09-14 23:59:00 +00:00
|
|
|
options/configurable_test.cc
|
2020-11-11 23:09:14 +00:00
|
|
|
options/customizable_test.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
options/options_settable_test.cc
|
|
|
|
options/options_test.cc
|
2020-05-15 06:23:32 +00:00
|
|
|
table/block_based/block_based_table_reader_test.cc
|
2019-05-30 21:47:29 +00:00
|
|
|
table/block_based/block_test.cc
|
|
|
|
table/block_based/data_block_hash_index_test.cc
|
|
|
|
table/block_based/full_filter_block_test.cc
|
2019-05-31 04:30:41 +00:00
|
|
|
table/block_based/partitioned_filter_block_test.cc
|
2017-10-13 01:19:10 +00:00
|
|
|
table/cleanable_test.cc
|
2019-05-30 21:47:29 +00:00
|
|
|
table/cuckoo/cuckoo_table_builder_test.cc
|
|
|
|
table/cuckoo/cuckoo_table_reader_test.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
table/merger_test.cc
|
2018-11-27 20:59:27 +00:00
|
|
|
table/sst_file_reader_test.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
table/table_test.cc
|
2020-04-24 22:30:12 +00:00
|
|
|
table/block_fetcher_test.cc
|
2020-06-05 17:53:08 +00:00
|
|
|
test_util/testutil_test.cc
|
2020-12-21 16:45:54 +00:00
|
|
|
trace_replay/block_cache_tracer_test.cc
|
2020-08-13 00:28:10 +00:00
|
|
|
trace_replay/io_tracer_test.cc
|
Block cache simulator: Add pysim to simulate caches using reinforcement learning. (#5610)
Summary:
This PR implements cache eviction using reinforcement learning. It includes two implementations:
1. An implementation of Thompson Sampling for the Bernoulli Bandit [1].
2. An implementation of LinUCB with disjoint linear models [2].
The idea is that a cache uses multiple eviction policies, e.g., MRU, LRU, and LFU. The cache learns which eviction policy is the best and uses it upon a cache miss.
Thompson Sampling is contextless and does not include any features.
LinUCB includes features such as level, block type, caller, column family id to decide which eviction policy to use.
[1] Daniel J. Russo, Benjamin Van Roy, Abbas Kazerouni, Ian Osband, and Zheng Wen. 2018. A Tutorial on Thompson Sampling. Found. Trends Mach. Learn. 11, 1 (July 2018), 1-96. DOI: https://doi.org/10.1561/2200000070
[2] Lihong Li, Wei Chu, John Langford, and Robert E. Schapire. 2010. A contextual-bandit approach to personalized news article recommendation. In Proceedings of the 19th international conference on World wide web (WWW '10). ACM, New York, NY, USA, 661-670. DOI=http://dx.doi.org/10.1145/1772690.1772758
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5610
Differential Revision: D16435067
Pulled By: HaoyuHuang
fbshipit-source-id: 6549239ae14115c01cb1e70548af9e46d8dc21bb
2019-07-26 21:36:16 +00:00
|
|
|
tools/block_cache_analyzer/block_cache_trace_analyzer_test.cc
|
2020-09-23 22:49:11 +00:00
|
|
|
tools/io_tracer_parser_test.cc
|
2015-10-15 00:08:28 +00:00
|
|
|
tools/ldb_cmd_test.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
tools/reduce_levels_test.cc
|
2015-10-15 00:08:28 +00:00
|
|
|
tools/sst_dump_test.cc
|
RocksDB Trace Analyzer (#4091)
Summary:
A framework of trace analyzing for RocksDB
After collecting the trace by using the tool of [PR #3837](https://github.com/facebook/rocksdb/pull/3837). User can use the Trace Analyzer to interpret, analyze, and characterize the collected workload.
**Input:**
1. trace file
2. Whole keys space file
**Statistics:**
1. Access count of each operation (Get, Put, Delete, SingleDelete, DeleteRange, Merge) in each column family.
2. Key hotness (access count) of each one
3. Key space separation based on given prefix
4. Key size distribution
5. Value size distribution if appliable
6. Top K accessed keys
7. QPS statistics including the average QPS and peak QPS
8. Top K accessed prefix
9. The query correlation analyzing, output the number of X after Y and the corresponding average time
intervals
**Output:**
1. key access heat map (either in the accessed key space or whole key space)
2. trace sequence file (interpret the raw trace file to line base text file for future use)
3. Time serial (The key space ID and its access time)
4. Key access count distritbution
5. Key size distribution
6. Value size distribution (in each intervals)
7. whole key space separation by the prefix
8. Accessed key space separation by the prefix
9. QPS of each operation and each column family
10. Top K QPS and their accessed prefix range
**Test:**
1. Added the unit test of analyzing Get, Put, Delete, SingleDelete, DeleteRange, Merge
2. Generated the trace and analyze the trace
**Implemented but not tested (due to the limitation of trace_replay):**
1. Analyzing Iterator, supporting Seek() and SeekForPrev() analyzing
2. Analyzing the number of Key found by Get
**Future Work:**
1. Support execution time analyzing of each requests
2. Support cache hit situation and block read situation of Get
Pull Request resolved: https://github.com/facebook/rocksdb/pull/4091
Differential Revision: D9256157
Pulled By: zhichao-cao
fbshipit-source-id: f0ceacb7eedbc43a3eee6e85b76087d7832a8fe6
2018-08-13 18:32:04 +00:00
|
|
|
tools/trace_analyzer_test.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
util/autovector_test.cc
|
|
|
|
util/bloom_test.cc
|
|
|
|
util/coding_test.cc
|
|
|
|
util/crc32c_test.cc
|
2020-02-11 01:58:03 +00:00
|
|
|
util/defer_test.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
util/dynamic_bloom_test.cc
|
RangeSync not to sync last 1MB of the file
Summary:
From other ones' investigation:
"sync_file_range() behavior highly depends on kernel version and filesystem.
xfs does neighbor page flushing outside of the specified ranges. For example, sync_file_range(fd, 8192, 16384) does not only trigger flushing page #3 to #4, but also flushing many more dirty pages (i.e. up to page#16)... Ranges of the sync_file_range() should be far enough from write() offset (at least 1MB)."
Test Plan: make all check
Reviewers: igor, rven, kradhakrishnan, yhchiang, IslamAbdelRahman, anthony
Reviewed By: anthony
Subscribers: yoshinorim, MarkCallaghan, sumeet, domas, dhruba, leveldb, ljin
Differential Revision: https://reviews.facebook.net/D15807
2015-07-20 21:46:15 +00:00
|
|
|
util/file_reader_writer_test.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
util/filelock_test.cc
|
2017-07-10 19:22:26 +00:00
|
|
|
util/hash_test.cc
|
2015-07-22 01:04:28 +00:00
|
|
|
util/heap_test.cc
|
2019-12-13 21:25:14 +00:00
|
|
|
util/random_test.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
util/rate_limiter_test.cc
|
2018-09-27 22:25:47 +00:00
|
|
|
util/repeatable_thread_test.cc
|
2020-10-26 03:43:04 +00:00
|
|
|
util/ribbon_test.cc
|
2020-02-07 22:24:41 +00:00
|
|
|
util/slice_test.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
util/slice_transform_test.cc
|
2024-01-10 18:17:31 +00:00
|
|
|
util/string_util_test.cc
|
2017-05-10 21:54:35 +00:00
|
|
|
util/timer_queue_test.cc
|
2020-04-07 18:53:00 +00:00
|
|
|
util/timer_test.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
util/thread_list_test.cc
|
|
|
|
util/thread_local_test.cc
|
2023-05-22 21:28:58 +00:00
|
|
|
util/udt_util_test.cc
|
2020-04-01 23:37:54 +00:00
|
|
|
util/work_queue_test.cc
|
2022-04-16 06:24:05 +00:00
|
|
|
utilities/agg_merge/agg_merge_test.cc
|
2022-04-05 16:52:33 +00:00
|
|
|
utilities/backup/backup_engine_test.cc
|
2017-05-31 05:16:32 +00:00
|
|
|
utilities/blob_db/blob_db_test.cc
|
2017-07-21 21:42:32 +00:00
|
|
|
utilities/cassandra/cassandra_functional_test.cc
|
|
|
|
utilities/cassandra/cassandra_format_test.cc
|
|
|
|
utilities/cassandra/cassandra_row_merge_test.cc
|
|
|
|
utilities/cassandra/cassandra_serialize_test.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
utilities/checkpoint/checkpoint_test.cc
|
2022-02-19 02:18:49 +00:00
|
|
|
utilities/env_timed_test.cc
|
2015-11-04 01:52:17 +00:00
|
|
|
utilities/memory/memory_test.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
utilities/merge_operators/string_append/stringappend_test.cc
|
2017-04-06 02:02:00 +00:00
|
|
|
utilities/object_registry_test.cc
|
2016-07-14 04:08:15 +00:00
|
|
|
utilities/option_change_migration/option_change_migration_test.cc
|
2015-11-12 22:53:19 +00:00
|
|
|
utilities/options/options_util_test.cc
|
2016-06-02 20:42:41 +00:00
|
|
|
utilities/persistent_cache/hash_table_test.cc
|
2016-06-07 23:07:30 +00:00
|
|
|
utilities/persistent_cache/persistent_cache_test.cc
|
2019-07-11 19:40:08 +00:00
|
|
|
utilities/simulator_cache/cache_simulator_test.cc
|
2017-07-28 19:18:09 +00:00
|
|
|
utilities/simulator_cache/sim_cache_test.cc
|
2015-08-04 03:42:55 +00:00
|
|
|
utilities/table_properties_collectors/compact_on_deletion_collector_test.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
utilities/transactions/optimistic_transaction_test.cc
|
Pessimistic Transactions
Summary:
Initial implementation of Pessimistic Transactions. This diff contains the api changes discussed in D38913. This diff is pretty large, so let me know if people would prefer to meet up to discuss it.
MyRocks folks: please take a look at the API in include/rocksdb/utilities/transaction[_db].h and let me know if you have any issues.
Also, you'll notice a couple of TODOs in the implementation of RollbackToSavePoint(). After chatting with Siying, I'm going to send out a separate diff for an alternate implementation of this feature that implements the rollback inside of WriteBatch/WriteBatchWithIndex. We can then decide which route is preferable.
Next, I'm planning on doing some perf testing and then integrating this diff into MongoRocks for further testing.
Test Plan: Unit tests, db_bench parallel testing.
Reviewers: igor, rven, sdong, yhchiang, yoshinorim
Reviewed By: sdong
Subscribers: hermanlee4, maykov, spetrunia, leveldb, dhruba
Differential Revision: https://reviews.facebook.net/D40869
2015-05-26 00:37:33 +00:00
|
|
|
utilities/transactions/transaction_test.cc
|
2020-10-19 17:12:53 +00:00
|
|
|
utilities/transactions/lock/point/point_lock_manager_test.cc
|
Support user-defined timestamps in write-committed txns (#9629)
Summary:
Pull Request resolved: https://github.com/facebook/rocksdb/pull/9629
Pessimistic transactions use pessimistic concurrency control, i.e. locking. Keys are
locked upon first operation that writes the key or has the intention of writing. For example,
`PessimisticTransaction::Put()`, `PessimisticTransaction::Delete()`,
`PessimisticTransaction::SingleDelete()` will write to or delete a key, while
`PessimisticTransaction::GetForUpdate()` is used by application to indicate
to RocksDB that the transaction has the intention of performing write operation later
in the same transaction.
Pessimistic transactions support two-phase commit (2PC). A transaction can be
`Prepared()`'ed and then `Commit()`. The prepare phase is similar to a promise: once
`Prepare()` succeeds, the transaction has acquired the necessary resources to commit.
The resources include locks, persistence of WAL, etc.
Write-committed transaction is the default pessimistic transaction implementation. In
RocksDB write-committed transaction, `Prepare()` will write data to the WAL as a prepare
section. `Commit()` will write a commit marker to the WAL and then write data to the
memtables. While writing to the memtables, different keys in the transaction's write batch
will be assigned different sequence numbers in ascending order.
Until commit/rollback, the transaction holds locks on the keys so that no other transaction
can write to the same keys. Furthermore, the keys' sequence numbers represent the order
in which they are committed and should be made visible. This is convenient for us to
implement support for user-defined timestamps.
Since column families with and without timestamps can co-exist in the same database,
a transaction may or may not involve timestamps. Based on this observation, we add two
optional members to each `PessimisticTransaction`, `read_timestamp_` and
`commit_timestamp_`. If no key in the transaction's write batch has timestamp, then
setting these two variables do not have any effect. For the rest of this commit, we discuss
only the cases when these two variables are meaningful.
read_timestamp_ is used mainly for validation, and should be set before first call to
`GetForUpdate()`. Otherwise, the latter will return non-ok status. `GetForUpdate()` calls
`TryLock()` that can verify if another transaction has written the same key since
`read_timestamp_` till this call to `GetForUpdate()`. If another transaction has indeed
written the same key, then validation fails, and RocksDB allows this transaction to
refine `read_timestamp_` by increasing it. Note that a transaction can still use `Get()`
with a different timestamp to read, but the result of the read should not be used to
determine data that will be written later.
commit_timestamp_ must be set after finishing writing and before transaction commit.
This applies to both 2PC and non-2PC cases. In the case of 2PC, it's usually set after
prepare phase succeeds.
We currently require that the commit timestamp be chosen after all keys are locked. This
means we disallow the `TransactionDB`-level APIs if user-defined timestamp is used
by the transaction. Specifically, calling `PessimisticTransactionDB::Put()`,
`PessimisticTransactionDB::Delete()`, `PessimisticTransactionDB::SingleDelete()`,
etc. will return non-ok status because they specify timestamps before locking the keys.
Users are also prompted to use the `Transaction` APIs when they receive the non-ok status.
Reviewed By: ltamasi
Differential Revision: D31822445
fbshipit-source-id: b82abf8e230216dc89cc519564a588224a88fd43
2022-03-09 00:20:59 +00:00
|
|
|
utilities/transactions/write_committed_transaction_ts_test.cc
|
2017-08-31 16:27:14 +00:00
|
|
|
utilities/transactions/write_prepared_transaction_test.cc
|
2018-06-01 21:57:55 +00:00
|
|
|
utilities/transactions/write_unprepared_transaction_test.cc
|
2020-12-23 03:10:56 +00:00
|
|
|
utilities/transactions/lock/range/range_locking_test.cc
|
Snapshots with user-specified timestamps (#9879)
Summary:
In RocksDB, keys are associated with (internal) sequence numbers which denote when the keys are written
to the database. Sequence numbers in different RocksDB instances are unrelated, thus not comparable.
It is nice if we can associate sequence numbers with their corresponding actual timestamps. One thing we can
do is to support user-defined timestamp, which allows the applications to specify the format of custom timestamps
and encode a timestamp with each key. More details can be found at https://github.com/facebook/rocksdb/wiki/User-defined-Timestamp-%28Experimental%29.
This PR provides a different but complementary approach. We can associate rocksdb snapshots (defined in
https://github.com/facebook/rocksdb/blob/7.2.fb/include/rocksdb/snapshot.h#L20) with **user-specified** timestamps.
Since a snapshot is essentially an object representing a sequence number, this PR establishes a bi-directional mapping between sequence numbers and timestamps.
In the past, snapshots are usually taken by readers. The current super-version is grabbed, and a `rocksdb::Snapshot`
object is created with the last published sequence number of the super-version. You can see that the reader actually
has no good idea of what timestamp to assign to this snapshot, because by the time the `GetSnapshot()` is called,
an arbitrarily long period of time may have already elapsed since the last write, which is when the last published
sequence number is written.
This observation motivates the creation of "timestamped" snapshots on the write path. Currently, this functionality is
exposed only to the layer of `TransactionDB`. Application can tell RocksDB to create a snapshot when a transaction
commits, effectively associating the last sequence number with a timestamp. It is also assumed that application will
ensure any two snapshots with timestamps should satisfy the following:
```
snapshot1.seq < snapshot2.seq iff. snapshot1.ts < snapshot2.ts
```
If the application can guarantee that when a reader takes a timestamped snapshot, there is no active writes going on
in the database, then we also allow the user to use a new API `TransactionDB::CreateTimestampedSnapshot()` to create
a snapshot with associated timestamp.
Code example
```cpp
// Create a timestamped snapshot when committing transaction.
txn->SetCommitTimestamp(100);
txn->SetSnapshotOnNextOperation();
txn->Commit();
// A wrapper API for convenience
Status Transaction::CommitAndTryCreateSnapshot(
std::shared_ptr<TransactionNotifier> notifier,
TxnTimestamp ts,
std::shared_ptr<const Snapshot>* ret);
// Create a timestamped snapshot if caller guarantees no concurrent writes
std::pair<Status, std::shared_ptr<const Snapshot>> snapshot = txn_db->CreateTimestampedSnapshot(100);
```
The snapshots created in this way will be managed by RocksDB with ref-counting and potentially shared with
other readers. We provide the following APIs for readers to retrieve a snapshot given a timestamp.
```cpp
// Return the timestamped snapshot correponding to given timestamp. If ts is
// kMaxTxnTimestamp, then we return the latest timestamped snapshot if present.
// Othersise, we return the snapshot whose timestamp is equal to `ts`. If no
// such snapshot exists, then we return null.
std::shared_ptr<const Snapshot> TransactionDB::GetTimestampedSnapshot(TxnTimestamp ts) const;
// Return the latest timestamped snapshot if present.
std::shared_ptr<const Snapshot> TransactionDB::GetLatestTimestampedSnapshot() const;
```
We also provide two additional APIs for stats collection and reporting purposes.
```cpp
Status TransactionDB::GetAllTimestampedSnapshots(
std::vector<std::shared_ptr<const Snapshot>>& snapshots) const;
// Return timestamped snapshots whose timestamps fall in [ts_lb, ts_ub) and store them in `snapshots`.
Status TransactionDB::GetTimestampedSnapshots(
TxnTimestamp ts_lb,
TxnTimestamp ts_ub,
std::vector<std::shared_ptr<const Snapshot>>& snapshots) const;
```
To prevent the number of timestamped snapshots from growing infinitely, we provide the following API to release
timestamped snapshots whose timestamps are older than or equal to a given threshold.
```cpp
void TransactionDB::ReleaseTimestampedSnapshotsOlderThan(TxnTimestamp ts);
```
Before shutdown, RocksDB will release all timestamped snapshots.
Comparison with user-defined timestamp and how they can be combined:
User-defined timestamp persists every key with a timestamp, while timestamped snapshots maintain a volatile
mapping between snapshots (sequence numbers) and timestamps.
Different internal keys with the same user key but different timestamps will be treated as different by compaction,
thus a newer version will not hide older versions (with smaller timestamps) unless they are eligible for garbage collection.
In contrast, taking a timestamped snapshot at a certain sequence number and timestamp prevents all the keys visible in
this snapshot from been dropped by compaction. Here, visible means (seq < snapshot and most recent).
The timestamped snapshot supports the semantics of reading at an exact point in time.
Timestamped snapshots can also be used with user-defined timestamp.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/9879
Test Plan:
```
make check
TEST_TMPDIR=/dev/shm make crash_test_with_txn
```
Reviewed By: siying
Differential Revision: D35783919
Pulled By: riversand963
fbshipit-source-id: 586ad905e169189e19d3bfc0cb0177a7239d1bd4
2022-06-10 23:07:03 +00:00
|
|
|
utilities/transactions/timestamped_snapshot_test.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
utilities/ttl/ttl_test.cc
|
2022-02-19 02:18:49 +00:00
|
|
|
utilities/util_merge_operators_test.cc
|
2015-07-01 23:13:49 +00:00
|
|
|
utilities/write_batch_with_index/write_batch_with_index_test.cc
|
2022-12-31 00:55:58 +00:00
|
|
|
${PLUGIN_TESTS}
|
2020-06-13 00:04:35 +00:00
|
|
|
)
|
|
|
|
endif()
|
2015-10-20 20:35:08 +00:00
|
|
|
|
2017-08-29 01:36:35 +00:00
|
|
|
set(TESTUTIL_SOURCE
|
|
|
|
db/db_test_util.cc
|
2022-05-20 01:39:41 +00:00
|
|
|
db/db_with_timestamp_test_util.cc
|
2017-08-29 01:36:35 +00:00
|
|
|
monitoring/thread_status_updater_debug.cc
|
|
|
|
table/mock_table.cc
|
2022-04-16 06:24:05 +00:00
|
|
|
utilities/agg_merge/test_agg_merge.cc
|
2017-08-29 01:36:35 +00:00
|
|
|
utilities/cassandra/test_utils.cc
|
|
|
|
)
|
|
|
|
enable_testing()
|
2023-12-18 21:17:45 +00:00
|
|
|
add_custom_target(rocksdb_check COMMAND ${CMAKE_CTEST_COMMAND})
|
2017-08-29 01:36:35 +00:00
|
|
|
set(TESTUTILLIB testutillib${ARTIFACT_SUFFIX})
|
|
|
|
add_library(${TESTUTILLIB} STATIC ${TESTUTIL_SOURCE})
|
2022-09-12 04:40:11 +00:00
|
|
|
target_link_libraries(${TESTUTILLIB} ${ROCKSDB_LIB} ${FOLLY_LIBS})
|
2017-08-29 01:36:35 +00:00
|
|
|
if(MSVC)
|
|
|
|
set_target_properties(${TESTUTILLIB} PROPERTIES COMPILE_FLAGS "/Fd${CMAKE_CFG_INTDIR}/testutillib${ARTIFACT_SUFFIX}.pdb")
|
|
|
|
endif()
|
|
|
|
set_target_properties(${TESTUTILLIB}
|
|
|
|
PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD_RELEASE 1
|
|
|
|
EXCLUDE_FROM_DEFAULT_BUILD_MINRELEASE 1
|
|
|
|
EXCLUDE_FROM_DEFAULT_BUILD_RELWITHDEBINFO 1
|
2020-04-20 20:21:34 +00:00
|
|
|
)
|
2017-08-29 01:36:35 +00:00
|
|
|
|
2019-12-13 19:33:59 +00:00
|
|
|
foreach(sourcefile ${TESTS})
|
2017-08-29 01:36:35 +00:00
|
|
|
get_filename_component(exename ${sourcefile} NAME_WE)
|
2021-06-01 21:42:06 +00:00
|
|
|
add_executable(${exename}${ARTIFACT_SUFFIX} ${sourcefile})
|
|
|
|
set_target_properties(${exename}${ARTIFACT_SUFFIX}
|
2017-08-29 01:36:35 +00:00
|
|
|
PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD_RELEASE 1
|
|
|
|
EXCLUDE_FROM_DEFAULT_BUILD_MINRELEASE 1
|
|
|
|
EXCLUDE_FROM_DEFAULT_BUILD_RELWITHDEBINFO 1
|
2018-01-16 22:13:38 +00:00
|
|
|
OUTPUT_NAME ${exename}${ARTIFACT_SUFFIX}
|
2020-04-20 20:21:34 +00:00
|
|
|
)
|
2021-06-01 21:42:06 +00:00
|
|
|
target_link_libraries(${exename}${ARTIFACT_SUFFIX} testutillib${ARTIFACT_SUFFIX} testharness gtest ${THIRDPARTY_LIBS} ${ROCKSDB_LIB})
|
2017-08-29 01:36:35 +00:00
|
|
|
if(NOT "${exename}" MATCHES "db_sanity_test")
|
2021-06-14 23:30:36 +00:00
|
|
|
gtest_discover_tests(${exename} DISCOVERY_TIMEOUT 120)
|
2023-12-18 21:17:45 +00:00
|
|
|
add_dependencies(rocksdb_check ${exename}${ARTIFACT_SUFFIX})
|
2017-08-29 01:36:35 +00:00
|
|
|
endif()
|
2019-12-13 19:33:59 +00:00
|
|
|
endforeach(sourcefile ${TESTS})
|
2017-08-29 01:36:35 +00:00
|
|
|
|
2019-12-10 23:19:24 +00:00
|
|
|
if(WIN32)
|
|
|
|
# C executables must link to a shared object
|
|
|
|
if(ROCKSDB_BUILD_SHARED)
|
|
|
|
set(ROCKSDB_LIB_FOR_C ${ROCKSDB_SHARED_LIB})
|
|
|
|
else()
|
|
|
|
set(ROCKSDB_LIB_FOR_C OFF)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(ROCKSDB_LIB_FOR_C ${ROCKSDB_LIB})
|
|
|
|
endif()
|
2017-08-29 01:36:35 +00:00
|
|
|
|
2019-12-10 23:19:24 +00:00
|
|
|
if(ROCKSDB_LIB_FOR_C)
|
|
|
|
set(C_TESTS db/c_test.c)
|
2019-12-13 19:33:59 +00:00
|
|
|
add_executable(c_test db/c_test.c)
|
2020-08-10 17:46:14 +00:00
|
|
|
target_link_libraries(c_test ${ROCKSDB_LIB_FOR_C} testharness)
|
2019-12-13 19:33:59 +00:00
|
|
|
add_test(NAME c_test COMMAND c_test${ARTIFACT_SUFFIX})
|
2023-12-18 21:17:45 +00:00
|
|
|
add_dependencies(rocksdb_check c_test)
|
2019-12-10 23:19:24 +00:00
|
|
|
endif()
|
2017-08-21 21:41:11 +00:00
|
|
|
endif()
|
2017-01-24 18:48:55 +00:00
|
|
|
|
2019-12-09 05:33:23 +00:00
|
|
|
if(WITH_BENCHMARK_TOOLS)
|
2021-03-09 18:36:44 +00:00
|
|
|
add_executable(db_bench${ARTIFACT_SUFFIX}
|
2021-05-12 18:38:03 +00:00
|
|
|
tools/simulated_hybrid_file_system.cc
|
2019-12-09 07:49:32 +00:00
|
|
|
tools/db_bench.cc
|
2019-12-13 19:33:59 +00:00
|
|
|
tools/db_bench_tool.cc)
|
2021-03-09 18:36:44 +00:00
|
|
|
target_link_libraries(db_bench${ARTIFACT_SUFFIX}
|
2020-08-18 01:52:39 +00:00
|
|
|
${ROCKSDB_LIB} ${THIRDPARTY_LIBS})
|
2019-12-13 19:33:59 +00:00
|
|
|
|
2021-03-09 18:36:44 +00:00
|
|
|
add_executable(cache_bench${ARTIFACT_SUFFIX}
|
2021-05-19 22:24:37 +00:00
|
|
|
cache/cache_bench.cc
|
|
|
|
cache/cache_bench_tool.cc)
|
2021-03-09 18:36:44 +00:00
|
|
|
target_link_libraries(cache_bench${ARTIFACT_SUFFIX}
|
2022-09-12 04:40:11 +00:00
|
|
|
${ROCKSDB_LIB} ${GFLAGS_LIB} ${FOLLY_LIBS})
|
2019-12-13 19:33:59 +00:00
|
|
|
|
2021-03-09 18:36:44 +00:00
|
|
|
add_executable(memtablerep_bench${ARTIFACT_SUFFIX}
|
2019-12-13 19:33:59 +00:00
|
|
|
memtable/memtablerep_bench.cc)
|
2021-03-09 18:36:44 +00:00
|
|
|
target_link_libraries(memtablerep_bench${ARTIFACT_SUFFIX}
|
2022-09-12 04:40:11 +00:00
|
|
|
${ROCKSDB_LIB} ${GFLAGS_LIB} ${FOLLY_LIBS})
|
2019-12-13 19:33:59 +00:00
|
|
|
|
2021-03-09 18:36:44 +00:00
|
|
|
add_executable(range_del_aggregator_bench${ARTIFACT_SUFFIX}
|
2019-12-13 19:33:59 +00:00
|
|
|
db/range_del_aggregator_bench.cc)
|
2021-03-09 18:36:44 +00:00
|
|
|
target_link_libraries(range_del_aggregator_bench${ARTIFACT_SUFFIX}
|
2022-09-12 04:40:11 +00:00
|
|
|
${ROCKSDB_LIB} ${GFLAGS_LIB} ${FOLLY_LIBS})
|
2019-12-13 19:33:59 +00:00
|
|
|
|
2021-03-09 18:36:44 +00:00
|
|
|
add_executable(table_reader_bench${ARTIFACT_SUFFIX}
|
2019-12-13 19:33:59 +00:00
|
|
|
table/table_reader_bench.cc)
|
2021-03-09 18:36:44 +00:00
|
|
|
target_link_libraries(table_reader_bench${ARTIFACT_SUFFIX}
|
2022-09-12 04:40:11 +00:00
|
|
|
${ROCKSDB_LIB} testharness ${GFLAGS_LIB} ${FOLLY_LIBS})
|
2019-12-13 19:33:59 +00:00
|
|
|
|
2021-03-09 18:36:44 +00:00
|
|
|
add_executable(filter_bench${ARTIFACT_SUFFIX}
|
2019-12-13 19:33:59 +00:00
|
|
|
util/filter_bench.cc)
|
2021-03-09 18:36:44 +00:00
|
|
|
target_link_libraries(filter_bench${ARTIFACT_SUFFIX}
|
2022-09-12 04:40:11 +00:00
|
|
|
${ROCKSDB_LIB} ${GFLAGS_LIB} ${FOLLY_LIBS})
|
2019-12-13 19:33:59 +00:00
|
|
|
|
2021-03-09 18:36:44 +00:00
|
|
|
add_executable(hash_table_bench${ARTIFACT_SUFFIX}
|
2019-12-13 19:33:59 +00:00
|
|
|
utilities/persistent_cache/hash_table_bench.cc)
|
2021-03-09 18:36:44 +00:00
|
|
|
target_link_libraries(hash_table_bench${ARTIFACT_SUFFIX}
|
2022-09-12 04:40:11 +00:00
|
|
|
${ROCKSDB_LIB} ${GFLAGS_LIB} ${FOLLY_LIBS})
|
2019-12-09 05:33:23 +00:00
|
|
|
endif()
|
|
|
|
|
2022-07-27 16:10:18 +00:00
|
|
|
option(WITH_TRACE_TOOLS "build with trace tools" ON)
|
Add support for wide-column point lookups (#10540)
Summary:
The patch adds a new API `GetEntity` that can be used to perform
wide-column point lookups. It also extends the `Get` code path and
the `MemTable` / `MemTableList` and `Version` / `GetContext` logic
accordingly so that wide-column entities can be served from both
memtables and SSTs. If the result of a lookup is a wide-column entity
(`kTypeWideColumnEntity`), it is passed to the application in deserialized
form; if it is a plain old key-value (`kTypeValue`), it is presented as a
wide-column entity with a single default (anonymous) column.
(In contrast, regular `Get` returns plain old key-values as-is, and
returns the value of the default column for wide-column entities, see
https://github.com/facebook/rocksdb/issues/10483 .)
The result of `GetEntity` is a self-contained `PinnableWideColumns` object.
`PinnableWideColumns` contains a `PinnableSlice`, which either stores the
underlying data in its own buffer or holds on to a cache handle. It also contains
a `WideColumns` instance, which indexes the contents of the `PinnableSlice`,
so applications can access the values of columns efficiently.
There are several pieces of functionality which are currently not supported
for wide-column entities: there is currently no `MultiGetEntity` or wide-column
iterator; also, `Merge` and `GetMergeOperands` are not supported, and there
is no `GetEntity` implementation for read-only and secondary instances.
We plan to implement these in future PRs.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/10540
Test Plan: `make check`
Reviewed By: akankshamahajan15
Differential Revision: D38847474
Pulled By: ltamasi
fbshipit-source-id: 42311a34ccdfe88b3775e847a5e2a5296e002b5b
2022-08-19 18:51:12 +00:00
|
|
|
if(WITH_TRACE_TOOLS)
|
2022-10-27 00:02:37 +00:00
|
|
|
add_executable(block_cache_trace_analyzer${ARTIFACT_SUFFIX}
|
2022-07-27 16:10:18 +00:00
|
|
|
tools/block_cache_analyzer/block_cache_trace_analyzer_tool.cc)
|
2022-10-27 00:02:37 +00:00
|
|
|
target_link_libraries(block_cache_trace_analyzer${ARTIFACT_SUFFIX}
|
2022-09-12 04:40:11 +00:00
|
|
|
${ROCKSDB_LIB} ${GFLAGS_LIB} ${FOLLY_LIBS})
|
2022-07-27 16:10:18 +00:00
|
|
|
|
|
|
|
add_executable(trace_analyzer${ARTIFACT_SUFFIX}
|
|
|
|
tools/trace_analyzer.cc)
|
|
|
|
target_link_libraries(trace_analyzer${ARTIFACT_SUFFIX}
|
2022-09-12 04:40:11 +00:00
|
|
|
${ROCKSDB_LIB} ${GFLAGS_LIB} ${FOLLY_LIBS})
|
2022-07-27 16:10:18 +00:00
|
|
|
|
|
|
|
endif()
|
|
|
|
|
2020-03-18 17:57:46 +00:00
|
|
|
if(WITH_CORE_TOOLS OR WITH_TOOLS)
|
2017-08-21 21:41:11 +00:00
|
|
|
add_subdirectory(tools)
|
2020-03-18 17:57:46 +00:00
|
|
|
add_custom_target(core_tools
|
|
|
|
DEPENDS ${core_tool_deps})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_TOOLS)
|
2019-12-09 07:49:32 +00:00
|
|
|
add_subdirectory(db_stress_tool)
|
|
|
|
add_custom_target(tools
|
|
|
|
DEPENDS ${tool_deps})
|
2017-01-24 18:48:55 +00:00
|
|
|
endif()
|
2020-06-19 00:58:24 +00:00
|
|
|
|
|
|
|
option(WITH_EXAMPLES "build with examples" OFF)
|
|
|
|
if(WITH_EXAMPLES)
|
|
|
|
add_subdirectory(examples)
|
|
|
|
endif()
|
2021-07-09 00:50:55 +00:00
|
|
|
|
|
|
|
option(WITH_BENCHMARK "build benchmark tests" OFF)
|
|
|
|
if(WITH_BENCHMARK)
|
|
|
|
add_subdirectory(${PROJECT_SOURCE_DIR}/microbench/)
|
|
|
|
endif()
|