Skip to content

Speculative portal chunk loading#13642

Draft
NewwindServer wants to merge 2 commits intoPaperMC:mainfrom
NewwindServer:speculative-portal-chunk-loading
Draft

Speculative portal chunk loading#13642
NewwindServer wants to merge 2 commits intoPaperMC:mainfrom
NewwindServer:speculative-portal-chunk-loading

Conversation

@NewwindServer
Copy link
Contributor

Nether portals loading chunks on the main thread is a big cause of lag, freezing the server upwards of 1-2 seconds.
Since there isn't an easy way to load these chunks async, we can instead preload them, as it takes some time for survival players to travel through a portal.
This shouldn't break any vanilla behavior as the chunk ticket does not simulate.

This current PR is a draft because the chunk loading behavior is a bit strange currently:

  • The server seems to still block the main thread for some time despite us preloading the chunks.
  • Despite passing Priority.HIGHEST to addTicketAndLoadWithRadius, it takes several seconds for the server to start preloading the chunks.
  • Printing out all ChunkLoadEvents, there is a chunk load event called for the correct chunk when speculating, then it is called again when the player goes through the actual portal, our chunk ticket should have kept the chunk loaded for long enough that it should only have fired 1 ChunkLoadEvent.

Do you guys have any ideas?

@NewwindServer NewwindServer requested a review from a team as a code owner February 16, 2026 23:46
@github-project-automation github-project-automation bot moved this to Awaiting review in Paper PR Queue Feb 16, 2026
@NewwindServer NewwindServer marked this pull request as draft February 16, 2026 23:46
public int portalSearchRadius = 128;
public int portalCreateRadius = 16;
public boolean netherPortalPreloading;
public int netherPortalPreloadingTicksBefore = 30;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you use IntOr.Disabled and have a single config option instead of 2?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Awaiting review

Development

Successfully merging this pull request may close these issues.

2 participants