acelyc111 commented on code in PR #1108: URL: https://github.com/apache/incubator-pegasus/pull/1108#discussion_r947432931
########## src/server/pegasus_server_impl.cpp: ########## @@ -3007,6 +3013,93 @@ void pegasus_server_impl::reset_usage_scenario_options( target_opts->max_write_buffer_number = base_opts.max_write_buffer_number; } +void pegasus_server_impl::recalculate_data_cf_options( + const rocksdb::ColumnFamilyOptions &cur_data_cf_opts) +{ +#define UPDATE_NUMBER_OPTION_IF_NEEDED(option, value) \ + if ((value) != cur_data_cf_opts.option) { \ + new_options[#option] = std::to_string((value)); \ + } +#define UPDATE_BOOL_OPTION_IF_NEEDED(option, value) \ + if ((value) != cur_data_cf_opts.option) { \ + if ((value)) \ + new_options[#option] = "true"; \ + else \ + new_options[#option] = "false"; \ + } + + if (!_is_need_update_data_cf_opts) + return; + std::unordered_map<std::string, std::string> new_options; + if (ROCKSDB_ENV_USAGE_SCENARIO_NORMAL == _usage_scenario || + ROCKSDB_ENV_USAGE_SCENARIO_PREFER_WRITE == _usage_scenario) { + if (ROCKSDB_ENV_USAGE_SCENARIO_NORMAL == _usage_scenario) { + if (!check_value_if_nearby(_data_cf_opts.write_buffer_size, + cur_data_cf_opts.write_buffer_size)) { + new_options["write_buffer_size"] = + std::to_string(get_random_nearby(_data_cf_opts.write_buffer_size)); + } + UPDATE_NUMBER_OPTION_IF_NEEDED(level0_file_num_compaction_trigger, + _data_cf_opts.level0_file_num_compaction_trigger); + } else { + uint64_t buffer_size = dsn::rand::next_u64(_data_cf_opts.write_buffer_size, + _data_cf_opts.write_buffer_size * 2); + if (!(cur_data_cf_opts.write_buffer_size >= _data_cf_opts.write_buffer_size && + cur_data_cf_opts.write_buffer_size <= _data_cf_opts.write_buffer_size * 2)) { + new_options["write_buffer_size"] = std::to_string(buffer_size); + uint64_t max_size = get_random_nearby(_data_cf_opts.max_bytes_for_level_base); + new_options["level0_file_num_compaction_trigger"] = + std::to_string(std::max<uint64_t>(4UL, max_size / buffer_size)); + } else if (!check_value_if_nearby(_data_cf_opts.max_bytes_for_level_base, + cur_data_cf_opts.max_bytes_for_level_base)) { + uint64_t max_size = get_random_nearby(_data_cf_opts.max_bytes_for_level_base); + new_options["level0_file_num_compaction_trigger"] = + std::to_string(std::max<uint64_t>(4UL, max_size / buffer_size)); + } + } + UPDATE_NUMBER_OPTION_IF_NEEDED(level0_slowdown_writes_trigger, + _data_cf_opts.level0_slowdown_writes_trigger); + UPDATE_NUMBER_OPTION_IF_NEEDED(level0_stop_writes_trigger, + _data_cf_opts.level0_stop_writes_trigger); + UPDATE_NUMBER_OPTION_IF_NEEDED(soft_pending_compaction_bytes_limit, + _data_cf_opts.soft_pending_compaction_bytes_limit); + UPDATE_NUMBER_OPTION_IF_NEEDED(hard_pending_compaction_bytes_limit, + _data_cf_opts.hard_pending_compaction_bytes_limit); Review Comment: how about define another macro, to leave only one parameter, change "XXX(xxx, _data_cf_opts.xxx)" to "XXX(xxx)"? -- 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: dev-unsubscr...@pegasus.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pegasus.apache.org For additional commands, e-mail: dev-h...@pegasus.apache.org