VersionControl:PRs/magenta/412

From PickiPedia: A knowledge base of bluegrass, old time psychedelic jams, and other public domain music
Revision as of 16:06, 9 November 2026 by DrivingThatTrain (talk | contribs) (cryptograss/magenta#412, as GitHub has it)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
magenta#412: Load test: open tabs on production; the poll stops redoing what didn't change
State 🟣 merged 2026-11-06 18:52:32
Worked on by magent, justin
Moods #performance
Deploy not said
Branch loadtest-tabs → main, by magent-cryptograss
Opened · last pushed 2026-11-06 18:50:35 · 2026-11-06 18:50:29
Justin asked (#performance, 6 Nov): simulate traffic and see how magenta holds up, on production.

**`memory-lane/loadtest/tabs.py`**: virtual tabs that do what `moods.html` does with nobody touching it. They poll their Mood every 4 s and `/api/moods/live/` every 5 s (preloading a Mood whose newest message moved), make the once-a-minute asks (servers, to-do, humans), and now and then open another Mood cold. Read-only and anonymous. It ramps in steps and stops itself when p95 passes a line. Each step prints p50/p95/p99 per kind, plus the slowest 5%'s Server-Timing laps against the time spent outside the server.

**First run, production, block 26,357,7xx:** it stopped at the first step.

| 5 tabs | p50 | p95 |
|---|---|---|
| poll (`?after=`, nothing new) | 1667 ms | 5051 ms |
| live | 22 ms | 1574 ms |
| all | 1183 ms | 4765 ms |

The slowest 5% spent 5.3 s in the server and 20 ms outside it, so they weren't queueing at gunicorn. The laps were pronouns 1318, zones 1179, agents 817 and activities 481 ms. Unloaded, a poll for nothing new was 870 ms (agents 429).

**The fix in this PR:**
- `pronouns_here` / `zones_here` each ran `mood.thinking_entities()`, a `DISTINCT` join over every message in the Mood, on every poll. They now take the participants from `said_in(mood)` (#338), kept until something new lands.
- `agents_in` sorted the whole settings history several times per emergent, plus three queries each. It's now kept, stamped with the settings' count and newest row and the Mood's newest message, for 15 s at most (a listening `until` running out, a harness reporting its models). A setting changed or a word said still shows at the next poll.
- `activities` (481 ms) is left alone: it has to stay realtime, and the registry on the to-do (Option A) is its fix.

Tests: `PollKeepsWhatDidntChangeTest` (the settings are worked out again on a new setting and on a new word, not otherwise; who spoke isn't joined again). All 1,723 tests in `conversations.tests` pass.

After the redeploy: run `tabs.py --steps 5,10,25,50` again and compare.

Redeploy: maybelle
Worked on by: magent, justin, in #performance