more iops cheese testing - sort by downloaded_at not host id

This commit is contained in:
Joe Lothan 2026-05-26 01:09:32 -04:00
parent a30fe104a3
commit 9266c1417d
3 changed files with 62 additions and 22 deletions

View file

@ -128,7 +128,9 @@ func main() {
// Stage 1: DB fetcher — continuously fetches pages into hostCh
go func() {
defer close(hostCh)
var lastTime *time.Time
var lastID int64
iconPhase := true // first: hosts with icons (by download time), then: hosts without
pageSize := 50000
fetched := 0
for {
@ -143,14 +145,26 @@ func main() {
}
}
fetchStart := time.Now()
hosts, err := fetchHostsPage(ctx, pool, lastID, limit)
hosts, err := fetchHostsPage(ctx, pool, lastTime, lastID, limit)
if err != nil {
log.Fatalf("Failed to fetch hosts: %v", err)
}
if len(hosts) == 0 {
if iconPhase {
// Switch to no-icon hosts
iconPhase = false
lastTime = nil
lastID = 0
continue
}
break
}
lastID = hosts[len(hosts)-1].ID
last := hosts[len(hosts)-1]
if last.IconDownloadedAt != nil {
lastTime = last.IconDownloadedAt
} else {
lastID = last.ID
}
fmt.Printf("[fetcher] %d hosts in %dms (hostCh: %d/%d)\n",
len(hosts), time.Since(fetchStart).Milliseconds(), len(hostCh), cap(hostCh))
for _, h := range hosts {