Files
magpie/internal/sessions
yetone 11ab58c587 sessions: a kept folder listing is one array (#2278)
readDirectory keeps each folder's listing to tell an unchanged folder
from a changed one. os.ReadDir's entries are a pointer each to a
separate unixDirent plus its name, so a Codex sessions tree of 10k
files held 20k small objects for as long as magpie ran. The kept
listing is now one []keptEntry (dir, name, type) with pointers into
it: one object per entry, and Info() still lstats on demand as
os.ReadDir's does. Windows keeps os.ReadDir's entries (their Info is
already filled and cheap).

Measured on mote, 10k-file folder, HeapAlloc/HeapObjects kept across
readDirectory, 3 runs each:
  before: 1,297,928 B, 19,996 objects (129.8 B/entry)
  after:  1,042,664 B,  9,994 objects (104.3 B/entry)
-20% bytes and half the objects the GC scans each cycle.

Run: go test ./internal/sessions on mote (TestKeptListingIsCompact
checks entries equal os.ReadDir's in Name/IsDir/Type/Info, are
contiguous, and an unchanged folder is not listed again).
Not tried: Windows (path unchanged there).
2026-11-13 14:45:32 +08:00
..
2026-10-02 08:20:33 +08:00