gavinchou commented on code in PR #65658:
URL: https://github.com/apache/doris/pull/65658#discussion_r3792325525


##########
be/src/io/cache/block_file_cache_factory.cpp:
##########
@@ -485,3 +502,66 @@ void FileCacheFactory::get_cache_stats_block(Block* block) 
{
 
 } // namespace io
 } // namespace doris
+
+namespace doris::config {
+
+namespace {
+
+/// Capture all mutable async-write fields after a config update into one 
coherent snapshot.
+Status load_async_write_options_from_config(io::AsyncCacheWriteServiceOptions* 
options) {
+    DORIS_CHECK(options != nullptr);
+    options->worker_count = 
static_cast<size_t>(async_file_cache_write_workers_per_disk);
+    return io::resolve_async_file_cache_write_max_pending_bytes_per_disk(
+            async_file_cache_write_max_pending_bytes_per_disk, 
MemInfo::mem_limit(),
+            &options->max_pending_bytes);
+}
+
+/// Forward one changed config field through the explicit factory/service 
update interface.
+/// @param config_name Name used only to identify failures in the log.
+/// @param old_value Previous config value; equal values require no service 
update.
+/// @param new_value Newly accepted config value.
+template <typename T>
+void update_async_write_options(const char* config_name, T old_value, T 
new_value) {
+    if (old_value == new_value) {
+        return;
+    }
+    auto* factory = ExecEnv::GetInstance()->file_cache_factory();
+    if (factory == nullptr) {
+        return;
+    }
+    io::AsyncCacheWriteServiceOptions options;
+    Status status = load_async_write_options_from_config(&options);
+    if (status.ok()) {
+        status = factory->update_async_write_options(options);
+    }
+    if (!status.ok()) {
+        LOG(WARNING) << "Failed to apply async file cache write option " << 
config_name << " from "
+                     << old_value << " to " << new_value << ": " << 
status.to_string();
+    }
+}
+
+} // namespace
+
+DEFINE_ON_UPDATE(enable_async_file_cache_write, [](bool old_value, bool 
new_value) {

Review Comment:
   nothing will happend if nable_async_file_cache_write changed from true to 
false?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to