logSnapshot.visit unpacked each block of usage.jsonl's snapshot into rows
of its own. Every Sessions, Usage and Routing poll reads the log through
it (buildGatewaySessions, topSummary, buildVias), so while calls came in
it allocated ~800 MB of rows a minute: 1.3 GB of the 5.3 GB a 24s heap
profile of a fed sandbox allocated was unpackReusing's rows, strings and
text under visit. It now decodes every block into one chunkRows buffer,
each over the one before, as the page's other readers do. A record's
strings are the block's own text, not the buffer's, so fn may keep them.
Run at this head (b69f8e96a + this change), on mote:
- go test ./internal/usage -timeout 45m: ok (24s).
- TestLogVisitReusesItsRows (new): visit's records equal a per-block
unpack's, and one visit of 20000 rows allocates at most a quarter of
their rows. Red on the old visit (4506304 > 4320000 bytes), green now.
- go test ./internal/gui -timeout 45m: ok but TestMainWindowCorners,
red the same as before this change (#3949).
- go vet -tags nogui ./... for darwin, linux and windows: clean.
A/B on mote, a sandbox HOME with #2278's synthetic history (34k
sessions, 3000 with gateway records), 10 page endpoints polled every 5s
and 4 gateway appends a second, 230s each, old = v0.1.1923:
old new
all polls mean 1.69s 1.09s
heatmap mean 4.54s 2.94s
footprint peak 648.9M 615.5M
avg CPU after feed 70.9% 70.3%
Another session's GUI suite ran on mote through both arms, so CPU is
noisy; the poll times are the point.
Rebased onto c5cdb043e (no internal/usage change in between), then run
again there: go test ./internal/usage ok (27.7s); go vet -tags nogui of
internal/usage and internal/gui for darwin, linux and windows clean.
Then rebased onto 8273325b0, which changes site/ only.
Not tried: the user's own history; the A/B's history is made up.