Files
magpie/internal
yetone f506638690 sessions: the Sessions poll makes its rows as the gateway's sessions merge
/api/sessions copied every one of ~17k sessions into MergeExternal's
merged list, and MergeExternal made a set of every native session's
keys again to leave natives out of the gateway's, though
GatewaySessions had already left them out by the same keys. The rows
were then copied from that list.

EachMerged hands each session to the caller in MergeExternal's order
(newest first, a native before an external of the same moment) from
the list as List gives it and the gateway's sessions sorted alone, so
the handler copies each session once, into its row. MergeExternal
keeps its own copy and dedupe for its other callers; both share
externalSessions.

TestEachMergedListsWhatMergeExternalDid: same rows, field for field, as
MergeExternal for a sorted list, an unsorted one (sorted in a copy, the
caller's left as it was) and none; with and without externals; ties;
stops at false. TestEachMergedCopiesNoList: 5000 natives merge in under
a twentieth of the list's bytes. Broken by hand, each red:
  EachMerged over MergeExternal's list: 5,437,624 bytes for a
    2,480,000-byte list
  EachMerged making the native key set again: 394,352 bytes

Measured on mote's build against the real ~17k sessions (sandbox HOME,
APFS clones), 30 polls, against v0.1.2554's build:
  heap diff alloc_space   726 MB -> 701 MB (MergeExternal's 107 MB
                          gone; externalSessions 51 MB left, the
                          gateway's own sessions)
  CPU over 30 polls       4.44s -> 4.24s
  /api/sessions median    73ms -> 71ms

Run on mote: go vet ./internal/sessions ./internal/gui ok;
go test ./internal/sessions ok; ./internal/gui red only in
TestSettingsSaveKeepsWhatItDoesNotSend (#4739) and
TestMainWindowCorners (#3949), both red on origin/main 788057340.
Not run: the full suite, the GUI suite (the answer's rows are the same).
Then rebased onto 1e6a27d4f (gui: an icon's image URL; none of the four commits touch sessions or the Sessions handler); not rerun.
Then rebased onto 994cd4fb6 (gui: Rex switches to the tab magpie opens, through the app's); not rerun.
2026-11-01 14:39:38 +08:00
..
…
…
…
…
…
…