Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

sessions: the warm-up lists the Codex rollouts once for all its reads (#3493)

yetone04439c8592ef
diff --git a/internal/sessions/quiet.go b/internal/sessions/quiet.go
index c7402c0cf..6620eb78b 100644
--- a/internal/sessions/quiet.go
+++ b/internal/sessions/quiet.go
@@ -35,7 +35,10 @@ func scanReaders() int { return max(2, runtime.NumCPU()/2) }
// Warm runs fn, the reads nobody waits on yet, with few readers.
func Warm(fn func()) {
warming.Add(1)
- defer warming.Add(-1)
+ defer func() {
+ warming.Add(-1)
+ forgetWarmListing()
+ }()
fn()
}
diff --git a/internal/sessions/sessions.go b/internal/sessions/sessions.go
index 47f50424e..7434652be 100644
--- a/internal/sessions/sessions.go
+++ b/internal/sessions/sessions.go
@@ -616,6 +616,41 @@ const zstSuffix = ".zst"
// reading CodexDir alone left out every other account's sessions and
// calls (phantom3792 on X).
func codexFiles() []file {
+ if !quiet() {
+ return listCodexFiles()
+ }
+ warmListing.Lock()
+ defer warmListing.Unlock()
+ if warmListing.files != nil && time.Since(warmListing.at) < warmListingFor {
+ return slices.Clone(warmListing.files)
+ }
+ files := listCodexFiles()
+ warmListing.at, warmListing.files = time.Now(), slices.Clone(files)
+ return files
+}
+
+// warmListing is codexFiles' listing kept through the warm-up: its reads
+// (the stats of every day and of 30, the Requests page) each listed every
+// rollout again within a few seconds, ~12k lstat()s and ~45 MB a time
+// (#3493). It is kept only while nobody but the warm-up reads (quiet) and
+// for warmListingFor at most, the age statsFor's memo already answers
+// with; Warm lets it go when it ends.
+var warmListing struct {
+ sync.Mutex
+ at time.Time
+ files []file
+}
+
+const warmListingFor = 10 * time.Second
+
+func forgetWarmListing() {
+ warmListing.Lock()
+ warmListing.files = nil
+ warmListing.Unlock()
+}
+
+// listCodexFiles is codexFiles listed now.
+func listCodexFiles() []file {
var out []file
for _, dir := range CodexDirs() {
out = append(out, codexFilesIn(dir)...)
diff --git a/internal/sessions/warm_listing_test.go b/internal/sessions/warm_listing_test.go
new file mode 100644
index 000000000..c5441d98b
--- /dev/null
+++ b/internal/sessions/warm_listing_test.go
@@ -0,0 +1,39 @@
+package sessions
+
+import (
+ "path/filepath"
+ "testing"
+)
+
+// The warm-up's reads list the rollouts once between them (#3493), and only
+// they do: a page asking meanwhile, and every read after the warm-up, sees
+// a rollout written since.
+func TestWarmUpListsRolloutsOnce(t *testing.T) {
+ d := setupCalls(t)
+ day := filepath.Join(d.codex, "sessions", "2026", "09", "20")
+ first := filepath.Join(day, "rollout-2026-09-20T10-00-00-0190aaaa-1111-7222-8333-444455556666.jsonl")
+ second := filepath.Join(day, "rollout-2026-09-20T11-00-00-0190bbbb-1111-7222-8333-444455556666.jsonl")
+ writeLines(t, first, cxTurnLines(1, "turn-1", "gpt-6-astra", "low")...)
+ Warm(func() {
+ if n := len(codexFiles()); n != 1 {
+ t.Fatalf("warm-up's first listing: %d rollouts", n)
+ }
+ writeLines(t, second, cxTurnLines(1, "turn-1", "gpt-6-astra", "low")...)
+ fs := codexFiles()
+ if len(fs) != 1 {
+ t.Fatalf("warm-up listed again: %d rollouts", len(fs))
+ }
+ fs[0] = file{}
+ if again := codexFiles(); len(again) != 1 || again[0].path != first {
+ t.Fatalf("a caller's change reached the kept listing: %+v", again)
+ }
+ done := Ask()
+ if n := len(codexFiles()); n != 2 {
+ t.Fatalf("a page asking got the warm-up's listing: %d rollouts", n)
+ }
+ done()
+ })
+ if n := len(codexFiles()); n != 2 {
+ t.Fatalf("after the warm-up: %d rollouts", n)
+ }
+}