diff --git a/HISTORY.md b/HISTORY.md index ac49ef440..b31c855f1 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -22,6 +22,9 @@ * The `skip_filters` parameter to SstFileWriter is now considered deprecated. Use `BlockBasedTableOptions::filter_policy` to control generation of filters. * ClockCache is known to have bugs that could lead to crash or corruption, so should not be used until fixed. Use NewLRUCache instead. +### Default Option Change +* When options.arena_block_size <= 0 (default value 0), still use writer_buffer_size / 8 but cap to 1MB. Too large alloation size might not be friendly to allocator and might cause performance issues in extreme cases. + ## 6.20.0 (04/16/2021) ### Behavior Changes * `ColumnFamilyOptions::sample_for_compression` now takes effect for creation of all block-based tables. Previously it only took effect for block-based tables created by flush. diff --git a/db/column_family.cc b/db/column_family.cc index 356c164af..d8f483908 100644 --- a/db/column_family.cc +++ b/db/column_family.cc @@ -214,7 +214,8 @@ ColumnFamilyOptions SanitizeOptions(const ImmutableDBOptions& db_options, // if user sets arena_block_size, we trust user to use this value. Otherwise, // calculate a proper value from writer_buffer_size; if (result.arena_block_size <= 0) { - result.arena_block_size = result.write_buffer_size / 8; + result.arena_block_size = + std::min(size_t{1024 * 1024}, result.write_buffer_size / 8); // Align up to 4k const size_t align = 4 * 1024; diff --git a/db/column_family_test.cc b/db/column_family_test.cc index 28c572168..09d055184 100644 --- a/db/column_family_test.cc +++ b/db/column_family_test.cc @@ -2286,6 +2286,8 @@ TEST_P(ColumnFamilyTest, SanitizeOptions) { // not a multiple of 4k, round up 4k expected_arena_block_size += 4 * 1024; } + expected_arena_block_size = + std::min(size_t{1024 * 1024}, expected_arena_block_size); ASSERT_EQ(expected_arena_block_size, result.arena_block_size); } } diff --git a/include/rocksdb/advanced_options.h b/include/rocksdb/advanced_options.h index 84a3061b0..c682003a4 100644 --- a/include/rocksdb/advanced_options.h +++ b/include/rocksdb/advanced_options.h @@ -390,7 +390,8 @@ struct AdvancedColumnFamilyOptions { // size of one block in arena memory allocation. // If <= 0, a proper value is automatically calculated (usually 1/8 of - // writer_buffer_size, rounded up to a multiple of 4KB). + // writer_buffer_size, rounded up to a multiple of 4KB, or 1MB which ever is + // smaller). // // There are two additional restriction of the specified size: // (1) size should be in the range of [4096, 2 << 30] and