Skip to content

Conversation

@SirYwell
Copy link
Member

Overview

Description

There are multiple things that can be improved about the state applying pattern:

  1. Use BV3#getBlock(Extent) instead of Extent#getBlock(BV3)
  2. Avoid costly computeIfAbsent. Not only has that method a very high complexity, but the capturing lambda causes an allocation every time
  3. Instead of iterating over the entry set of a map, use an array of specialized entry types

Here is a diff showcasing how this change affects the performance of the applyBlock method when running //set ^[snowy=true] on a selection of 2048x320x2048:
stateapplyingpattern-diff

Submitter Checklist

  • Make sure you are opening from a topic branch (/feature/fix/docs/ branch (right side)) and not your main branch.
  • Ensure that the pull request title represents the desired changelog entry.
  • New public fields and methods are annotated with @since TODO.
  • I read and followed the contribution guidelines.

@SirYwell SirYwell requested a review from a team as a code owner March 16, 2025 14:19
@dordsor21 dordsor21 requested a review from a team March 21, 2025 12:16
@NotMyFault NotMyFault merged commit 76d6a64 into main Mar 23, 2025
9 checks passed
@NotMyFault NotMyFault deleted the perf/state-applying-pattern branch March 23, 2025 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants