A refresh no longer links copies by content behind the user's back. After the gate is released, CopyFinder looks for copies whose ids differ: the server's photo lookup (or 1.1's gate and the hints on an older server), session keys, and an exact comparison by manifest, bounded per refresh and remembered in copy_probes so nothing is compared twice while neither side moves. What a pair becomes is the Link matches setting's call: asked by default, linked by itself only as the setting allows, through a compare-and-set that a Keep apart wins. Local detection finds copies inside this PC's archives and never links them. SyncService gives every link its pair, adds Unlink (kept apart, observation kept), marks pairs whose server sequence answers 404 (once per refresh, twice reads deleted, never on an address key or in a 404 sweep), keeps deletion counts current at each comparison, writes an Integrate's agreed details to both sides by content (ApplyAgreedAsync) and queues uploads at a given priority. CopyReviewBuilder assembles what the Compare dialog shows. Refs #73 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
47 lines
1.8 KiB
C#
47 lines
1.8 KiB
C#
using Chronos.Data.Copies;
|
|
using Chronos.Data.Tests.Infrastructure;
|
|
using Chronos.Testing;
|
|
|
|
namespace Chronos.Data.Tests.Perf;
|
|
|
|
/// <summary>
|
|
/// Owner review 6 (#73), design §3.4: local detection's SHA-256 join over the 500,000-photo library answers in under 2 s
|
|
/// (every photo unique: the join finds no pair, which is the whole index read). Opt-in: <c>CHRONOS_PERF=1</c>.
|
|
/// </summary>
|
|
[Category("perf")]
|
|
[RequiresEnvironment(PerfGate.Variable)]
|
|
[Serial]
|
|
[Timeout(3_600_000)]
|
|
public abstract class CopyOverlapPerfTests(TestContext context) : RepositoryTest(context)
|
|
{
|
|
public const double BudgetMs = 2_000;
|
|
|
|
[Test]
|
|
public async Task LocalOverlapsAreFoundWithinTheGate()
|
|
{
|
|
var options = await NewOptionsAsync(multiConnection: true);
|
|
await using (var build = await ChronosDatabase.OpenAsync(options, Ct)) await SyntheticLibrary.BuildAsync(build, Context);
|
|
|
|
var db = Own(await ChronosDatabase.OpenAsync(options, Ct));
|
|
var store = new FoundCopyStore(db);
|
|
IReadOnlyList<LocalOverlap> overlaps = [];
|
|
var first = await PerfGate.TimeAsync(async () => overlaps = await store.LocalOverlapsAsync(Ct));
|
|
var again = await PerfGate.MedianAsync(() => store.LocalOverlapsAsync(Ct));
|
|
Context.Log($"perf: {Dialect} local overlaps {first:F0} ms first, {again:F0} ms again (budget {BudgetMs:F0} ms), {overlaps.Count} pairs");
|
|
|
|
Assert.Empty(overlaps);
|
|
Assert.LessOrEqual(first, BudgetMs);
|
|
}
|
|
}
|
|
|
|
public sealed class SqliteCopyOverlapPerfTests(TestContext context) : CopyOverlapPerfTests(context)
|
|
{
|
|
protected override Backend Backend => Backend.SqliteFile;
|
|
}
|
|
|
|
[RequiresEnvironment(PgTestServer.Variable)]
|
|
public sealed class PostgresCopyOverlapPerfTests(TestContext context) : CopyOverlapPerfTests(context)
|
|
{
|
|
protected override Backend Backend => Backend.Postgres;
|
|
}
|