From 565f39e651df1afdca415d87e5f50b80a3c8bbff Mon Sep 17 00:00:00 2001 From: Stuart Clark Date: Fri, 15 Sep 2023 23:37:46 -0700 Subject: [PATCH] Add core_multiplier_threshold option v2 Summary: Threshold to enable customization of proxy threads using core-multiplier. Reviewed By: alikhtarov Differential Revision: D49329331 fbshipit-source-id: 9562d575ed54d5e72325be4aa875f49969b18d7a --- mcrouter/StandaloneUtils.cpp | 6 +++++- mcrouter/standalone_options_list.h | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/mcrouter/StandaloneUtils.cpp b/mcrouter/StandaloneUtils.cpp index 44638cf49..0d01a0349 100644 --- a/mcrouter/StandaloneUtils.cpp +++ b/mcrouter/StandaloneUtils.cpp @@ -461,7 +461,11 @@ void setupStandaloneMcrouter( standaloneOptions.updateFromDict(standaloneOptionsDict); if (standaloneOptions.core_multiplier > 0) { - libmcrouterOptions.num_proxies *= standaloneOptions.core_multiplier; + auto c = std::thread::hardware_concurrency(); + if (!standaloneOptions.core_multiplier_threshold || + c >= standaloneOptions.core_multiplier_threshold) { + libmcrouterOptions.num_proxies = c * standaloneOptions.core_multiplier; + } } if (libmcrouterOptions.enable_failure_logging) { diff --git a/mcrouter/standalone_options_list.h b/mcrouter/standalone_options_list.h index 3994cd41e..e29508d85 100644 --- a/mcrouter/standalone_options_list.h +++ b/mcrouter/standalone_options_list.h @@ -288,10 +288,18 @@ MCROUTER_OPTION_INTEGER( MCROUTER_OPTION_DOUBLE( double, core_multiplier, - 1.0, + 0.0, "core-multiplier", no_short, - "When > 0, number of proxies used will be num-proxies * core-multiplier") + "When > 0, number of proxies used will be std::hardware_concurrency * core-multiplier") + +MCROUTER_OPTION_INTEGER( + size_t, + core_multiplier_threshold, + 0, + "core-multiplier-threshold", + no_short, + "core-mutiplier logic is applied if the number of cores >= core_multiplier_threshold") #ifdef ADDITIONAL_STANDALONE_OPTIONS_FILE #include ADDITIONAL_STANDALONE_OPTIONS_FILE