feat(diagnostics): complete residency pressure ledger
Complete Slice D4 by adding aggregate lifecycle occupancy and traffic facts, validating physical source reports, and including decoded audio under the typed startup budget. Exercise every domain under forced pressure and retain the real cache/fence convergence gates.
This commit is contained in:
parent
f2644d42c2
commit
1853a57c12
15 changed files with 297 additions and 15 deletions
|
|
@ -164,12 +164,41 @@ internal readonly record struct ResidencyDomainSnapshot(
|
|||
long CapacityBytes = 0,
|
||||
long UsedBytes = 0,
|
||||
long LargestFreeBytes = 0,
|
||||
long Hits = 0,
|
||||
long Misses = 0,
|
||||
long Evictions = 0)
|
||||
{
|
||||
public long FreeBytes => Math.Max(0, CapacityBytes - UsedBytes);
|
||||
|
||||
public long FragmentedFreeBytes =>
|
||||
Math.Max(0, FreeBytes - LargestFreeBytes);
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (!Enum.IsDefined(Domain))
|
||||
throw new ArgumentOutOfRangeException(nameof(Domain));
|
||||
ArgumentOutOfRangeException.ThrowIfNegative(EntryCount);
|
||||
ArgumentOutOfRangeException.ThrowIfNegative(OwnerCount);
|
||||
Charges.Validate();
|
||||
ArgumentOutOfRangeException.ThrowIfNegative(BudgetBytes);
|
||||
ArgumentOutOfRangeException.ThrowIfNegative(CapacityBytes);
|
||||
ArgumentOutOfRangeException.ThrowIfNegative(UsedBytes);
|
||||
ArgumentOutOfRangeException.ThrowIfNegative(LargestFreeBytes);
|
||||
ArgumentOutOfRangeException.ThrowIfNegative(Hits);
|
||||
ArgumentOutOfRangeException.ThrowIfNegative(Misses);
|
||||
ArgumentOutOfRangeException.ThrowIfNegative(Evictions);
|
||||
if (UsedBytes > CapacityBytes && CapacityBytes != 0)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"{Domain} residency uses {UsedBytes} bytes from "
|
||||
+ $"{CapacityBytes} bytes of physical capacity.");
|
||||
}
|
||||
if (LargestFreeBytes > CapacityBytes)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"{Domain} largest free range exceeds physical capacity.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal readonly record struct ResidencySnapshot(
|
||||
|
|
@ -177,7 +206,35 @@ internal readonly record struct ResidencySnapshot(
|
|||
ResidencyCharges TotalCharges)
|
||||
{
|
||||
public ResidencyDomainSnapshot Get(ResidencyDomain domain) =>
|
||||
Domains.FirstOrDefault(snapshot => snapshot.Domain == domain);
|
||||
Domains?.FirstOrDefault(snapshot => snapshot.Domain == domain)
|
||||
?? default;
|
||||
|
||||
public int TotalEntries =>
|
||||
Domains?.Sum(static snapshot => snapshot.EntryCount) ?? 0;
|
||||
|
||||
public int TotalOwners =>
|
||||
Domains?.Sum(static snapshot => snapshot.OwnerCount) ?? 0;
|
||||
|
||||
public long TotalBudgetBytes =>
|
||||
Domains?.Sum(static snapshot => snapshot.BudgetBytes) ?? 0;
|
||||
|
||||
public long TotalCapacityBytes =>
|
||||
Domains?.Sum(static snapshot => snapshot.CapacityBytes) ?? 0;
|
||||
|
||||
public long TotalUsedBytes =>
|
||||
Domains?.Sum(static snapshot => snapshot.UsedBytes) ?? 0;
|
||||
|
||||
public long TotalFragmentedFreeBytes =>
|
||||
Domains?.Sum(static snapshot => snapshot.FragmentedFreeBytes) ?? 0;
|
||||
|
||||
public long TotalHits =>
|
||||
Domains?.Sum(static snapshot => snapshot.Hits) ?? 0;
|
||||
|
||||
public long TotalMisses =>
|
||||
Domains?.Sum(static snapshot => snapshot.Misses) ?? 0;
|
||||
|
||||
public long TotalEvictions =>
|
||||
Domains?.Sum(static snapshot => snapshot.Evictions) ?? 0;
|
||||
}
|
||||
|
||||
internal interface IResidencyDomainSource
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ internal sealed class DelegateResidencyDomainSource(
|
|||
throw new InvalidOperationException(
|
||||
$"Residency source {Domain} returned {snapshot.Domain}.");
|
||||
}
|
||||
snapshot.Validate();
|
||||
return snapshot;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ public sealed record ResidencyBudgetOptions(
|
|||
int StandaloneUnownedEntries,
|
||||
long AnimationBytes,
|
||||
int AnimationEntries,
|
||||
long AudioBytes,
|
||||
long AlphaScratchBytes)
|
||||
{
|
||||
public const long MiB = 1024L * 1024L;
|
||||
|
|
@ -36,6 +37,7 @@ public sealed record ResidencyBudgetOptions(
|
|||
StandaloneUnownedEntries: 256,
|
||||
AnimationBytes: 64 * MiB,
|
||||
AnimationEntries: 512,
|
||||
AudioBytes: 32 * MiB,
|
||||
AlphaScratchBytes: 16 * MiB);
|
||||
|
||||
internal static ResidencyBudgetOptions Parse(
|
||||
|
|
@ -80,6 +82,9 @@ public sealed record ResidencyBudgetOptions(
|
|||
AnimationEntries: ParseCount(
|
||||
env("ACDREAM_RESIDENCY_ANIMATION_ENTRIES"),
|
||||
defaults.AnimationEntries),
|
||||
AudioBytes: ParseMiB(
|
||||
env("ACDREAM_RESIDENCY_AUDIO_MIB"),
|
||||
defaults.AudioBytes),
|
||||
AlphaScratchBytes: ParseMiB(
|
||||
env("ACDREAM_RESIDENCY_ALPHA_SCRATCH_MIB"),
|
||||
defaults.AlphaScratchBytes));
|
||||
|
|
@ -110,4 +115,3 @@ public sealed record ResidencyBudgetOptions(
|
|||
? count
|
||||
: fallback;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -638,6 +638,7 @@ internal sealed class ResidencyManager
|
|||
LogicalBytes: current.LogicalBytes,
|
||||
CpuPreparedBytes: current.CpuPreparedBytes,
|
||||
DecodedBytes: current.DecodedBytes,
|
||||
ScratchBytes: current.ScratchBytes,
|
||||
PinnedBytes: current.PinnedBytes,
|
||||
RetiringBytes: checked(
|
||||
current.GpuRequestedBytes
|
||||
|
|
|
|||
|
|
@ -1316,14 +1316,20 @@ namespace AcDream.App.Rendering.Wb
|
|||
return bytes;
|
||||
}
|
||||
|
||||
internal ResidencyDomainSnapshot CapturePreparedMeshResidency() =>
|
||||
new(
|
||||
internal ResidencyDomainSnapshot CapturePreparedMeshResidency()
|
||||
{
|
||||
CacheStats stats = _cpuMeshCache.Stats;
|
||||
return new ResidencyDomainSnapshot(
|
||||
ResidencyDomain.PreparedMeshCpu,
|
||||
EntryCount: _cpuMeshCache.Count,
|
||||
OwnerCount: 0,
|
||||
Charges: new ResidencyCharges(
|
||||
CpuPreparedBytes: _cpuMeshCache.ResidentBytes),
|
||||
BudgetBytes: _cpuMeshCache.ByteCapacity);
|
||||
BudgetBytes: _cpuMeshCache.ByteCapacity,
|
||||
Hits: stats.Hits,
|
||||
Misses: stats.Misses,
|
||||
Evictions: stats.Evictions);
|
||||
}
|
||||
|
||||
internal ResidencyDomainSnapshot CaptureStagingResidency() =>
|
||||
new(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue