-
Notifications
You must be signed in to change notification settings - Fork 540
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement additional fanout for SRRoute
Summary: as title Reviewed By: disylh Differential Revision: D61860873 fbshipit-source-id: f78632c33c1919aeef4fea66b97ce16fdff0fabe
- Loading branch information
1 parent
53dd319
commit d80da5d
Showing
4 changed files
with
74 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#include "mcrouter/routes/RoutingUtils.h" | ||
|
||
#include <folly/json/dynamic.h> | ||
#include "mcrouter/lib/fbi/cpp/util.h" | ||
#include "mcrouter/options.h" | ||
|
||
namespace facebook { | ||
namespace memcache { | ||
namespace mcrouter { | ||
|
||
static constexpr uint32_t kMaxTotalFanout = 32 * 1024; | ||
|
||
uint32_t getAdditionalFanout( | ||
const folly::dynamic& json, | ||
const McrouterOptions& opts) { | ||
auto jAdditionalFanout = json.get_ptr("additional_fanout"); | ||
if (!jAdditionalFanout) { | ||
return 0; | ||
} | ||
|
||
checkLogic(jAdditionalFanout->isInt(), "additional_fanout is not an integer"); | ||
uint32_t additionalFanout = jAdditionalFanout->getInt(); | ||
|
||
checkLogic( | ||
static_cast<uint64_t>(additionalFanout + 1) * | ||
static_cast<uint64_t>(opts.num_proxies) <= | ||
kMaxTotalFanout, | ||
"(additional_fanout={} + 1) * num_proxies={} must be <= {}", | ||
additionalFanout, | ||
opts.num_proxies, | ||
kMaxTotalFanout); | ||
|
||
checkLogic( | ||
additionalFanout == 0 || !opts.thread_affinity, | ||
"additional_fanout is not supported with thread_affinity"); | ||
return additionalFanout; | ||
} | ||
|
||
} // namespace mcrouter | ||
} // namespace memcache | ||
} // namespace facebook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters