Skip to content

Commit

Permalink
perf: limit enhanced autosave iteration to avoid issues with high RD
Browse files Browse the repository at this point in the history
  • Loading branch information
ishland committed Feb 9, 2024
1 parent 03c0429 commit 88a605c
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public abstract class MixinThreadedAnvilChunkStorage implements IThreadedAnvilCh

@Shadow @Final private ThreadExecutor<Runnable> mainThreadExecutor;

@Unique
private static final int c2me$maxSearchPerCall = 128;

@Unique
private ObjectBidirectionalIterator<Long2ObjectMap.Entry<ChunkHolder>> c2me$saveChunksIterator;
@Unique
Expand All @@ -51,8 +54,9 @@ private void onTick(CallbackInfo ci) {
c2me$enhancedAutoSaveUpdateIterator();
}

int i = 0;
final ObjectBidirectionalIterator<Long2ObjectMap.Entry<ChunkHolder>> iterator = this.c2me$saveChunksIterator;
while (iterator.hasNext()) {
while (iterator.hasNext() && (i ++) < c2me$maxSearchPerCall) {
final Long2ObjectMap.Entry<ChunkHolder> entry = iterator.next();
final long pos = entry.getLongKey();
final ChunkHolder chunkHolder = entry.getValue();
Expand Down

0 comments on commit 88a605c

Please sign in to comment.