perf(grpc-data): H2 review 6 - Implemented(target) once per node; history serving cached per source

Metadata no longer rebuilds the history view per node x operation (and checks the ACL before the tagname, the
ingress order); OriginHistoryPort caches its served-aggregate set per historian source instance.
This commit is contained in:
Joseph Doherty
2026-11-23 22:06:02 -05:00
parent 3c5cbea931
commit 6f1faaeb0b
3 changed files with 33 additions and 8 deletions
@@ -284,6 +284,17 @@ public sealed class GrpcDataHistoryWireTests
denied.StatusCode.ShouldBe(StatusCode.PermissionDenied);
}
[Fact]
public async Task A_v1_metadata_call_does_not_rebuild_the_history_view_per_node_and_operation()
{
await using var origin = new RealOrigin();
var before = origin.History!.ServingReads;
var lookups = origin.History.HistorizedLookups;
await origin.DriveAsync("GetMetadata", new Metadata()); // 11 views, header-less
(origin.History.ServingReads - before).ShouldBeLessThanOrEqualTo(16, "at most about one per node, not one per node and operation");
(origin.History.HistorizedLookups - lookups).ShouldBeLessThanOrEqualTo(11);
}
[Fact]
public async Task Origin_memory_is_bounded_per_request_and_per_principal_and_nothing_is_lost()
{
@@ -381,7 +392,11 @@ internal sealed class FakeHistoryPort : IOriginHistoryPort
private readonly TaskCompletionSource _entered = new(TaskCreationOptions.RunContinuationsAsynchronously);
private readonly ConcurrentDictionary<string, bool> _issued = new();
public OriginHistoryServing? Serving { get; set; } = new(["Average", "Count"], 10);
private OriginHistoryServing? _serving = new(["Average", "Count"], 10);
private int _servingReads;
public OriginHistoryServing? Serving { get { Interlocked.Increment(ref _servingReads); return _serving; } set => _serving = value; }
/// <summary>How often the origin asked what it can serve.</summary>
public int ServingReads => Volatile.Read(ref _servingReads);
public IReadOnlyList<OriginHistorySample> Samples { get; set; } = [];
public byte[]? Continuation { get; set; }
public bool WiringFault { get; set; }