Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(shared): SQLite reads stop queueing behind each other, up to 5x faster under load #27097

Mergedjuliusmarmingemerged 2 commits intomain fromrefs/pull/27097/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 40 additions and 0 deletions (loading 1).

x
0 of 2 viewed, 2 left
40 additions and 0 deletionspackages/shared/src/nodeSqliteClient.test.tsModified
View file
@@ -238,6 +238,27 @@
​
+it.effect("serves another read while a read-only transaction is open", () =>
+ withReaderClient((sql) =>
+ Effect.gen(function* () {
+ const opened = yield* Deferred.make<void>();
+ const other = yield* Effect.forkChild(
+ Deferred.await(opened).pipe(Effect.andThen(countEntries(sql).pipe(SqliteClient.readOnly))),
+ );
+ yield* sql
+ .withTransaction(
+ Effect.gen(function* () {
+ yield* countEntries(sql);
+ yield* Deferred.succeed(opened, undefined);
+ // One shared reader would make this join wait on the transaction forever.
+ assert.equal(yield* Fiber.join(other), 1);
+ }),
+ )
+ .pipe(SqliteClient.readOnly);
+ }),
+ ),
+);
+​
// regression: #19226 read-only transactions run on the separate reader connection
it.effect("rejects a write in a read-only transaction", () =>
withReaderClient((sql) =>
@@ -333,6 +354,25 @@