Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(server): thread recovery reads are 10x faster #27099

Mergedjuliusmarmingemerged 1 commit intomain fromrefs/pull/27099/headmerged by juliusmarminge View on GitHub

Showing 4 changed files with 35 additions and 1 deletion (loading 1).

x
0 of 4 viewed, 4 left
14 additions and 1 deletionapps/server/src/orchestration-v2/ProjectionStore.test.tsModified
View file
@@ -6640,10 +6640,23 @@
completedAt: releasedAt,
+ const { statements, tracer } = traceSqlStatements();
assert.deepEqual(
- (yield* store.getRuntimeRecoveryProjection(threadId)).runs.map((run) => run.id),
+ (yield* store
+ .getRuntimeRecoveryProjection(threadId)
+ .pipe(Effect.withTracer(tracer))).runs.map((run) => run.id),
[runId, newerRunId],
+ // Live-item filters must hit the active partial indexes, not walk the thread's history.
+ const sql = yield* SqlClient.SqlClient;
+ for (const statement of statements.filter((query) => query.includes("turn_items"))) {
+ const plan = (yield* sql.unsafe<{ readonly detail: string }>(
+ `EXPLAIN QUERY PLAN ${statement}`,
+ )).map((row) => row.detail);
+ for (const detail of plan) {
+ assert.notMatch(detail, /turn_items_(thread_ordinal|thread_run)_idx \(thread_id=\?\)$/);
+ }
+ }
19 additions and 0 deletionsapps/server/src/persistence/Migrations/073_ActiveTurnItemIndexes.tsAdded
View file
@@ -0,0 +1,19 @@
+import * as Effect from "effect/Effect";