Skip to content

Commit 49d699c

Browse files
authored
[opt](file_cache) Add config to enable base compaction output to file cache (#44497) (#44496)
Previous implementation does not allow the output of base compaction write into file cache, which may have some performance penalty. This commit add a config to make that policy configurable. be.conf `enable_file_cache_keep_base_compaction_output` it is false by default. If your file cache is ample enough to accommodate all the data in your database, enable this option; otherwise, it is recommended to leave it disabled. master branch PR #44497
1 parent b71b35e commit 49d699c

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

be/src/common/config.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -950,8 +950,6 @@ DEFINE_Int32(doris_remote_scanner_thread_pool_thread_num, "48");
950950
// number of s3 scanner thread pool queue size
951951
DEFINE_Int32(doris_remote_scanner_thread_pool_queue_size, "102400");
952952
DEFINE_mInt64(block_cache_wait_timeout_ms, "1000");
953-
DEFINE_mInt64(cache_lock_long_tail_threshold, "1000");
954-
DEFINE_Int64(file_cache_recycle_keys_size, "1000000");
955953

956954
// limit the queue of pending batches which will be sent by a single nodechannel
957955
DEFINE_mInt64(nodechannel_pending_queue_max_bytes, "67108864");
@@ -1043,6 +1041,9 @@ DEFINE_Bool(enable_ttl_cache_evict_using_lru, "true");
10431041
DEFINE_mBool(enbale_dump_error_file, "true");
10441042
// limit the max size of error log on disk
10451043
DEFINE_mInt64(file_cache_error_log_limit_bytes, "209715200"); // 200MB
1044+
DEFINE_mInt64(cache_lock_long_tail_threshold, "1000");
1045+
DEFINE_Int64(file_cache_recycle_keys_size, "1000000");
1046+
DEFINE_mBool(enable_file_cache_keep_base_compaction_output, "false");
10461047

10471048
DEFINE_mInt32(index_cache_entry_stay_time_after_lookup_s, "1800");
10481049
DEFINE_mInt32(inverted_index_cache_stale_sweep_time_sec, "600");

be/src/common/config.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,8 +1004,6 @@ DECLARE_mInt64(nodechannel_pending_queue_max_bytes);
10041004
// The batch size for sending data by brpc streaming client
10051005
DECLARE_mInt64(brpc_streaming_client_batch_bytes);
10061006
DECLARE_mInt64(block_cache_wait_timeout_ms);
1007-
DECLARE_mInt64(cache_lock_long_tail_threshold);
1008-
DECLARE_Int64(file_cache_recycle_keys_size);
10091007

10101008
DECLARE_Bool(enable_brpc_builtin_services);
10111009

@@ -1084,6 +1082,15 @@ DECLARE_Bool(enable_ttl_cache_evict_using_lru);
10841082
DECLARE_mBool(enbale_dump_error_file);
10851083
// limit the max size of error log on disk
10861084
DECLARE_mInt64(file_cache_error_log_limit_bytes);
1085+
DECLARE_mInt64(cache_lock_long_tail_threshold);
1086+
DECLARE_Int64(file_cache_recycle_keys_size);
1087+
// Base compaction may retrieve and produce some less frequently accessed data,
1088+
// potentially affecting the file cache hit rate.
1089+
// This configuration determines whether to retain the output within the file cache.
1090+
// Make your choice based on the following considerations:
1091+
// If your file cache is ample enough to accommodate all the data in your database,
1092+
// enable this option; otherwise, it is recommended to leave it disabled.
1093+
DECLARE_mBool(enable_file_cache_keep_base_compaction_output);
10871094

10881095
// inverted index searcher cache
10891096
// cache entry stay time after lookup

be/src/olap/compaction.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,8 +1181,12 @@ Status CloudCompactionMixin::construct_output_rowset_writer(RowsetWriterContext&
11811181
ctx.compaction_level = _engine.cumu_compaction_policy(compaction_policy)
11821182
->new_compaction_level(_input_rowsets);
11831183
}
1184-
1185-
ctx.write_file_cache = compaction_type() == ReaderType::READER_CUMULATIVE_COMPACTION;
1184+
// We presume that the data involved in cumulative compaction is sufficiently 'hot'
1185+
// and should always be retained in the cache.
1186+
// TODO(gavin): Ensure that the retention of hot data is implemented with precision.
1187+
ctx.write_file_cache = (compaction_type() == ReaderType::READER_CUMULATIVE_COMPACTION) ||
1188+
(config::enable_file_cache_keep_base_compaction_output &&
1189+
compaction_type() == ReaderType::READER_BASE_COMPACTION);
11861190
ctx.file_cache_ttl_sec = _tablet->ttl_seconds();
11871191
_output_rs_writer = DORIS_TRY(_tablet->create_rowset_writer(ctx, _is_vertical));
11881192
RETURN_IF_ERROR(_engine.meta_mgr().prepare_rowset(*_output_rs_writer->rowset_meta().get()));

0 commit comments

Comments
 (0)