From fa002471bf6c600348acf049b645144b09816494 Mon Sep 17 00:00:00 2001 From: Derek Bruening Date: Wed, 23 Oct 2024 13:25:15 -0400 Subject: [PATCH] i#7044 hang: Sleep on wait in parallel drmemtrace analyzer Adds a 1ms sleep on a STATUS_WAIT in the drmemtrace analyzer when operating in parallel. This avoids costly spinning in replay mode. Adding targeted condition variables inside the scheduler doesn't end up performing any better and is complicated by the scheduler not knowing the threading model of the user, so this is a safer and simpler solution despite not waiting on an event. Fixes #7044 --- clients/drcachesim/analyzer.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/clients/drcachesim/analyzer.cpp b/clients/drcachesim/analyzer.cpp index 728648171fa..6f905c10f9e 100644 --- a/clients/drcachesim/analyzer.cpp +++ b/clients/drcachesim/analyzer.cpp @@ -649,6 +649,10 @@ analyzer_tmpl_t::process_tasks_internal( // We synthesize a record here. If we wanted this to count toward output // stream ordinals we would need to add a scheduler API to inject it. record = create_wait_marker(); + if (parallel_) { + // Don't spin on this artificial wait; retry later. + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + } } else if (status == sched_type_t::STATUS_IDLE) { assert(shard_type_ == SHARD_BY_CORE); // We let tools know about idle time so they can analyze cpu usage.