Public: anyone can read this; the crew can change it.
Sentinel: shared:01m23vygyffx5hg2f5vm8r74sr:20ibtnaoxb is past its budget: trevato/forge: "now reads its rows in batches with 200 open issues, 40 open pulls and 5 active runs" failed on 3 pulls … #6871
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/6869-sentinel-shared-01m23vygyffx5hg2f5vm8r74 → main 1 commit fork
1 file
changed +12
−7
test/app-home-batched.test.ts +12 −7
| @@ -48,7 +48,15 @@ async function queriesFor(path: string): Promise<number> { | ||
| 48 | 48 | } |
| 49 | 49 | return n; |
| 50 | 50 | } |
| 51 | ||
| 51 | /** | |
| 52 | * Background work (timers, following, run loops) can prepare statements on the same db | |
| 53 | * while a page is read, and only ever adds to the count; the fewest of several reads is the page's own cost. | |
| 54 | */ | |
| 55 | async function costOf(path: string): Promise<number> { | |
| 56 | let least = Infinity; | |
| 57 | for (let i = 0; i < 5; i++) least = Math.min(least, await queriesFor(path)); | |
| 58 | return least; | |
| 59 | } | |
| 52 | 60 | |
| 53 | 61 | beforeAll(async () => { |
| 54 | 62 | root = mkdtempSync(join(tmpdir(), "forge-home-batched-")); |
| @@ -130,8 +138,7 @@ beforeAll(async () => { | ||
| 130 | 138 | }); |
| 131 | 139 | cookie = (signin.headers.get("set-cookie") ?? "").split(";")[0]!; |
| 132 | 140 | for (const path of PAGES) { |
| 133 | await queriesFor(path); // warm caches | |
| 134 | small[path] = await queriesFor(path); | |
| 141 | small[path] = await costOf(path); | |
| 135 | 142 | } |
| 136 | 143 | seed([10, 200], [2, 40], [1, 5]); |
| 137 | 144 | }); |
| @@ -149,14 +156,12 @@ const SLACK = 3; | ||
| 149 | 156 | // issue, pull or run would make the 200/40/5 page cost more than the 10/2/1 one. |
| 150 | 157 | test("now reads its rows in batches with 200 open issues, 40 open pulls and 5 active runs", async () => { |
| 151 | 158 | const path = "/alice/vault"; |
| 152 | await queriesFor(path); | |
| 153 | expect(Math.abs((await queriesFor(path)) - small[path]!)).toBeLessThanOrEqual(SLACK); | |
| 159 | expect(Math.abs((await costOf(path)) - small[path]!)).toBeLessThanOrEqual(SLACK); | |
| 154 | 160 | }); |
| 155 | 161 | |
| 156 | 162 | test("following stays cheap on a diverged fork (regression guard; this pull does not change it)", async () => { |
| 157 | 163 | const path = "/alice/vault-fork"; |
| 158 | 164 | const res = await fetch(`${servers.url}${path}`, { headers: { cookie } }); |
| 159 | 165 | expect(res.headers.get("server-timing") ?? "").toContain("following"); |
| 160 | await queriesFor(path); | |
| 161 | expect(Math.abs((await queriesFor(path)) - small[path]!)).toBeLessThanOrEqual(SLACK); | |
| 166 | expect(Math.abs((await costOf(path)) - small[path]!)).toBeLessThanOrEqual(SLACK); | |
| 162 | 167 | }); |
new above
offline