Commit Graph
1 Commits
Author SHA1 Message Date
yetone 1f589e3f4f usage: read today's usage ahead at startup
CyberCaius (Discord, Windows): "今天 N 次调用" is slow on the first
panel open after a start. The first usage?period=today parses
usage.jsonl: 0.33s for 2MB, 0.43s for a 40MB sandbox log here, more
on a slower disk. startBackend now runs usage.ReadAhead() in the
background, which works out today's summary into the summary cache,
so the panel's first ask finds it.

Parallel parsing was not done: with the read ahead, a request 1s
after start answers in 1-2ms, so there is nothing left to win there.

Test: TestReadAheadLeavesTodayNothingToRead. After ReadAhead, a
SummarizeTopIn(Today) parses nothing and works nothing out. Red with
ReadAhead's body emptied ("parsed the log 1 more times and was
worked out 1 more").

Run at tree 53ae48f72 (on origin/main 3b5a2f612): go test -tags nogui
-timeout 45m ./internal/usage ./internal/gui ok (TestCoreScriptBudget
included, no budget raised; app.js 1,317,465 of 1,317,486). GUI files
panel*, tray*, i18n-keys, routing-sessions (27 files, chromium and
webkit): 336 pass, 0 fail. gofmt clean. Earlier, at 7571ebc93: full
GUI suite 1095 pass; the 4 reds are two tests red on main too (#3497,
removed by hand gives "changed height 630 !== 561".
2026-10-24 23:49:08 +08:00