Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update default behavior for max threads PA async mode #737

Merged
merged 4 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/c++/perf_analyzer/command_line_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1715,7 +1715,8 @@ CLParser::ParseCommandLine(int argc, char** argv)

// Overriding the max_threads default for request_rate search
if (!params_->max_threads_specified && params_->targeting_concurrency()) {
params_->max_threads = 16;
params_->max_threads =
dyastremsky marked this conversation as resolved.
Show resolved Hide resolved
std::max(DEFAULT_MAX_THREADS, params_->concurrency_range.end);
}

if (params_->using_custom_intervals) {
Expand Down
1 change: 1 addition & 0 deletions src/c++/perf_analyzer/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ constexpr static const uint32_t STABILITY_ERROR = 2;
constexpr static const uint32_t OPTION_ERROR = 3;

constexpr static const uint32_t GENERIC_ERROR = 99;
constexpr static const size_t DEFAULT_MAX_THREADS = 16;

const double DELAY_PCT_THRESHOLD{1.0};

Expand Down
89 changes: 82 additions & 7 deletions src/c++/perf_analyzer/test_command_line_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,12 @@ class TestCLParser : public CLParser {
void
CheckValidRange(
std::vector<char*>& args, char* option_name, TestCLParser& parser,
PAParamsPtr& act, bool& using_range, Range<uint64_t>& range)
PAParamsPtr& act, bool& using_range, Range<uint64_t>& range,
size_t* max_threads)
{
SUBCASE("start:end provided")
{
*max_threads = 400;
args.push_back(option_name);
args.push_back("100:400"); // start:end

Expand All @@ -392,6 +394,7 @@ CheckValidRange(

SUBCASE("start:end:step provided")
{
*max_threads = 400;
args.push_back(option_name);
args.push_back("100:400:10"); // start:end:step

Expand Down Expand Up @@ -525,7 +528,7 @@ TEST_CASE("Testing Command Line Parser")

// Most common defaults
exp->model_name = model_name; // model_name;
exp->max_threads = 16;
exp->max_threads = DEFAULT_MAX_THREADS;

SUBCASE("with no parameters")
{
Expand Down Expand Up @@ -1111,11 +1114,14 @@ TEST_CASE("Testing Command Line Parser")
SUBCASE("Option : --concurrency-range")
{
char* option_name = "--concurrency-range";
uint64_t concurrency_range_start;
uint64_t concurrency_range_end;

SUBCASE("start provided")
{
concurrency_range_start = 100;
args.push_back(option_name);
args.push_back("100"); // start
args.push_back(std::to_string(concurrency_range_start).data()); // start

int argc = args.size();
char* argv[argc];
Expand All @@ -1125,13 +1131,13 @@ TEST_CASE("Testing Command Line Parser")
CHECK(!parser.UsageCalled());

exp->using_concurrency_range = true;
exp->concurrency_range.start = 100;
exp->concurrency_range.start = concurrency_range_start;
exp->max_threads = DEFAULT_MAX_THREADS;
}

CheckValidRange(
args, option_name, parser, act, exp->using_concurrency_range,
exp->concurrency_range);

exp->concurrency_range, &(exp->max_threads));
CheckInvalidRange(args, option_name, parser, act, check_params);

SUBCASE("wrong separator")
Expand Down Expand Up @@ -1173,6 +1179,75 @@ TEST_CASE("Testing Command Line Parser")

check_params = false;
}

concurrency_range_start = 10;
SUBCASE("Max threads set to default when concurrency-range.end < 16")
{
concurrency_range_end = 10;
std::string concurrency_range_str =
std::to_string(concurrency_range_start) + ":" +
std::to_string(concurrency_range_end);
args.push_back(option_name);
args.push_back(concurrency_range_str.data());

int argc = args.size();
char* argv[argc];
std::copy(args.begin(), args.end(), argv);

REQUIRE_NOTHROW(act = parser.Parse(argc, argv));
CHECK(!parser.UsageCalled());

exp->using_concurrency_range = true;
exp->concurrency_range.start = concurrency_range_start;
exp->concurrency_range.end = concurrency_range_end;
exp->max_threads = DEFAULT_MAX_THREADS;
}

SUBCASE("Max_threads set to default when concurrency-range.end = 16")
{
concurrency_range_end = 16;
std::string concurrency_range_str =
std::to_string(concurrency_range_start) + ":" +
std::to_string(concurrency_range_end);
args.push_back(option_name);
args.push_back(concurrency_range_str.data());

int argc = args.size();
char* argv[argc];
std::copy(args.begin(), args.end(), argv);

REQUIRE_NOTHROW(act = parser.Parse(argc, argv));
CHECK(!parser.UsageCalled());

exp->using_concurrency_range = true;
exp->concurrency_range.start = concurrency_range_start;
exp->concurrency_range.end = concurrency_range_end;
exp->max_threads = DEFAULT_MAX_THREADS;
}

SUBCASE(
"Max_threads set to concurrency-range.end when concurrency-range.end > "
"16")
{
concurrency_range_end = 40;
std::string concurrency_range_str =
std::to_string(concurrency_range_start) + ":" +
std::to_string(concurrency_range_end);
args.push_back(option_name);
args.push_back(concurrency_range_str.data());

int argc = args.size();
char* argv[argc];
std::copy(args.begin(), args.end(), argv);

REQUIRE_NOTHROW(act = parser.Parse(argc, argv));
CHECK(!parser.UsageCalled());

exp->using_concurrency_range = true;
exp->concurrency_range.start = concurrency_range_start;
exp->concurrency_range.end = concurrency_range_end;
exp->max_threads = exp->concurrency_range.end;
}
}

SUBCASE("Option : --periodic-concurrency-range")
Expand Down Expand Up @@ -1210,7 +1285,7 @@ TEST_CASE("Testing Command Line Parser")

CheckValidRange(
args, option_name, parser, act, exp->is_using_periodic_concurrency_mode,
exp->periodic_concurrency_range);
exp->periodic_concurrency_range, &(exp->max_threads));

CheckInvalidRange(args, option_name, parser, act, check_params);

Expand Down
Loading