This commit is contained in:
Youmu Liu
2026-03-26 18:02:13 +08:00
parent d960d02972
commit 06e3aa119b
20 changed files with 198 additions and 169 deletions
+10 -7
View File
@@ -40,7 +40,7 @@ namespace StgSharp
// WriteBack 记录被回写的 origin,供驱逐测试断言。
// ====================================================================
internal sealed unsafe class TrackingPredictor : IPrefetchPredict
internal sealed unsafe class TrackingPredictor : IL4Predict
{
private readonly nuint[] _addresses;
@@ -128,7 +128,10 @@ namespace StgSharp
private static unsafe byte L4ReadFirstByte(
L4.CacheLine line
) => *(byte*)line.Address;
)
{
return *(byte*)line.Address;
}
// ================================================================
// P1-2 AgeAll_SaturatesAt3
@@ -168,7 +171,7 @@ namespace StgSharp
for (int i = 0; i < snap.MaxId; i++) {
L4Assert(
snap.RrpvSnapshot[i] == 0,
$"RrpvSnapshot[{i}] should be 0 right after Map, " + $"got {snap.RrpvSnapshot[i]}");
$"{$"RrpvSnapshot[{i}] should be 0 right after Map, "}{$"got {snap.RrpvSnapshot[i]}"}");
}
}
@@ -191,7 +194,7 @@ namespace StgSharp
if (snap.RrpvSnapshot[i] != 3)
{
L4Assert(false,
$"RrpvSnapshot[{i}] == {snap.RrpvSnapshot[i]}, " + "expected 3 after 4x AgeAll (saturation failure or overflow)");
$"{$"RrpvSnapshot[{i}] == {snap.RrpvSnapshot[i]}, "}expected 3 after 4x AgeAll (saturation failure or overflow)");
allSaturated = false;
}
}
@@ -305,7 +308,7 @@ namespace StgSharp
}
L4Assert(
evictedOrigin != nuint.Zero,
$"WriteBack origin should be a batch1 address, " + $"WriteBackLog=[{string.Join(", ", predictor2.WriteBackLog)}]");
$"{$"WriteBack origin should be a batch1 address, "}{($"WriteBackLog=[{string.Join(", ", predictor2.WriteBackLog)}]")}");
// 断言 c: SwissTable 中已不含该 origin
L4Assert(
@@ -320,11 +323,11 @@ namespace StgSharp
remapped.Dispose();
L4Assert(
refill == 0xCC,
$"Re-mapped evicted line should be re-prefetched with 0xCC, " + $"got 0x{refill:X2} (0xAA = stale data not evicted)");
$"{$"Re-mapped evicted line should be re-prefetched with 0xCC, "}{($"got 0x{refill:X2} (0xAA = stale data not evicted)")}");
if (_l4FailCount == 0) {
Console.WriteLine(
$"PASS (evicted 0x{evictedOrigin:X}, remain={remain}, " + $"WriteBack×{predictor2.WriteBackLog.Count})");
$"{($"PASS (evicted 0x{evictedOrigin:X}, remain={remain}, ")}{$"WriteBack×{predictor2.WriteBackLog.Count})"}");
}
}
catch (Exception ex)