diff options
author | Alessio Balsini <balsini@google.com> | 2024-03-12 11:45:29 +0000 |
---|---|---|
committer | Alessio Balsini <balsini@google.com> | 2024-03-12 12:53:06 +0000 |
commit | 70b969d89efa4d48644781ee79e10c301e3078e2 (patch) | |
tree | 0bc032a5246e1886155ee13a35d96fd28e8d9948 | |
parent | e8cea65741e47490bed5987aeb9d26fb25118821 (diff) | |
download | dittosuite-70b969d89efa4d48644781ee79e10c301e3078e2.tar.gz |
Use name instead of instruction id for spawned tasks
When printing the benchmarking results, instead of reporting the
process/thraed name, Dittobench was only printing the numerical
identifier of the process/thread. This was enough to distinguish the
instructions run from one process/thread to another, but not enough to
understand what process/thread called them.
Additionally, this numerical value was only referring to the id of the
"spawned" processes, so if multiple threads were generated manually, and
each of them was using the default "spawn" value of 1, their reported
instruction identifier would have been "0".
Fix by using the thread name if available, otherwise the instruction
number.
Test: manual check
Change-Id: If3cfbf705dd242f78a51cec995381d964872217f
Signed-off-by: Alessio Balsini <balsini@google.com>
-rw-r--r-- | src/instruction_factory.cpp | 6 | ||||
-rw-r--r-- | src/multiprocessing.cpp | 4 | ||||
-rw-r--r-- | src/multithreading.cpp | 3 |
3 files changed, 8 insertions, 5 deletions
diff --git a/src/instruction_factory.cpp b/src/instruction_factory.cpp index 1ac4433..3112995 100644 --- a/src/instruction_factory.cpp +++ b/src/instruction_factory.cpp @@ -206,7 +206,9 @@ std::unique_ptr<Instruction> InstructionFactory::CreateFromProtoInstruction( std::vector<MultithreadingParams> thread_params; std::vector<std::unique_ptr<Instruction>> instructions; - for (const auto& thread : options.threads()) { + + for (int t = 0; t < options.threads().size(); t++) { + const auto& thread = options.threads()[t]; for (int i = 0; i < thread.spawn(); i++) { auto thread_ids_copy = thread_ids; thread_ids_copy.push_back(InstructionFactory::GenerateThreadId()); @@ -217,7 +219,7 @@ std::unique_ptr<Instruction> InstructionFactory::CreateFromProtoInstruction( if (thread.has_name()) { thread_name = thread.name() + "_" + std::to_string(i); } else { - thread_name = std::to_string(i); + thread_name = std::to_string(t) + "_" + std::to_string(i); } SchedAttr sched_attr(Syscall::GetSyscall()); diff --git a/src/multiprocessing.cpp b/src/multiprocessing.cpp index 0b37b7a..6ab589f 100644 --- a/src/multiprocessing.cpp +++ b/src/multiprocessing.cpp @@ -179,8 +179,8 @@ std::unique_ptr<Result> Multiprocessing::CollectResults(const std::string& prefi } } else { LOGD("Child writing... " + std::to_string(getpid())); - result->AddSubResult( - instructions_[instruction_id_]->CollectResults(std::to_string(instruction_id_) + "/")); + std::string child_name = thread_params_[instruction_id_].name_; + result->AddSubResult(instructions_[instruction_id_]->CollectResults(child_name + "/")); result_pb = result->ToPb(); diff --git a/src/multithreading.cpp b/src/multithreading.cpp index b696d5e..3f685dd 100644 --- a/src/multithreading.cpp +++ b/src/multithreading.cpp @@ -56,7 +56,8 @@ std::unique_ptr<Result> Multithreading::CollectResults(const std::string& prefix auto result = std::make_unique<Result>(prefix + name_, repeat_); result->AddMeasurement("duration", TimespecToDoubleNanos(time_sampler_.GetSamples())); for (std::size_t i = 0; i < instructions_.size(); ++i) { - result->AddSubResult(instructions_[i]->CollectResults(std::to_string(i) + "/")); + std::string child_name = thread_params_[i].name_; + result->AddSubResult(instructions_[i]->CollectResults(child_name + "/")); } return result; } |