Skip to content

Fold the home-page prewarm into the page warmer - #139

Merged
mspinola merged 1 commit into
mainfrom
claude/fold-home-prewarm
Sep 25, 2026
Merged

mspinola merged 1 commit into
mainfrom
claude/fold-home-prewarm

Conversation

@mspinola

Copy link
Copy Markdown
Owner

Why

pages/home.py started its own prewarm thread at import. That thread raced the page warmer for the GIL while both built the same per-market frames. After the 2026-09-25 16:17 restart on the VPS, the home prewarm and the queued weekly-report requests all finished together, about 3.5 minutes after boot (see #137).

Change

  • home._prewarm_cache becomes home.warm_caches(), and the import-time thread is gone.
  • main.warm_page_caches calls it second: after the newest weekly report, before crowd, heatmap and divergence.
  • Side effects:
    • It now runs only in the process that serves requests. Under --debug's reloader the import used to run it in both processes.
    • The home cards are re-warmed after a new week (they are keyed on db_time). Before, a release left them cold until the first visitor.

Measured (local, real stores, two runs each, from process start)

before after
newest weekly page served 3.2s 2.0s
home prewarm 2.7s 1.0s
everything warm ~10.4s ~10.1s

Tests

pytest tests/ gives 897 passed, and ruff check src tests is clean. test_warm_order.py now pins weekly, home, crowd, heatmap, divergence.

🤖 Generated with Claude Code

pages/home.py started its own prewarm thread at import, which raced the
page warmer for the GIL while both built the same per-market frames. On
the VPS after the 2026-09-25 16:17 restart the home prewarm and the queued
weekly-report requests all finished together ~3.5 minutes after boot.

Now home.warm_caches runs inside main.warm_page_caches, second, after the
newest weekly report and before the boards. That also means it only runs
in the process that serves requests (the import ran it in both under
--debug's reloader), and it is re-warmed after a new week, where before a
release left the home cards cold until the first visitor.

Local boot, process start to served: newest weekly page 3.2s -> 2.0s,
home prewarm 2.7s -> 1.0s, everything warm ~10s either way (two runs each).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mspinola
mspinola merged commit ab93f7a into main Sep 25, 2026
3 checks passed
@mspinola
mspinola deleted the claude/fold-home-prewarm branch September 25, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant