Home

fsky / yggpeers

public
Overview Code History Branches Pull requestsIssuesInsights
main
HomeOverview Code PRsIssues

Speed up cache misses with a rollup table, CGO SQLite, and warming

5 months ago

e3ee122
Authored
architect4/19/2026, 12:54:45 PM
- Swap modernc.org/sqlite for mattn/go-sqlite3 so aggregation runs
  in native C instead of a transpiled Go VM; Containerfile now builds
  with CGO and musl-dev.
- Add a daily_peer_stats rollup (one row per peer per day) so /stats,
  /, and /api/countries aggregate over ~peers*days rows instead of
  the full 7-day checks window. RecordChecks upserts into it in the
  same tx; PruneOldChecks trims both tables; first boot backfills
  from existing checks.
- Move per-connection pragmas into the DSN and bump cache_size to
  ~40 MB so hot pages stay resident; ANALYZE once after migrate.
- Add Store.RefreshCaches, called from the checker after each run,
  so the expensive queries always execute on checker time and user
  requests hit a warm cache.

Parent20796fd

5 files changed
  • Containerfile+2−1
  • go.mod+4−10
  • go.sum+12−49
  • internal/checker/checker.go+3−0
  • internal/store/store.go+185−69