diff options
| author | eIBart0 <eIBart0@users.noreply.github.com> | 2026-11-21 19:29:37 +0000 |
|---|---|---|
| committer | eIBart0 <eIBart0@users.noreply.github.com> | 2026-11-21 19:29:37 +0000 |
| commit | 8cfbdc21cc62500e2d5ee47c8b0afd915a3f450d (patch) | |
| tree | 211d324d38a71143e69f1fd9c7ad5db64b7c08a6 /runtime | |
| parent | ca801d9419e27948afab48bd4b677e279b20781b (diff) | |
Runtime: wake vk_pipeline_check watchdog via condition_variable on completion
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/test/vk_pipeline_check.cpp | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/runtime/test/vk_pipeline_check.cpp b/runtime/test/vk_pipeline_check.cpp index 6e7e61730..b1a9c718d 100644 --- a/runtime/test/vk_pipeline_check.cpp +++ b/runtime/test/vk_pipeline_check.cpp | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include <atomic> | 19 | #include <atomic> |
| 20 | #include <cctype> | 20 | #include <cctype> |
| 21 | #include <chrono> | 21 | #include <chrono> |
| 22 | #include <condition_variable> | ||
| 22 | #include <cstdio> | 23 | #include <cstdio> |
| 23 | #include <cstring> | 24 | #include <cstring> |
| 24 | #include <fstream> | 25 | #include <fstream> |
| @@ -758,22 +759,32 @@ int main(int argc, char** argv) { | |||
| 758 | std::vector<std::thread> pool; | 759 | std::vector<std::thread> pool; |
| 759 | for (uint32_t t = 0; t < jobs; t++) pool.emplace_back(worker); | 760 | for (uint32_t t = 0; t < jobs; t++) pool.emplace_back(worker); |
| 760 | // Watchdog: names every compile running past 60 s (about once a minute) and saves the cache every 10 minutes. | 761 | // Watchdog: names every compile running past 60 s (about once a minute) and saves the cache every 10 minutes. |
| 762 | std::condition_variable watch_cv; | ||
| 763 | bool all_done = false; | ||
| 761 | std::thread watch([&] { | 764 | std::thread watch([&] { |
| 762 | auto last_save = std::chrono::steady_clock::now(); | 765 | auto last_save = std::chrono::steady_clock::now(); |
| 763 | while (done < work.size()) { | 766 | std::unique_lock<std::mutex> g(mu); |
| 764 | std::this_thread::sleep_for(std::chrono::seconds(5)); | 767 | while (!all_done) { |
| 768 | if (watch_cv.wait_for(g, std::chrono::seconds(5), [&] { return all_done; })) break; | ||
| 765 | const auto now = std::chrono::steady_clock::now(); | 769 | const auto now = std::chrono::steady_clock::now(); |
| 766 | { | 770 | for (auto& [tid, job] : inflight) { |
| 767 | std::lock_guard<std::mutex> g(mu); | 771 | const double s = std::chrono::duration<double>(now - job.second).count(); |
| 768 | for (auto& [tid, job] : inflight) { | 772 | if (s > 60 && int(s) % 60 < 5) std::fprintf(stderr, " still compiling %s after %.0fs\n", job.first.c_str(), s); |
| 769 | const double s = std::chrono::duration<double>(now - job.second).count(); | 773 | } |
| 770 | if (s > 60 && int(s) % 60 < 5) std::fprintf(stderr, " still compiling %s after %.0fs\n", job.first.c_str(), s); | 774 | if (now - last_save > std::chrono::minutes(10)) { |
| 771 | } | 775 | g.unlock(); |
| 776 | save_cache(false); | ||
| 777 | g.lock(); | ||
| 778 | last_save = now; | ||
| 772 | } | 779 | } |
| 773 | if (now - last_save > std::chrono::minutes(10)) { save_cache(false); last_save = now; } | ||
| 774 | } | 780 | } |
| 775 | }); | 781 | }); |
| 776 | for (auto& t : pool) t.join(); | 782 | for (auto& t : pool) t.join(); |
| 783 | { | ||
| 784 | std::lock_guard<std::mutex> g(mu); | ||
| 785 | all_done = true; | ||
| 786 | } | ||
| 787 | watch_cv.notify_one(); | ||
| 777 | watch.join(); | 788 | watch.join(); |
| 778 | 789 | ||
| 779 | for (auto& [_, mod] : stub_cache) if (mod) vkDestroyShaderModule(dev, mod, nullptr); | 790 | for (auto& [_, mod] : stub_cache) if (mod) vkDestroyShaderModule(dev, mod, nullptr); |