Skip to content

Commit

Permalink
Add SEParallelConcurrencyController mode to conformance stresstest
Browse files Browse the repository at this point in the history
Reviewed By: robertroeser

Differential Revision: D63459838

fbshipit-source-id: 583c90b0efd55efd7a1d3fc2a48ae31fc2852707
  • Loading branch information
ot authored and facebook-github-bot committed Sep 27, 2024
1 parent 4788293 commit 883b971
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions thrift/conformance/stresstest/server/StressTestServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <rroeser/scripts/src/executor/WorkStealingExecutor.h>
#include <folly/executors/CPUThreadPoolExecutor.h>
#include <thrift/lib/cpp2/server/ParallelConcurrencyController.h>
#include <thrift/lib/cpp2/server/SEParallelConcurrencyController.h>
#include <thrift/lib/cpp2/server/ThriftServer.h>

DEFINE_int32(port, 5000, "Server port");
Expand All @@ -44,6 +45,10 @@ DEFINE_bool(
false,
"Enable work stealing test without request pile or concurrency controller."
" Implies --work_stealing and --enable_resource_pools");
DEFINE_bool(
se_parallel_concurrency_controller,
false,
"Enable SEParallelConcurrencyController. Implies --enable_resource_pools");
DEFINE_string(
certPath,
"folly/io/async/test/certs/tests-cert.pem",
Expand All @@ -70,7 +75,8 @@ namespace {
bool enableResourcePools() {
// These flags explicitly or implicitly enable resource pools.
return FLAGS_enable_resource_pools || FLAGS_work_stealing ||
FLAGS_work_stealing_executor_only;
FLAGS_work_stealing_executor_only ||
FLAGS_se_parallel_concurrency_controller;
}

bool enableWorkStealing() {
Expand Down Expand Up @@ -168,9 +174,9 @@ std::shared_ptr<ThriftServer> createStressTestServer(
std::shared_ptr<folly::Executor> executor;
std::unique_ptr<RequestPileInterface> requestPile;
std::unique_ptr<ConcurrencyControllerInterface> concurrencyController;
auto t = sanitizeNumThreads(FLAGS_cpu_threads);
if (enableWorkStealing()) {
LOG(INFO) << "Work stealing executor enabled";
auto t = sanitizeNumThreads(FLAGS_cpu_threads);
executor = std::make_shared<folly::WorkStealingExecutor>(t, 4 * t);
if (FLAGS_work_stealing_executor_only) {
LOG(INFO) << "Request pile and concurrency controller disabled";
Expand All @@ -181,6 +187,14 @@ std::shared_ptr<ThriftServer> createStressTestServer(
concurrencyController = std::make_unique<ParallelConcurrencyController>(
*requestPile.get(), *executor.get());
}
} else if (FLAGS_se_parallel_concurrency_controller) {
LOG(INFO) << "SEParallelConcurrencyController enabled";
executor = std::make_shared<folly::CPUThreadPoolExecutor>(
t, folly::CPUThreadPoolExecutor::makeThrottledLifoSemQueue());
RoundRobinRequestPile::Options options;
requestPile = std::make_unique<RoundRobinRequestPile>(std::move(options));
concurrencyController = std::make_unique<SEParallelConcurrencyController>(
*requestPile.get(), *executor.get());
}

server->resourcePoolSet().setResourcePool(
Expand Down

0 comments on commit 883b971

Please sign in to comment.