Every Requests page build (each 5s refresh of the newest page, each page
turn, each filter) walks the whole period. Over all of it each row went
into about 17 sums: the page's own, a source cell, five chart series
groups, five dimension groups, the caller key and account groups, the
computers' share, and the chart point with its five parts. Each one
copied the 896-byte Row and worked out Decode and Floor again, and
each dimension rebuilt f.Without(d) and ran keepsRow on another copy.
Now each row's sums are made once (Totals.addRow into d) and added to
each group (Totals.plus, Part.plus). The filters with a dimension, or
the computer and day, cleared are built once. A filter that clearing
leaves unchanged reuses the row's own keep, and with no pick that is
every dimension. keepsRow, keepsRecord, computer, Row.key and keyer.key
take pointers.
Measured on the real sandbox data (sbmem, 416,665 rows), with zzbench:
one QueryPage of period=all, then six rebuilds at new offsets. Process
CPU at load ~110-127, three runs each, alternated with the old binary:
before (7d67910f7): user 20.84 / 20.39 / 20.61 s, sys 2.69-2.93 s
after: user 15.33 / 15.74 / 15.75 s, sys 2.80-2.97 s
In the profile, buildRequestBlocksOf's row closure went from 5.56 s to
1.59 s cumulative. Wall time per page is too noisy at this load to quote
(1.9-3.1 s both ways). What remains per rebuild is mostly evicted shards
being read again (prefetchSources -> loadCalls, ~1.7 s over the seven
builds) and the walk of the Codex folders.
Tests: TestTotalsPlusAddsEveryField fails when a Totals field is left
out of plus (broken by hand: dropping FloorN fails it).
TestPartPlusIsAdd compares Part.plus with Part.add over measured,
reasoning, failed, handed-on and retried rows. TestCompactPageMatchesLedger
already compares the page with the per-row ledger path over 13 filters.
Making every dimension group reuse keep fails 60 of its subtests.
Run at this head: go test -count=1 ./internal/usage ./internal/gui ok
(36.5s, 150.0s); go build -tags nogui ./... ok; go vet -tags nogui for
GOOS=linux and windows on internal/usage ok; gofmt -l clean. Not run:
the full suite (other sessions' suites hold the machine) and the gateway
package (it only calls usage's exported API, which is unchanged).