Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(server): unchanged node updates no longer write to SQLite #19429

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/19429/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 4 changed files with 87 additions and 0 deletions (loading 1).

x
0 of 4 viewed, 4 left
24 additions and 0 deletionsapps/server/src/orchestration-v2/ProjectionStore.tsModified
View file
@@ -73,6 +73,7 @@
import * as Context from "effect/Context";
import * as DateTime from "effect/DateTime";
import * as Effect from "effect/Effect";
+import * as Equal from "effect/Equal";
import * as Layer from "effect/Layer";
import * as Ref from "effect/Ref";
import * as Schema from "effect/Schema";
@@ -460,6 +461,10 @@
requestId: TurnItemId,
resultId: TurnItemId,
) => Effect.Effect<boolean, ProjectionStoreV2Error>;
+ /** True when the projection already stores this exact node, so a write would change nothing. */
+ readonly isNodeStored: (
+ node: OrchestrationV2ExecutionNode,
+ ) => Effect.Effect<boolean, ProjectionStoreV2Error>;
readonly getRuntimeRequest: (
threadId: ThreadId,
requestId: RuntimeRequestId,
@@ -4404,6 +4409,15 @@
return rows[0]?.pending === 1;
}).pipe(Effect.mapError(controlReadError(threadId)));
+ const isNodeStored: ProjectionStoreV2Shape["isNodeStored"] = (node) =>
+ Effect.gen(function* () {
+ const payloadJson = yield* encodeNodePayload(node);
+ const rows = yield* sql<PayloadRow>`
+ SELECT payload_json FROM orchestration_v2_projection_nodes WHERE node_id = ${node.id}