From 4f9948d00c4edb2c85608a3134a44a2ff2065529 Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Wed, 11 Nov 2020 17:47:57 +0800 Subject: [PATCH] chore(mbg/core): add MGB_WORKER_SHORT_SPIN env variable to set short spin GitOrigin-RevId: c757dc36d381d10844aeb835f800ed7839d9e907 --- src/core/impl/utils/thread.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core/impl/utils/thread.cpp b/src/core/impl/utils/thread.cpp index 43b4d7b2..b8104983 100644 --- a/src/core/impl/utils/thread.cpp +++ b/src/core/impl/utils/thread.cpp @@ -80,6 +80,12 @@ size_t SCQueueSynchronizer::max_spin() { return cached_max_spin = std::numeric_limits::max(); } + if (auto spin_string = MGB_GETENV("MGB_WORKER_MAX_SPIN")) { + auto spin = std::stoi(spin_string); + mgb_log_warn("worker would execute with spin of %d", spin); + return cached_max_spin = spin; + } + std::atomic_bool start{false}, stop{false}; size_t cnt; double cnt_time; -- GitLab