perf: stop per-frame SQLite writes and console spam, make perf.log opt-in
- Explorer: the tip check runs every frame the Explorer tab is open, and it read both tip rows and rewrote them each time (two autocommit WAL writes per frame). A steady tip is now kept in memory and skips SQLite. A new tip writes both rows in one savepoint, so a crash between them can't pair a new height with the old hash. A test checks that 100 steady checks write nothing. - Console: while the daemon was in the Error state the Console tab added its error line on every poll, i.e. every frame, re-laying out the whole buffer each time. It prints once per error now: on entering Error, when the message changes, or after another crash (EmbeddedDaemon::getUnexpectedExitCount(), never reset). setState writes the message before the state, so a reader that sees Error sees that error's message. The stray " ===" suffix is gone. - perf.log: the profiler appended a block every 300 frames on every run and never rotated the file (tens of MB a day for a wallet left open). It is now off unless the app starts with DRAGONX_PERFLOG=1; otherwise its zone hooks are near no-ops. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5468,6 +5468,15 @@ void testRendererHelpers()
|
||||
EXPECT_NEAR(dragonx::ui::ClampConsoleWrapWidth(40.0f, 8.0f), 50.0, 0.0001);
|
||||
EXPECT_NEAR(dragonx::ui::ClampConsoleWrapWidth(200.0f, 12.0f), 176.0, 0.0001);
|
||||
|
||||
// The daemon-error line prints once per error, not on every poll (it flooded one line per frame).
|
||||
using dragonx::ui::ShouldPrintDaemonErrorLine;
|
||||
EXPECT_TRUE(ShouldPrintDaemonErrorLine(false, true, "bind failed", "")); // entering Error
|
||||
EXPECT_FALSE(ShouldPrintDaemonErrorLine(true, true, "bind failed", "bind failed")); // still the same error
|
||||
EXPECT_TRUE(ShouldPrintDaemonErrorLine(true, true, "binary missing", "bind failed")); // reason changed
|
||||
EXPECT_TRUE(ShouldPrintDaemonErrorLine(false, true, "bind failed", "bind failed")); // a new episode
|
||||
EXPECT_FALSE(ShouldPrintDaemonErrorLine(true, false, "bind failed", "")); // not in Error
|
||||
EXPECT_TRUE(ShouldPrintDaemonErrorLine(true, true, "exit code 1", "exit code 1", true)); // crashed again
|
||||
|
||||
EXPECT_EQ(dragonx::ui::ClampMiningThreads(0, 8), 1);
|
||||
EXPECT_EQ(dragonx::ui::ClampMiningThreads(12, 8), 8);
|
||||
EXPECT_EQ(dragonx::ui::ClampMiningThreads(4, 8), 4);
|
||||
@@ -5783,6 +5792,12 @@ void testExplorerBlockCache()
|
||||
auto sameTipValidation = cache.prepareValidation(10, "hash-10");
|
||||
EXPECT_FALSE(sameTipValidation.needed);
|
||||
|
||||
// A steady tip writes nothing: this check runs every frame the Explorer is open (it used to
|
||||
// rewrite both tip rows each time).
|
||||
const int changesBeforeSteadyTip = cache.totalChanges();
|
||||
for (int i = 0; i < 100; ++i) EXPECT_FALSE(cache.prepareValidation(10, "hash-10").needed);
|
||||
EXPECT_EQ(cache.totalChanges(), changesBeforeSteadyTip);
|
||||
|
||||
auto advancedValidation = cache.prepareValidation(12, "hash-12");
|
||||
EXPECT_TRUE(advancedValidation.needed);
|
||||
EXPECT_EQ(advancedValidation.height, 10);
|
||||
|
||||
Reference in New Issue
Block a user