server: make index log back-off a bit more concise
This commit is contained in:
@ -29,6 +29,7 @@
|
||||
#include <atomic>
|
||||
#include <variant>
|
||||
#include <functional>
|
||||
#include <chrono>
|
||||
|
||||
#include <cstring>
|
||||
#include <glib.h>
|
||||
@ -828,18 +829,15 @@ Server::Private::do_index(const Indexer::Config& conf)
|
||||
{
|
||||
StopWatch sw{"indexing"};
|
||||
indexer().start(conf);
|
||||
std::chrono::milliseconds sleep_duration(125); // initial 125ms
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
auto sleep_duration{125ms};
|
||||
while (indexer().is_running()) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
sleep_duration = std::min(sleep_duration * 2, 2000ms);
|
||||
}
|
||||
output_sexp(get_stats(indexer().progress(), "complete"),
|
||||
Server::OutputFlags::Flush);
|
||||
|
||||
Reference in New Issue
Block a user