Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,16 @@ public int configMaxAutoSavePerTick(final ServerLevel world) {
return ConfigHolder.getConfig().chunkSaving.maxAutoSaveChunksPerTick;
}

@Override
public int configMinUnlockChunksPerTick(final ServerLevel world) {
return ConfigHolder.getConfig().chunkSaving.minUnloadChunksPerTick;
}

@Override
public double configMaxUnlockChunksPerTickFactor(final ServerLevel world) {
return ConfigHolder.getConfig().chunkSaving.maxUnloadChunksPerTickFactor;
}

@Override
public boolean configFixMC159283() {
return ConfigHolder.getConfig().bugFixes.fixMC159283;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,16 @@ public int configMaxAutoSavePerTick(final ServerLevel world) {
return ConfigHolder.getConfig().chunkSaving.maxAutoSaveChunksPerTick;
}

@Override
public int configMinUnlockChunksPerTick(final ServerLevel world) {
return ConfigHolder.getConfig().chunkSaving.minUnloadChunksPerTick;
}

@Override
public double configMaxUnlockChunksPerTickFactor(final ServerLevel world) {
return ConfigHolder.getConfig().chunkSaving.maxUnloadChunksPerTickFactor;
}

@Override
public boolean configFixMC159283() {
return ConfigHolder.getConfig().bugFixes.fixMC159283;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ public <T extends Entity> void addToGetEntities(final Level world, final EntityT

public int configMaxAutoSavePerTick(final ServerLevel world);

public int configMinUnlockChunksPerTick(final ServerLevel world);

public double configMaxUnlockChunksPerTickFactor(final ServerLevel world);

public boolean configFixMC159283();

// support for CB chunk mustNotSave
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,28 @@ public static final class ChunkSaving {
public Duration autoSaveInterval = Duration.parse("5m");

@Serializable(
comment = """
comment = """
The maximum number of chunks to incrementally autosave each tick. If
the value is <= 0, then no chunks will be incrementally saved.
"""
)
public int maxAutoSaveChunksPerTick = 12;

@Serializable(
comment = """
The minimum number of chunks to unload each tick.
See maxUnloadChunksPerTickFactor for more.
"""
)
public int minUnloadChunksPerTick = 50;

@Serializable(
comment = """
The factor to determine maximum unload chunks per tick. The final value is
current pending unload chunks * maxUnloadChunksPerTickFactor .
"""
)
public double maxUnloadChunksPerTickFactor = 0.05;
}

@Serializable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,10 @@ public void processUnloads() {
// We do need to process updates here so that any addTicket that is synchronised before this call does not go missed.
this.processTicketUpdates();

final int toUnloadCount = Math.max(50, (int)(unloadCountTentative * 0.05));
final int toUnloadCount = Math.max(
PlatformHooks.get().configMinUnlockChunksPerTick(this.world),
(int) (unloadCountTentative * PlatformHooks.get().configMaxUnlockChunksPerTickFactor(this.world))
);
int processedCount = 0;

for (final ChunkUnloadQueue.SectionToUnload sectionRef : unloadSectionsForRegion) {
Expand Down