Skip to content

Cache pipe shapes by connection mask - #5327

Open
Marsietiss wants to merge 1 commit into
GregTechCEu:1.20.1from
Marsietiss:perf/cache-pipe-collision-shapes
Open

Cache pipe shapes by connection mask#5327
Marsietiss wants to merge 1 commit into
GregTechCEu:1.20.1from
Marsietiss:perf/cache-pipe-collision-shapes

Conversation

@Marsietiss

Copy link
Copy Markdown

What

Caches the combined base VoxelShape returned by PipeBlock#getShapes for each possible connection mask.

Implementation Details

Adds a lazily populated 64 entry AtomicReferenceArray<VoxelShape> to each PipeBlock. The six connection bits are used as the cache index and compare-and-set safely publishes shapes when client and server threads query the same block at the same time.

AI Usage

  • No AI driven tools were used for this pull request.
  • Yes AI driven tools were used for this pull request.

Outcome

Removes repeated construction of identical pipe shapes during collision queries.

  • Aggregate time for the affected entities dropped from 12.9% to 3.2%.
  • Average per-entity tick time dropped from approximately 344 μs to 64 μs.

Before: https://observable.tas.sh/p/kRjSS/aggregated
After: https://observable.tas.sh/p/SidOa/aggregated
image
image

How Was This Tested

  • Ran ./gradlew spotlessCheck build against the current 1.20.1 branch.
  • Loaded the same world with the patched GTCEu 7.5.3 jar and captured the profiles.

Potential Compatibility Issues

Should be none

@Marsietiss
Marsietiss requested a review from a team as a code owner August 21, 2026 09:20
@TarLaboratories TarLaboratories added type: bugfix General bug fixes Release: Patch - 0.0.X Smaller changes that either are bug fixes or very minor tweaks. labels Aug 21, 2026
@DilithiumThoride

DilithiumThoride commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Was this cache tested with pipes of different sizes but the same connections? i.e. if a tiny pipe connected N/S caches a collision box, will a huge pipe connected N/S pull the same collision box? or will it generate a new collision box for itself?

@TarLaboratories
TarLaboratories dismissed their stale review August 21, 2026 09:51

sorry i thought PipeBlock had only 1 instance per pipe size

@screret screret left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

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

Labels

1.20.1 Release: Patch - 0.0.X Smaller changes that either are bug fixes or very minor tweaks. type: bugfix General bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants