perf(streaming): quiesce retired generations and budget teardown

Publish the retail blocking-for-cells edge before deferred recenter work, freeze old-world presentation/simulation/audio, and advance full-window retirement from exact metered entity and owner cursors. This removes synchronous portal teardown without allowing retained owners to remain observable.
This commit is contained in:
Erik 2026-07-24 18:29:52 +02:00
parent b8f6317fe1
commit bb16f74fd4
38 changed files with 1691 additions and 170 deletions

View file

@ -137,6 +137,7 @@ public sealed class LandblockPresentationPipelineTests
var recenter = new StreamingOriginRecenterCoordinator(controller, origin);
Assert.False(recenter.Begin(0x22, 0x23, isSealedDungeon: false));
controller.Tick(0x19, 0x19);
Assert.Equal((0x19, 0x19), (origin.CenterX, origin.CenterY));
Assert.False(state.IsLoaded(centerId));
@ -144,12 +145,11 @@ public sealed class LandblockPresentationPipelineTests
Assert.Equal(1, controller.PendingRetirementCount);
Assert.Equal(2, controller.LastFullWindowRetirementLandblockCount);
controller.Tick(0x19, 0x19);
Assert.Empty(enqueued);
Assert.True(neighborAttempts >= 2);
Assert.Equal(1, neighborAttempts);
failNeighbor = false;
Assert.True(recenter.Advance());
Assert.True(Converge(recenter, controller, 0x19, 0x19));
Assert.Equal((0x22, 0x23), (origin.CenterX, origin.CenterY));
Assert.Equal(0, controller.PendingRetirementCount);
@ -187,12 +187,13 @@ public sealed class LandblockPresentationPipelineTests
var recenter = new StreamingOriginRecenterCoordinator(controller, origin);
Assert.False(recenter.Begin(0x40, 0x41, isSealedDungeon: false));
controller.Tick(0x30, 0x30);
Assert.Equal((0x30, 0x30), (origin.CenterX, origin.CenterY));
Assert.True(state.IsLoaded(landblockId));
Assert.Equal(0, controller.PendingRetirementCount);
failClear = false;
Assert.True(recenter.Advance());
Assert.True(Converge(recenter, controller, 0x30, 0x30));
Assert.Equal(2, clearAttempts);
Assert.False(state.IsLoaded(landblockId));
@ -234,13 +235,15 @@ public sealed class LandblockPresentationPipelineTests
var recenter = new StreamingOriginRecenterCoordinator(controller, origin);
Assert.False(recenter.Begin(0x43, 0x44, isSealedDungeon: false));
for (int frame = 0; frame < 16 && observerCalls == 0; frame++)
controller.Tick(0x42, 0x42);
Assert.Equal((0x42, 0x42), (origin.CenterX, origin.CenterY));
Assert.False(state.IsLoaded(firstId));
Assert.False(state.IsLoaded(secondId));
Assert.Equal(1, observerCalls);
Assert.True(recenter.Advance());
Assert.True(Converge(recenter, controller, 0x42, 0x42));
Assert.Equal((0x43, 0x44), (origin.CenterX, origin.CenterY));
Assert.Equal([firstId, secondId], removed);
}
@ -281,13 +284,14 @@ public sealed class LandblockPresentationPipelineTests
var recenter = new StreamingOriginRecenterCoordinator(controller, origin);
Assert.False(recenter.Begin(0x46, 0x46, isSealedDungeon: false));
controller.Tick(0x45, 0x45);
Assert.Same(player, Assert.Single(state.DrainRescued()));
Assert.Equal(1, state.PendingLiveEntityCount);
Assert.Empty(state.Entities);
failRetirement = false;
Assert.True(recenter.Advance());
Assert.True(Converge(recenter, controller, 0x45, 0x45));
Assert.Empty(state.DrainRescued());
state.AddLandblock(new LoadedLandblock(
destinationId,
@ -344,7 +348,7 @@ public sealed class LandblockPresentationPipelineTests
Assert.True(recenter.IsPending);
failRetirement = false;
Assert.True(recenter.Advance());
Assert.True(Converge(recenter, controller, 0x50, 0x50));
Assert.False(recenter.IsPending);
Assert.Equal((0x50, 0x50), (origin.CenterX, origin.CenterY));
@ -384,7 +388,12 @@ public sealed class LandblockPresentationPipelineTests
Assert.False(recenter.Begin(0x60, 0x60, isSealedDungeon: false));
recenter.Reset();
failRetirement = false;
Assert.True(recenter.Advance());
Assert.True(Converge(
recenter,
controller,
0x52,
0x52,
insideDungeon: true));
Assert.Equal((0x52, 0x52), (origin.CenterX, origin.CenterY));
Assert.Equal([(sourceId, LandblockStreamJobKind.LoadNear)], enqueued);
@ -423,7 +432,7 @@ public sealed class LandblockPresentationPipelineTests
Assert.False(recenter.Begin(0x54, 0x54, isSealedDungeon: true));
recenter.Reset(sessionEnding: true);
failRetirement = false;
Assert.True(recenter.Advance());
Assert.True(Converge(recenter, controller, 0x53, 0x53));
Assert.Empty(enqueued);
Assert.Equal((0x53, 0x53), (origin.CenterX, origin.CenterY));
@ -464,7 +473,7 @@ public sealed class LandblockPresentationPipelineTests
Assert.True(origin.TryInitialize(0x61, 0x62));
failRetirement = false;
Assert.True(recenter.Advance());
Assert.True(Converge(recenter, controller, 0x61, 0x62));
Assert.Equal((0x61, 0x62), (origin.CenterX, origin.CenterY));
}
@ -494,7 +503,7 @@ public sealed class LandblockPresentationPipelineTests
var recenter = new StreamingOriginRecenterCoordinator(controller, origin);
Assert.False(recenter.Begin(0x11, 0x11, isSealedDungeon: false));
Assert.True(recenter.Advance());
Assert.True(Converge(recenter, controller, 0x10, 0x10));
Assert.Equal(1, clearAttempts);
Assert.Equal((0x11, 0x11), (origin.CenterX, origin.CenterY));
@ -537,10 +546,11 @@ public sealed class LandblockPresentationPipelineTests
removed.Add(id);
if (id == firstId)
Assert.False(controller!.IsOriginRecenterRetirementComplete());
});
});
var recenter = new StreamingOriginRecenterCoordinator(controller, origin);
Assert.True(recenter.Begin(0x71, 0x71, isSealedDungeon: false));
Assert.False(recenter.Begin(0x71, 0x71, isSealedDungeon: false));
Assert.True(Converge(recenter, controller, 0x70, 0x70));
Assert.Equal(1, clearCalls);
Assert.Equal([firstId, secondId], removed);
@ -585,7 +595,7 @@ public sealed class LandblockPresentationPipelineTests
Assert.Empty(enqueued);
failRetirement = false;
Assert.True(recenter.Advance());
Assert.True(Converge(recenter, controller, 0x72, 0x72));
controller.Tick(0x73, 0x73);
Assert.Equal(1, controller.NearRadius);
@ -630,6 +640,7 @@ public sealed class LandblockPresentationPipelineTests
Assert.True(recenter.IsPending);
controller.Tick(0x30, 0x30, insideDungeon: true);
Assert.Empty(enqueued);
Assert.False(recenter.Advance());
failDungeonEnqueue = false;
Assert.True(recenter.Advance());
@ -1066,6 +1077,8 @@ public sealed class LandblockPresentationPipelineTests
Assert.True(state.IsNearTier(landblockId));
controller.ForceReloadWindow();
for (int frame = 0; frame < 16 && state.IsLoaded(landblockId); frame++)
controller.Tick(0x80, 0x80);
Assert.False(state.IsLoaded(landblockId));
Assert.Equal(1, presentationCalls);
@ -1276,6 +1289,25 @@ public sealed class LandblockPresentationPipelineTests
Assert.DoesNotContain(forbidden, field, StringComparison.OrdinalIgnoreCase);
}
private static bool Converge(
StreamingOriginRecenterCoordinator recenter,
StreamingController controller,
int observerX,
int observerY,
bool insideDungeon = false,
int maximumFrames = 64)
{
for (int frame = 0; frame < maximumFrames; frame++)
{
if (recenter.Advance())
return true;
controller.Tick(observerX, observerY, insideDungeon);
}
return recenter.Advance();
}
private static LandblockBuild BuildWithShell(
uint landblockId,
params WorldEntity[] entities)