From 70869735d7e6575d3df40bb913ba4475ecd9dc5a Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 29 Nov 2022 12:23:58 +0100 Subject: [PATCH] blinktree: Start measurement via task to avoid measuring worker thread creation. --- .../blinktree_benchmark/benchmark.cpp | 31 +++++++++++++------ .../blinktree/blinktree_benchmark/benchmark.h | 27 ++++++++++++++++ 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/repos/mml/src/app/blinktree/blinktree_benchmark/benchmark.cpp b/repos/mml/src/app/blinktree/blinktree_benchmark/benchmark.cpp index c081cc56f9..d0c124e05e 100644 --- a/repos/mml/src/app/blinktree/blinktree_benchmark/benchmark.cpp +++ b/repos/mml/src/app/blinktree/blinktree_benchmark/benchmark.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include using namespace application::blinktree_benchmark; @@ -57,6 +58,9 @@ void Benchmark::start() this->_request_scheduler.clear(); } + auto *start_task = mx::tasking::runtime::new_task(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(static_cast(this->_workload)), - this->_current_iteration + 1, this->_cores.current()); + /*his->_chronometer.start(static_cast(static_cast(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) diff --git a/repos/mml/src/app/blinktree/blinktree_benchmark/benchmark.h b/repos/mml/src/app/blinktree/blinktree_benchmark/benchmark.h index c00f2d2d1e..44f1cf9454 100644 --- a/repos/mml/src/app/blinktree/blinktree_benchmark/benchmark.h +++ b/repos/mml/src/app/blinktree/blinktree_benchmark/benchmark.h @@ -14,6 +14,10 @@ #include #include #include +#include + +#include +#include 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(static_cast(_benchmark._workload)), _benchmark._current_iteration + 1, _benchmark._cores.current()); + //_benchmark._start = Genode::Trace::timestamp(); + return mx::tasking::TaskResult::make_remove(); + } }; } // namespace application::blinktree_benchmark \ No newline at end of file