chunk/light.go: optimize light calculations (4400x fewer allocs)#1192
Merged
cqdetdev merged 6 commits intoMay 15, 2026
Conversation
- Replaced linked-list BFS queue with a ring-buffer queue for light propagation (Fill/Spread) to remove per-node heap churn. - Removed iterator-based neighbor traversal in propagation; now uses direct 6-neighbor checks. - Removed small slice allocations in world light orchestration (chunk() and spreadLight()).
Sandertv
reviewed
Feb 25, 2026
Sandertv
left a comment
Member
There was a problem hiding this comment.
Good changes, a ring buffer will definitely help bring down allocations. Got a couple of minor comments
Silentmussle913
approved these changes
May 7, 2026
T14Raptor
previously approved these changes
May 7, 2026
RestartFU
previously approved these changes
May 7, 2026
…ulations # Conflicts: # server/world/chunk/light.go # server/world/chunk/light_area.go
HashimTheArab
dismissed stale reviews from RestartFU, T14Raptor, and cqdetdev
via
May 15, 2026 22:14
aaa2d77
Collaborator
Author
|
I did some more testing after cadet and updated the value to 1024, and named it as a constant to be more clear and easier to change if needed. For anything more than a basic server such as vanilla or skyblock 512 will almost always grow. The difference between 512 and 1024 is negligible (24KiB). 1024 is the safer value, anything past that and the benefit drops quickly. If a less common case needs more than 1024 the queue can still grow normally |
RestartFU
approved these changes
May 15, 2026
cqdetdev
approved these changes
May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Benchmark results
Benchmark Code