Skip to content

Commit 1197829

Browse files
committed
Warn if there are too many background jobs
1 parent 30ba38c commit 1197829

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/util.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,13 @@ struct BackgroundJobTracker::Impl
343343
{
344344
MutexLock lock(m_lock);
345345

346-
auto it = m_jobs.insert({ name, 1 });
346+
auto it = m_jobs.emplace(name, 1);
347347
if (!it.second) {
348-
++it.first->second;
348+
const int32_t n = ++it.first->second;
349+
// Print the warning only once as the number goes past 20
350+
if (n == 20) {
351+
LOGWARN(3, "Performance warning: there are " << n << " instances of " << name << " running in the background. This shouldn't be normally happening - check logs for other warnings and errors.");
352+
}
349353
}
350354
}
351355

@@ -359,8 +363,8 @@ struct BackgroundJobTracker::Impl
359363
return;
360364
}
361365

362-
--it->second;
363-
if (it->second <= 0) {
366+
const int32_t n = --it->second;
367+
if (n <= 0) {
364368
m_jobs.erase(it);
365369
}
366370
}

0 commit comments

Comments
 (0)