Speedb Tuning Function
Overview
This feature aims to simplify the configuration process for Speedb storage engine by providing an easy way to enable and set Speedb options to optimized configurations. By introducing the SharedOptions class and specific functions, users can effortlessly configure Speedb's features with minimal manual intervention. Also when running multiple Speedb instances, it allows to configure all of the instances using the same method, and same configuration.
Motivation
Speedb users currently configure the database manually. New Speedb users are required to spend time in order to understand how to enable/disable and actually configure all the relevant options to enjoy the capabilities.
Not all of the capabilities are enabled by default and some need different tuning per workload. The user always has the flexibility to tune the database based on their needs, but in case a user would like to enjoy all of Speedb's benefits, we give the option to let us do the work for you and tune the database or databases to a default and improved configuration, following basic system parameters you provide while using this new method.
Technical Details
SharedOptions Class
The SharedOptions class has been introduced to enhance the usability of Speedb in multiple database scenarios. It organizes shared options, making configuration more streamlined and user-friendly.
Configuration Parameters
To benefit from this feature, users need to provide three key configuration parameters:
Total RAM size for Speedb: Specify the amount of RAM allocated for Speedb operations.
Total number of threads for background jobs: Determine the number of threads allocated for handling background tasks.
Delayed write rate: Set the rate at which delayed writes are performed.
By utilizing the provided functions, Speedb's features can be easily configured to default settings, simplifying the process for users. The default configuration includes the following features:
Proactive Flushing
Global Delayed Write
Sorted Hash Memtable
Dynamic Delayed Writes
Paired bloom filter
Implementation
Struct SharedOptions
Contain the shared configuration for multiple databases group
Write buffer manager
Cache
Write controller
Env;
RateLimiter;
SstFileManager;
Logger;
EventListener;
FileChecksumGenFactory;
Contain the methodology for configuring Speedb features
total_threads
total_ram_size_bytes
delayed_write_rate
Write_buffer_size
Paired bloom filter
class SharedOptions
SharedOptions constructor
Creates a LRU cache Default values for cache’s construction is:
Capacity = _total_ram_size_bytes
Creates a write buffer manager (with proactive flushes) Default values for WBM’s construction is:
_write_buffer_size = 1;
kDfltMaxNumParallelFlushes = 4U;
Creates a write_controller default values for WC’s construction is:
dynamic_delay = true
_delayed_write_rate = 256 * 1024 * 1024ul
EnableSpeedbFeatures function
Call EnableSpeedbFeaturesDB
Call EnableSpeedbFeaturesCF
EnableSpeedbFeaturesDB function
Set TotalThreads;
Set delayed_write_rate;
bytes_per_sync = 1ul << 20;
use_dynamic_delay = true;
Set write_buffer_manager;
Set write_controller;
DBOptions* DBOptions::EnableSpeedbFeaturesDB(SharedOptions& shared_options)
EnableSpeedbFeaturesCF function
Each new column family will ask the write buffer manager to increase the write buffer size by 512 * 1024 * 1024ul
Set cf write_buffer_size min(db_wbf_size / 4, 64ul << 20);
max_write_buffer_number = 32;
min_write_buffer_number_to_merge = max_write_buffer_number - 1;
// set the pinning option for indexes and filters
Set filter to FilterPolicy to speedb.PairedBloomFilter 10 bytes per key
Set cache
Pinned all tables info (index, filter, compression dictionary)
Set unpartitioned_pinning to PinningTier::kAll
Set partition_pinning to PinningTier::kAll
Pinned by set to CacheEntryRoleOptions::Decision::kEnabled
CacheEntryRole::kFilterConstruction
CacheEntryRole::kBlockBasedTableReader
CacheEntryRole::kCompressionDictionaryBuildingBuffer
CacheEntryRole::kFileMetadata
Make sure pinned memory is accounted toward the cache
Set memtable type to speedb.HashSpdRepFactory
ColumnFamilyOptions* ColumnFamilyOptions::EnableSpeedbFeaturesCF(SharedOptions& shared_options)
SharedOptions constructor
Creates a LRU cache default values for cache’s construction is:
Capacity = _total_ram_size_bytes
Creates a write buffer manager (with proactive flushes) default values for WBM’s construction is:
_write_buffer_size = 1;
kDfltMaxNumParallelFlushes = 4U;
Creates a write_controller Default values for WC’s construction is:
dynamic_delay = true
_delayed_write_rate = 256 * 1024 * 1024ul
Usage
Below is an example demonstrating the usage of these functions and enabling Speedb features with default configurations. It is also available in the examples directory /enable_speedb_features_example.cc".
Last updated
Was this helpful?

