test(perf): rebuild gate in the §1.1 shape on both dialects, every column compared

- The rebuild gate adopts 400 sequences of 250 real photos (one fifth of the
  §1.1 library, same frames per sequence) and runs on SQLite and PostgreSQL.
- The rebuilt index is compared with the original in every column of every
  sequence and frame (only UpdatedAt, the rebuild time, is left out), and the
  first differing row is named.
- Synthetic frames are seeded by the sequence's position, so every run builds
  the same library; the Library open gate says it runs on a new connection pool
  with a warm OS cache instead of calling it cold.

Measured locally (PostgreSQL 16): Library open 259 ms SQLite / 181 ms PostgreSQL,
filters <= 6.4 ms; rebuild of 100,000 frames 1.8 s SQLite / 4.7 s PostgreSQL
(budget 120 s).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-03 10:13:06 +00:00
1 parent 411425b83a
commit 54fa588ecc
3 files changed
+86 -51

No files matched your search

@@ -7,8 +7,8 @@ namespace Titano.Data.Tests.Perf;
/// <summary>
/// The §1.1 library: 2,000 sequences of 250 photos (500,000 frames) over twelve years, a dozen cameras, sixty tags and
/// mixed status flags, written straight into the index (no files). Titles, cameras, dates, tags and flags follow the
/// seed; ids and hashes are random.
/// mixed status flags, written straight into the index (no files). Everything but ids and hashes follows the seed, so
/// every run measures the same library.
/// </summary>
internal static class SyntheticLibrary
{
@@ -75,14 +75,15 @@ internal static class SyntheticLibrary
});
}
foreach (var s in sequences) await db.Sequences.UpsertAsync(s, context.Cancellation);
await db.Frames.BulkInsertAsync(sequences.SelectMany(s => Frames(s, seed)), context.Cancellation);
await db.Frames.BulkInsertAsync(sequences.SelectMany((s, i) => Frames(s, seed, i)), context.Cancellation);
context.Log($"perf: built {Sequences:N0} sequences / {Photos:N0} photos in {watch.Elapsed.TotalSeconds:F1} s");
return archive;
}
private static IEnumerable<Frame> Frames(Sequence sequence, int seed)
private static IEnumerable<Frame> Frames(Sequence sequence, int seed, int index)
{
var random = new Random(HashCode.Combine(seed, sequence.Id));
// Seeded by the sequence's position, not its random id, so every run builds the same frames.
var random = new Random(unchecked((seed * 100_003) + index));
var format = Formats[random.Next(Formats.Length)];
for (var i = 0; i < FramesPerSequence; i++)
{