blinktree: Start measurement via task to avoid measuring worker thread creation.

This commit is contained in:
Michael Mueller
2022-11-29 12:23:58 +01:00
parent 195be5ff6e
commit 70869735d7
2 changed files with 49 additions and 9 deletions

View File

@@ -5,6 +5,7 @@
#include <json.hpp> #include <json.hpp>
#include <memory> #include <memory>
#include <mx/memory/global_heap.h> #include <mx/memory/global_heap.h>
#include <mx/system/topology.h>
#include <base/log.h> #include <base/log.h>
using namespace application::blinktree_benchmark; using namespace application::blinktree_benchmark;
@@ -57,6 +58,9 @@ void Benchmark::start()
this->_request_scheduler.clear(); this->_request_scheduler.clear();
} }
auto *start_task = mx::tasking::runtime::new_task<StartMeasurementTask>(0U, *this);
mx::tasking::runtime::spawn(*start_task, 0U);
// Create one request scheduler per core. // Create one request scheduler per core.
for (auto core_index = 0U; core_index < this->_cores.current().size(); core_index++) for (auto core_index = 0U; core_index < this->_cores.current().size(); core_index++)
{ {
@@ -73,8 +77,9 @@ void Benchmark::start()
{ {
mx::tasking::runtime::profile(this->profile_file_name()); mx::tasking::runtime::profile(this->profile_file_name());
} }
this->_chronometer.start(static_cast<std::uint16_t>(static_cast<benchmark::phase>(this->_workload)), /*his->_chronometer.start(static_cast<std::uint16_t>(static_cast<benchmark::phase>(this->_workload)),
this->_current_iteration + 1, this->_cores.current()); this->_current_iteration + 1, this->_cores.current());*/
//Genode::log("Timer started ");
} }
const mx::util::core_set &Benchmark::core_set() const mx::util::core_set &Benchmark::core_set()
@@ -116,18 +121,26 @@ void Benchmark::requests_finished()
const auto result = this->_chronometer.stop(this->_workload.size()); const auto result = this->_chronometer.stop(this->_workload.size());
mx::tasking::runtime::stop(); mx::tasking::runtime::stop();
Genode::log(result.core_count(), "\t", result.iteration(), "\t", result.phase(), "\t", result.time().count(), " ms\t", result.throughput(), " op/s"); //_end = Genode::Trace::timestamp();
//std::cout << result << std::endl;
//if (mx::system::topology::core_id() == 0)
//std::cout << result << "\t " << (_end - _start) << " cycles" << std::endl;
std::cout << result.to_json().dump() << std::endl;
// std::cout << result << std::endl;
// Dump results to file. // Dump results to file.
/*if (this->_result_file_name.empty() == false) if (this->_result_file_name.empty() == false)
{ {
std::ofstream result_file_stream(this->_result_file_name, std::ofstream::app); //std::ofstream result_file_stream(this->_result_file_name, std::ofstream::app);
result_file_stream << result.to_json().dump() << std::endl; //result_file_stream << result.to_json().dump() << std::endl;
} }
// Dump statistics to file. // Dump statistics to file.
if constexpr (mx::tasking::config::task_statistics()) if constexpr (mx::tasking::config::task_statistics())
{ {
if (this->_statistic_file_name.empty() == false) /*if (this->_statistic_file_name.empty() == false)
{ {
std::ofstream statistic_file_stream(this->_statistic_file_name, std::ofstream::app); std::ofstream statistic_file_stream(this->_statistic_file_name, std::ofstream::app);
nlohmann::json statistic_json; nlohmann::json statistic_json;
@@ -162,8 +175,8 @@ void Benchmark::requests_finished()
} }
statistic_file_stream << statistic_json.dump(2) << std::endl; statistic_file_stream << statistic_json.dump(2) << std::endl;
} }*/
}*/ }
// Check and print the tree. // Check and print the tree.
if (this->_check_tree) if (this->_check_tree)

View File

@@ -14,6 +14,10 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <libc/component.h> #include <libc/component.h>
#include <mx/tasking/task.h>
#include <trace/timestamp.h>
#include <base/log.h>
namespace application::blinktree_benchmark { namespace application::blinktree_benchmark {
/** /**
@@ -22,6 +26,7 @@ namespace application::blinktree_benchmark {
class Benchmark final : public Listener class Benchmark final : public Listener
{ {
public: public:
Benchmark(Libc::Env &env, benchmark::Cores &&, std::uint16_t iterations, std::string &&fill_workload_file, Benchmark(Libc::Env &env, benchmark::Cores &&, std::uint16_t iterations, std::string &&fill_workload_file,
std::string &&mixed_workload_file, bool use_performance_counter, std::string &&mixed_workload_file, bool use_performance_counter,
mx::synchronization::isolation_level node_isolation_level, mx::synchronization::isolation_level node_isolation_level,
@@ -48,6 +53,9 @@ public:
void start(); void start();
private: private:
std::uint64_t _start;
std::uint64_t _end;
// Collection of cores the benchmark should run on. // Collection of cores the benchmark should run on.
benchmark::Cores _cores; benchmark::Cores _cores;
@@ -100,5 +108,24 @@ private:
* @return Name of the file to write profiling results to. * @return Name of the file to write profiling results to.
*/ */
[[nodiscard]] std::string profile_file_name() const; [[nodiscard]] std::string profile_file_name() const;
friend class StartMeasurementTask;
};
class StartMeasurementTask : public mx::tasking::TaskInterface
{
private:
Benchmark &_benchmark;
public:
constexpr StartMeasurementTask(Benchmark& benchmark) : _benchmark(benchmark) {}
~StartMeasurementTask() override = default;
mx::tasking::TaskResult execute(const std::uint16_t core_id, const std::uint16_t channel_id) override
{
_benchmark._chronometer.start(static_cast<std::uint16_t>(static_cast<benchmark::phase>(_benchmark._workload)), _benchmark._current_iteration + 1, _benchmark._cores.current());
//_benchmark._start = Genode::Trace::timestamp();
return mx::tasking::TaskResult::make_remove();
}
}; };
} // namespace application::blinktree_benchmark } // namespace application::blinktree_benchmark