diigo-cache: pace diigo calls only; cache hits don't wait
page() ran the 500 ms pacing gate before the cache check, so every hit waited too: a fill rerun skipping 166 cached pages took ~80 s and looked like a start from scratch. The gate now sits after the hit check (re-checking storage once through it, in case a request ahead had just etched the page). Regression test: the fixed-clock test cache records its sleeps; a miss sleeps once, three hits add none (failed before: 4 sleeps). Generated-by: Claude Opus 5.5
This commit is contained in:
1 parent
f5d57f73d3
commit
fd16c7db53
3 files changed
+43
-8
No files matched your search
@@ -285,8 +285,15 @@ abstract class PagedCache extends DurableObject<CacheEnv> {
|
||||
if (!init) throw new Error("not wired: this cache id was never set up");
|
||||
this.ctx.storage.sql.exec(SCHEMA_V1);
|
||||
|
||||
// one diigo call path at a time, min spacing MS_PER_CALL (webapp's
|
||||
// Gate pattern; per activation)
|
||||
const hit = await this.#pageFromStorage(pageNum, count);
|
||||
if (hit) {
|
||||
console.log({ event: "cache", kind: this.kind, page: pageNum, outcome: "hit", items: hit.items.length });
|
||||
return hit;
|
||||
}
|
||||
|
||||
// a miss calls diigo: one call path at a time, min spacing
|
||||
// MS_PER_CALL (webapp's Gate pattern; per activation). Hits above
|
||||
// never wait.
|
||||
let before;
|
||||
do {
|
||||
before = this.#step;
|
||||
@@ -294,11 +301,11 @@ abstract class PagedCache extends DurableObject<CacheEnv> {
|
||||
} while (before !== this.#step);
|
||||
this.#step += 1;
|
||||
this.#pause = this.#clock.sleep(MS_PER_CALL);
|
||||
|
||||
const hit = await this.#pageFromStorage(pageNum, count);
|
||||
if (hit) {
|
||||
console.log({ event: "cache", kind: this.kind, page: pageNum, outcome: "hit", items: hit.items.length });
|
||||
return hit;
|
||||
// a request ahead of us at the gate may have etched this page
|
||||
const late = await this.#pageFromStorage(pageNum, count);
|
||||
if (late) {
|
||||
console.log({ event: "cache", kind: this.kind, page: pageNum, outcome: "hit", items: late.items.length });
|
||||
return late;
|
||||
}
|
||||
|
||||
// RPC stubs (the app and each pipelined step) are disposed once the
|
||||
|
||||
Reference in new issue
Block a user