Skip to content

Commit

Permalink
Merge pull request #1399 from msimberg/resume-suspend-start-stop-perf…
Browse files Browse the repository at this point in the history
…ormance-ci

Add start-stop and resume-suspend performance benchmarks to performance CI runs
  • Loading branch information
msimberg authored Feb 4, 2025
2 parents 78a3fc3 + fa3470b commit bea0e73
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 51 deletions.
10 changes: 10 additions & 0 deletions .gitlab/scripts/run_performance_benchmarks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ pika_targets=(
"task_yield_test"
"condition_variable_overhead_test"
"async_rw_mutex_scheduling_test"
"start_stop_test"
"resume_suspend_test"
)
pika_test_options=(
"--pika:ini=pika.thread_queue.init_threads_count=100 \
Expand Down Expand Up @@ -113,6 +115,14 @@ pika_test_options=(
--num-ro-accesses=5
--repetitions=100
--pika:threads=4
--perftest-json"

"--repetitions=100
--pika:threads=4
--perftest-json"

"--repetitions=100
--pika:threads=4
--perftest-json"
)

Expand Down
52 changes: 25 additions & 27 deletions tests/performance/local/resume_suspend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <pika/testing/performance.hpp>
#include <pika/thread.hpp>

#include <fmt/format.h>

#include <cstddef>
#include <cstdint>
#include <iostream>
Expand All @@ -23,18 +25,19 @@ namespace ex = pika::execution::experimental;

int main(int argc, char** argv)
{
pika::program_options::options_description desc_commandline;
desc_commandline.add_options()("repetitions",
pika::program_options::value<std::uint64_t>()->default_value(100), "Number of repetitions");
using namespace pika::program_options;
options_description desc_commandline;
// clang-format off
desc_commandline.add_options()
("repetitions", value<std::uint64_t>()->default_value(100), "Number of repetitions")
("perftest-json", bool_switch(), "Print average resume-suspend time in json format for use with performance CI");
// clang-format on

pika::program_options::variables_map vm;
pika::program_options::store(pika::program_options::command_line_parser(argc, argv)
.allow_unregistered()
.options(desc_commandline)
.run(),
vm);
variables_map vm;
store(command_line_parser(argc, argv).allow_unregistered().options(desc_commandline).run(), vm);

std::uint64_t repetitions = vm["repetitions"].as<std::uint64_t>();
auto const repetitions = vm["repetitions"].as<std::uint64_t>();
auto const perftest_json = vm["perftest-json"].as<bool>();

pika::init_params init_args;
init_args.desc_cmdline = desc_commandline;
Expand All @@ -44,12 +47,9 @@ int main(int argc, char** argv)

std::uint64_t threads = pika::resource::get_num_threads("default");

auto sched = ex::thread_pool_scheduler{};

std::cout << "threads, resume [s], execute [s], suspend [s]" << std::endl;
if (!perftest_json) { std::cout << "threads, resume [s], suspend [s]" << std::endl; }

double suspend_time = 0;
double resume_time = 0;
pika::chrono::detail::high_resolution_timer timer;

for (std::size_t i = 0; i < repetitions; ++i)
Expand All @@ -58,27 +58,25 @@ int main(int argc, char** argv)

pika::resume();
auto t_resume = timer.elapsed();
resume_time += t_resume;

for (std::size_t thread = 0; thread < threads; ++thread)
{
ex::execute(sched, [] {});
}

auto t_execute = timer.elapsed();

pika::suspend();
auto t_suspend = timer.elapsed();
suspend_time += t_suspend;

std::cout << threads << ", " << t_resume << ", " << t_execute << ", " << t_suspend
<< std::endl;
if (!perftest_json)
{
std::cout << threads << ", " << t_resume << ", " << t_suspend << std::endl;
}
}

pika::util::print_cdash_timing("ResumeTime", resume_time);
pika::util::print_cdash_timing("SuspendTime", suspend_time);

pika::resume();
pika::finalize();
pika::stop();

if (perftest_json)
{
pika::util::detail::json_perf_times t;
t.add(fmt::format("resume_suspend - {} threads", threads), suspend_time / repetitions);
std::cout << t;
}
}
49 changes: 25 additions & 24 deletions tests/performance/local/start_stop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <pika/testing/performance.hpp>
#include <pika/thread.hpp>

#include <fmt/format.h>

#include <cstddef>
#include <cstdint>
#include <cstdlib>
Expand All @@ -29,18 +31,19 @@ int pika_main()

int main(int argc, char** argv)
{
pika::program_options::options_description desc_commandline;
desc_commandline.add_options()("repetitions",
pika::program_options::value<std::uint64_t>()->default_value(100), "Number of repetitions");
using namespace pika::program_options;
options_description desc_commandline;
// clang-format off
desc_commandline.add_options()
("repetitions", value<std::uint64_t>()->default_value(100), "Number of repetitions")
("perftest-json", bool_switch(), "Print average start-stop time in json format for use with performance CI");
// clang-format on

pika::program_options::variables_map vm;
pika::program_options::store(pika::program_options::command_line_parser(argc, argv)
.allow_unregistered()
.options(desc_commandline)
.run(),
vm);
variables_map vm;
store(command_line_parser(argc, argv).allow_unregistered().options(desc_commandline).run(), vm);

std::uint64_t repetitions = vm["repetitions"].as<std::uint64_t>();
auto const repetitions = vm["repetitions"].as<std::uint64_t>();
auto const perftest_json = vm["perftest-json"].as<bool>();

pika::init_params init_args;
init_args.desc_cmdline = desc_commandline;
Expand All @@ -49,9 +52,8 @@ int main(int argc, char** argv)
std::uint64_t threads = pika::resource::get_num_threads("default");
pika::stop();

std::cout << "threads, resume [s], execute [s], suspend [s]" << std::endl;
if (!perftest_json) { std::cout << "threads, resume [s], suspend [s]" << std::endl; }

double start_time = 0;
double stop_time = 0;
pika::chrono::detail::high_resolution_timer timer;

Expand All @@ -64,22 +66,21 @@ int main(int argc, char** argv)

pika::start(pika_main, argc, argv, init_args);
auto t_start = timer.elapsed();
start_time += t_start;

auto sched = ex::thread_pool_scheduler{};
for (std::size_t thread = 0; thread < threads; ++thread)
{
ex::execute(sched, [] {});
}

auto t_execute = timer.elapsed();

pika::stop();
auto t_stop = timer.elapsed();
stop_time += t_stop;

std::cout << threads << ", " << t_start << ", " << t_execute << ", " << t_stop << std::endl;
if (!perftest_json)
{
std::cout << threads << ", " << t_start << ", " << t_stop << std::endl;
}
}

if (perftest_json)
{
pika::util::detail::json_perf_times t;
t.add(fmt::format("start_stop - {} threads", threads), stop_time / repetitions);
std::cout << t;
}
pika::util::print_cdash_timing("StartTime", start_time);
pika::util::print_cdash_timing("StopTime", stop_time);
}

0 comments on commit bea0e73

Please sign in to comment.