Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(server): PR cache invalidation no longer waits on other projects' reads (1,163 ms → 0.12 ms median) #30293

MergedYuruzuu(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/30293/headmerged by maria-rcks View on GitHub

Showing 2 changed files with 18 additions and 1 deletion.

x
0 of 2 viewed, 2 left
3 additions and 0 deletionsapps/server/src/pullRequest/PullRequestReadCache.test.tsModified
View file
@@ -44,6 +44,9 @@
const invalidate = yield* cache
.invalidate("pr")
.pipe(Effect.forkChild({ startImmediately: true }));
+ // Another PR's invalidation does not wait on this read; this one's does.
+ yield* cache.invalidate("other-pr");
+ assert.isUndefined(invalidate.pollUnsafe());
yield* Deferred.succeed(release, undefined);
yield* Fiber.join(read);
yield* Fiber.join(invalidate);
15 additions and 1 deletionapps/server/src/pullRequest/PullRequestReadCache.tsModified
View file
@@ -26,6 +26,8 @@
import { forkParked } from "../serverActivation.ts";
​
const CONCURRENT_READS = 512;
+/** Invalidation excludes only reads whose scopes share its stripe, not every PR read. */
+const SCOPE_STRIPES = 64;
// Entry filenames are the URI-encoded `<storeId>:<key>`; the scope revisions file has
// no store id. Effect before 4.1 wrote `<storeId><key>`, still pruned here.
const STORE_ID = "pr-v2";
@@ -87,6 +89,11 @@
const clock = yield* Clock.Clock;
let enabled = true;
const lock = yield* Semaphore.make(CONCURRENT_READS);
+ const stripes = yield* Effect.forEach(Array.from({ length: SCOPE_STRIPES }), () =>
+ Semaphore.make(CONCURRENT_READS),