perf(daemon): memoize the external debug.log miss
When following the debug.log of a node this session did not launch, every poll re-read the last 2 MB of the file and re-scanned it for the process banner. If that node logs to its console instead, the banner is never there, so the full re-scan repeated on every poll for the life of the process. - A miss is now remembered by pid and file size: if nothing has changed since the last miss, or the file is growing but the backoff has not elapsed, the scan is skipped. - The retry schedule re-scans quickly during a fresh-node grace window (the banner flushes a beat after the pid appears) and then backs off from 4 s, doubling to a 60 s cap. The memo is cleared on a successful tie and when the followed process goes away. Tests: the retry delay is fast within the grace window and then steps 4, 8, 16 s up to the 60 s cap. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -6755,6 +6755,19 @@ void testDebugLogTailRules()
|
||||
EXPECT_TRUE(externalLogFeedOffset(midRun, false, t0) == std::string::npos); // whole file, no banner: can't tell
|
||||
EXPECT_TRUE(externalLogFeedOffset(oldRun + newRun, false, 0) == std::string::npos);
|
||||
|
||||
// C107: the miss-retry schedule: fast in the grace window, then 4,8,...,60 s cap.
|
||||
{
|
||||
double b = 0.0;
|
||||
EXPECT_NEAR(dragonx::daemon::nextExternalLogRetryDelay(0.0, b), 2.0, 1e-9);
|
||||
EXPECT_NEAR(dragonx::daemon::nextExternalLogRetryDelay(14.9, b), 2.0, 1e-9);
|
||||
EXPECT_NEAR(b, 0.0, 1e-9);
|
||||
EXPECT_NEAR(dragonx::daemon::nextExternalLogRetryDelay(15.0, b), 4.0, 1e-9);
|
||||
EXPECT_NEAR(dragonx::daemon::nextExternalLogRetryDelay(20.0, b), 8.0, 1e-9);
|
||||
EXPECT_NEAR(dragonx::daemon::nextExternalLogRetryDelay(30.0, b), 16.0, 1e-9);
|
||||
for (int i = 0; i < 6; ++i) dragonx::daemon::nextExternalLogRetryDelay(100.0, b);
|
||||
EXPECT_NEAR(b, 60.0, 1e-9);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
const long self = static_cast<long>(GetCurrentProcessId());
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user