mirror of
https://github.com/mmueller41/genode.git
synced 2026-01-21 20:42:56 +01:00
blinktree: Start measurement via task to avoid measuring worker thread creation.
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <json.hpp>
|
||||
#include <memory>
|
||||
#include <mx/memory/global_heap.h>
|
||||
#include <mx/system/topology.h>
|
||||
#include <base/log.h>
|
||||
|
||||
using namespace application::blinktree_benchmark;
|
||||
@@ -57,6 +58,9 @@ void Benchmark::start()
|
||||
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.
|
||||
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());
|
||||
}
|
||||
this->_chronometer.start(static_cast<std::uint16_t>(static_cast<benchmark::phase>(this->_workload)),
|
||||
this->_current_iteration + 1, this->_cores.current());
|
||||
/*his->_chronometer.start(static_cast<std::uint16_t>(static_cast<benchmark::phase>(this->_workload)),
|
||||
this->_current_iteration + 1, this->_cores.current());*/
|
||||
//Genode::log("Timer started ");
|
||||
}
|
||||
|
||||
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());
|
||||
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.
|
||||
/*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);
|
||||
result_file_stream << result.to_json().dump() << std::endl;
|
||||
//std::ofstream result_file_stream(this->_result_file_name, std::ofstream::app);
|
||||
//result_file_stream << result.to_json().dump() << std::endl;
|
||||
}
|
||||
|
||||
// Dump statistics to file.
|
||||
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);
|
||||
nlohmann::json statistic_json;
|
||||
@@ -162,8 +175,8 @@ void Benchmark::requests_finished()
|
||||
}
|
||||
|
||||
statistic_file_stream << statistic_json.dump(2) << std::endl;
|
||||
}
|
||||
}*/
|
||||
}*/
|
||||
}
|
||||
|
||||
// Check and print the tree.
|
||||
if (this->_check_tree)
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <libc/component.h>
|
||||
#include <mx/tasking/task.h>
|
||||
|
||||
#include <trace/timestamp.h>
|
||||
#include <base/log.h>
|
||||
|
||||
namespace application::blinktree_benchmark {
|
||||
/**
|
||||
@@ -22,6 +26,7 @@ namespace application::blinktree_benchmark {
|
||||
class Benchmark final : public Listener
|
||||
{
|
||||
public:
|
||||
|
||||
Benchmark(Libc::Env &env, benchmark::Cores &&, std::uint16_t iterations, std::string &&fill_workload_file,
|
||||
std::string &&mixed_workload_file, bool use_performance_counter,
|
||||
mx::synchronization::isolation_level node_isolation_level,
|
||||
@@ -48,6 +53,9 @@ public:
|
||||
void start();
|
||||
|
||||
private:
|
||||
std::uint64_t _start;
|
||||
std::uint64_t _end;
|
||||
|
||||
// Collection of cores the benchmark should run on.
|
||||
benchmark::Cores _cores;
|
||||
|
||||
@@ -100,5 +108,24 @@ private:
|
||||
* @return Name of the file to write profiling results to.
|
||||
*/
|
||||
[[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
|
||||
Reference in New Issue
Block a user