Skip to content

Fix and speed up light in chunk snapshots - #14342

Open
masmc05 wants to merge 4 commits into
PaperMC:mainfrom
masmc05:faster-snapshots
Open

masmc05 wants to merge 4 commits into
PaperMC:mainfrom
masmc05:faster-snapshots

Conversation

@masmc05

@masmc05 masmc05 commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

This PR speeds up the creation of chunk snapshots that contain light data and, more importantly, reduces the memory footprint of both the creation process and the stored snapshots themselves (empty DataLayers now store only the preset instead of a byte array). It felt odd that a snapshot holding less information was more expensive than NMS SerializableChunkData#copyOf

As a comparison, on a randomly generated force loaded world (chunks with tile entities ignored, as it would be unfair to SerializableChunkData#copyOf), via chunk.getChunkSnapshot(true, true, true, true)

main SerializableChunkData#copyOf faster-snapshots
time per call 5.54 µs 4.17 µs 2.67 µs
calls per second 180.5k 239.6k 374.4k
KiB per call 122.89 KiB 60.43 KiB 43.38 KiB
CPU Alloc
main 3dWgAw1Qyq BR1g2zpnut
faster-snapshots aBF66G22GF CL0VM1RuyP
copyOf jSsmUz9fFu EOmMRQE1m6

During consistency testing I also noticed that ChunkSnapshot#getBlockSkyLight didn't match Block#getLightFromSky(), which now would also be fixed by this PR

@masmc05
masmc05 requested a review from a team as a code owner October 3, 2026 14:20
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.

1 participant