feat: ChunkStreamer tracks failed chunks to prevent retry storms

This commit is contained in:
2026-06-01 12:04:50 +02:00
parent da051ed413
commit 85a345d6e7
2 changed files with 38 additions and 0 deletions

View File

@@ -29,6 +29,7 @@ public sealed class ChunkStreamer : IDisposable
private readonly PriorityQueue<Vector3i, int> _pendingLoad = new();
private readonly ConcurrentQueue<ChunkJobResult> _completed = new();
private readonly Queue<Vector3i> _pendingUnload = new();
private readonly HashSet<Vector3i> _failed = new();
private Vector3i _lastPlayerChunk = new(int.MinValue, int.MinValue, int.MinValue);
private int _inFlight;
@@ -118,6 +119,7 @@ public sealed class ChunkStreamer : IDisposable
foreach (var pos in target)
{
if (this._failed.Contains(pos)) continue;
if (this._tracked.Add(pos))
{
int priority = (pos.X - p.X) * (pos.X - p.X)
@@ -162,6 +164,7 @@ public sealed class ChunkStreamer : IDisposable
}
this._world.RemoveChunk(pos);
this._ready.Remove(pos);
this._failed.Remove(pos);
Log.Debug("Unloaded {Pos}", pos);
}
}
@@ -190,6 +193,7 @@ public sealed class ChunkStreamer : IDisposable
{
if (result.Error != null || result.Mesh == null)
{
this._failed.Add(result.Pos);
Log.Error(result.Error, "Chunk {Pos} failed to load", result.Pos);
return;
}