Skip to content

Reduce arena preparation memory spikes - #117

Open
GerwinVerkerk wants to merge 1 commit into
ShaneBeeStudios:masterfrom
UnitedFactions:fix/lazy-arena-preparation
Open

GerwinVerkerk wants to merge 1 commit into
ShaneBeeStudios:masterfrom
UnitedFactions:fix/lazy-arena-preparation

Conversation

@GerwinVerkerk

Copy link
Copy Markdown

Describe your changes

Stream arena blocks lazily during preparation instead of first allocating a List<Location> containing every block in the arena.

For a 1000 x 100 x 1000 arena, the previous implementation attempted to create 100 million Location objects before the per-tick preparation task began. That creates a large, immediate heap spike in GameRegion#getBlocks() and can freeze or exhaust the server before rollback logging has made progress.

This change:

  • adds a lazy block iterator to GameRegion;
  • makes PrepareArenaTask consume blocks directly at the configured per-tick rate;
  • applies predicates while iterating, so bonus-chest-only scans are lazy too;
  • preserves the existing traversal order, rollback snapshots, bonus block handling, and scheduler cadence.

This removes the eager location-list allocation reported in #113. Rollback itself can still retain many BlockState snapshots for very large arenas; changing that storage model is a separate architectural concern and is intentionally outside this PR.

Verification

  • ./gradlew build
  • git diff --check
  • Build completed successfully against the repository's Paper 26.2 configuration.

Target Minecraft Versions: all currently supported versions
Requirements: none
Related Issues: #113

Checklist before requesting a review

Worked on by

  • United Factions Manager

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant