Files
magpie/internal
yetone 4753a6cfbb gateway: a look at the routing history reads today's file only past what it counted, and parses only its latest routes (#3383)
The Routing view asks /api/gateway/history every 15s while requests are
done. History read a day's .jsonl whole whenever its size had changed,
which today's always has, so a busy day's 350 MB file (19,751 routes in
the report) was read through at every look, and asking for today
unmarshalled all its routes to keep the latest 2000. Now a .jsonl's
count is kept with where each of its lines starts: a look reads only the
bytes added since, and the asked day parses its latest historyMax plus
200 lines (historySlack, for a route done after later ones began). A
last line without its newline is counted, as readDay reads it, but
tallied again at the next look, as it may be half written; a file
smaller than what was counted is counted again from its start. .gz days
are read as before, an asked one skipping the unmarshal of all but its
latest lines.

Run:
- TestHistoryReadsOnlyWhatWasAdded: ok; red on the old history.go
  ("want 2252 requests", got 2251: it read the blanked routes again).
- BenchmarkHistoryLook (20k routes, ~100 MB, one added per look):
  54.1 ms/op on the old code, 1.19 ms/op now.
- go test -count=1 -run 'History|Trace|Route' ./internal/gateway/
  ./internal/gui/: once exited 1 with the failing test's name lost to a
  tail; rerun with the whole log kept, then -count=3: ok every time.
- gofmt -l clean; go vet darwin, GOOS=linux and GOOS=windows -tags nogui
  clean for internal/gateway.

Not done here: the route's Order list's size on disk, and moejs's
retained JSON (#3383's other two findings).
2026-10-24 21:00:05 +08:00
..
…
…
…
…
…
…