diff --git a/DEFAULT_OPTIONS_HISTORY.md b/DEFAULT_OPTIONS_HISTORY.md index 934fb2123..b066e4a65 100644 --- a/DEFAULT_OPTIONS_HISTORY.md +++ b/DEFAULT_OPTIONS_HISTORY.md @@ -3,4 +3,6 @@ * options.target_file_size_base changes from 2MB to 64MB * options.max_bytes_for_level_base changes from 10MB to 256MB * options.soft_pending_compaction_bytes_limit changes from 0 (disabled) to 64GB -* options.hard_pending_compaction_bytes_limit changes from 0 (disabled) to 256GB \ No newline at end of file +* options.hard_pending_compaction_bytes_limit changes from 0 (disabled) to 256GB +* table_cache_numshardbits changes from 4 to 6 +* max_file_opening_threads changes from 1 to 16 \ No newline at end of file diff --git a/table/table_test.cc b/table/table_test.cc index 9507d9e77..aad646f5b 100644 --- a/table/table_test.cc +++ b/table/table_test.cc @@ -1065,7 +1065,7 @@ void PrefetchRange(TableConstructor* c, Options* opt, const std::vector& keys_not_in_cache, const Status expected_status = Status::OK()) { // reset the cache and reopen the table - table_options->block_cache = NewLRUCache(16 * 1024 * 1024); + table_options->block_cache = NewLRUCache(16 * 1024 * 1024, 4); opt->table_factory.reset(NewBlockBasedTableFactory(*table_options)); const ImmutableCFOptions ioptions2(*opt); ASSERT_OK(c->Reopen(ioptions2)); @@ -1094,7 +1094,7 @@ TEST_F(BlockBasedTableTest, PrefetchTest) { BlockBasedTableOptions table_options; table_options.block_size = 1024; // big enough so we don't ever lose cached values. - table_options.block_cache = NewLRUCache(16 * 1024 * 1024); + table_options.block_cache = NewLRUCache(16 * 1024 * 1024, 4); opt.table_factory.reset(NewBlockBasedTableFactory(table_options)); TableConstructor c(BytewiseComparator()); @@ -1328,7 +1328,7 @@ TEST_F(TableTest, HashIndexTest) { table_options.index_type = BlockBasedTableOptions::kHashSearch; table_options.hash_index_allow_collision = true; table_options.block_size = 1700; - table_options.block_cache = NewLRUCache(1024); + table_options.block_cache = NewLRUCache(1024, 4); options.table_factory.reset(NewBlockBasedTableFactory(table_options)); std::unique_ptr comparator( @@ -1550,7 +1550,7 @@ TEST_F(BlockBasedTableTest, BlockCacheDisabledTest) { options.create_if_missing = true; options.statistics = CreateDBStatistics(); BlockBasedTableOptions table_options; - table_options.block_cache = NewLRUCache(1024); + table_options.block_cache = NewLRUCache(1024, 4); table_options.filter_policy.reset(NewBloomFilterPolicy(10)); options.table_factory.reset(new BlockBasedTableFactory(table_options)); std::vector keys; @@ -1596,7 +1596,7 @@ TEST_F(BlockBasedTableTest, FilterBlockInBlockCache) { // Enable the cache for index/filter blocks BlockBasedTableOptions table_options; - table_options.block_cache = NewLRUCache(1024); + table_options.block_cache = NewLRUCache(1024, 4); table_options.cache_index_and_filter_blocks = true; options.table_factory.reset(new BlockBasedTableFactory(table_options)); std::vector keys; @@ -1679,7 +1679,7 @@ TEST_F(BlockBasedTableTest, FilterBlockInBlockCache) { // -- PART 2: Open with very small block cache // In this test, no block will ever get hit since the block cache is // too small to fit even one entry. - table_options.block_cache = NewLRUCache(1); + table_options.block_cache = NewLRUCache(1, 4); options.statistics = CreateDBStatistics(); options.table_factory.reset(new BlockBasedTableFactory(table_options)); const ImmutableCFOptions ioptions2(options); @@ -1719,7 +1719,7 @@ TEST_F(BlockBasedTableTest, FilterBlockInBlockCache) { c.ResetTableReader(); // -- PART 3: Open table with bloom filter enabled but not in SST file - table_options.block_cache = NewLRUCache(4096); + table_options.block_cache = NewLRUCache(4096, 4); table_options.cache_index_and_filter_blocks = false; options.table_factory.reset(NewBlockBasedTableFactory(table_options)); @@ -1881,7 +1881,7 @@ TEST_F(BlockBasedTableTest, BlockCacheLeak) { BlockBasedTableOptions table_options; table_options.block_size = 1024; // big enough so we don't ever lose cached values. - table_options.block_cache = NewLRUCache(16 * 1024 * 1024); + table_options.block_cache = NewLRUCache(16 * 1024 * 1024, 4); opt.table_factory.reset(NewBlockBasedTableFactory(table_options)); TableConstructor c(BytewiseComparator()); @@ -1915,7 +1915,7 @@ TEST_F(BlockBasedTableTest, BlockCacheLeak) { c.ResetTableReader(); // rerun with different block cache - table_options.block_cache = NewLRUCache(16 * 1024 * 1024); + table_options.block_cache = NewLRUCache(16 * 1024 * 1024, 4); opt.table_factory.reset(NewBlockBasedTableFactory(table_options)); const ImmutableCFOptions ioptions2(opt); ASSERT_OK(c.Reopen(ioptions2)); diff --git a/util/cache.cc b/util/cache.cc index ed9ff870c..c94530e06 100644 --- a/util/cache.cc +++ b/util/cache.cc @@ -520,7 +520,7 @@ void LRUCache::Erase(const Slice& key, uint32_t hash) { } } -static int kNumShardBits = 4; // default values, can be overridden +static int kNumShardBits = 6; // default values, can be overridden class ShardedLRUCache : public Cache { private: diff --git a/util/options.cc b/util/options.cc index 3f35aaea4..3ef6f1ca7 100644 --- a/util/options.cc +++ b/util/options.cc @@ -221,7 +221,7 @@ DBOptions::DBOptions() info_log_level(DEBUG_LEVEL), #endif // NDEBUG max_open_files(5000), - max_file_opening_threads(1), + max_file_opening_threads(16), max_total_wal_size(0), statistics(nullptr), disableDataSync(false), @@ -238,7 +238,7 @@ DBOptions::DBOptions() keep_log_file_num(1000), recycle_log_file_num(0), max_manifest_file_size(std::numeric_limits::max()), - table_cache_numshardbits(4), + table_cache_numshardbits(6), WAL_ttl_seconds(0), WAL_size_limit_MB(0), manifest_preallocation_size(4 * 1024 * 1024), @@ -673,6 +673,8 @@ Options* Options::OldDefaults(int rocksdb_major_version, DBOptions* DBOptions::OldDefaults(int rocksdb_major_version, int rocksdb_minor_version) { + max_file_opening_threads = 1; + table_cache_numshardbits = 4; return this; } diff --git a/util/options_test.cc b/util/options_test.cc index aaa585523..65c478757 100644 --- a/util/options_test.cc +++ b/util/options_test.cc @@ -1270,6 +1270,7 @@ TEST_F(OptionsParserTest, DifferentDefault) { Options old_default_opts46; old_default_opts46.OldDefaults(); ASSERT_EQ(10 * 1048576, old_default_opts46.max_bytes_for_level_base); + ASSERT_EQ(4, old_default_opts46.table_cache_numshardbits); ColumnFamilyOptions old_default_cf_opts; old_default_cf_opts.OldDefaults();