From 507925ca4bfa92d3effba9d24c8a9995c84702a9 Mon Sep 17 00:00:00 2001 From: "Zheng, Ping" <82363+pingz@users.noreply.github.com> Date: Tue, 1 Jul 2025 00:16:23 +0800 Subject: [PATCH] indexer sleep exp backoff --- lib/mu-server.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/mu-server.cc b/lib/mu-server.cc index 700f5e32..3484c612 100644 --- a/lib/mu-server.cc +++ b/lib/mu-server.cc @@ -828,10 +828,18 @@ Server::Private::do_index(const Indexer::Config& conf) { StopWatch sw{"indexing"}; indexer().start(conf); + std::chrono::milliseconds sleep_duration(125); // initial 20ms while (indexer().is_running()) { - std::this_thread::sleep_for(std::chrono::milliseconds(2000)); + std::this_thread::sleep_for(sleep_duration); output_sexp(get_stats(indexer().progress(), "running"), Server::OutputFlags::Flush); + // Exponential backoff: doubling sleep duration up to 2s + if (sleep_duration < std::chrono::milliseconds(2000)) { + sleep_duration *= 2; + if (sleep_duration > std::chrono::milliseconds(2000)) { + sleep_duration = std::chrono::milliseconds(2000); + } + } } output_sexp(get_stats(indexer().progress(), "complete"), Server::OutputFlags::Flush);