Reduce temporary allocations while scanning ships#561
Conversation
4253c94 to
530283d
Compare
|
There's 2 changes proposed here, first |
|
Now, regarding the second change, replacing 5 pre-allocated JumpBlock native arrays with a single ArrayList: To move forward, I suggest you measure the actual dimensions and blocks of the ships you're having issues with, that'll help understand what's going on here. |
Replace the five bounding-volume JumpBlock arrays with lists pre-sized from the last ship scan volume (or 20% of the bounding box when no scan is available), avoiding both the large upfront allocation and repeated list growth.
530283d to
6bc939f
Compare
|
Split as requested. This PR is now just the pre-sizing: kept the five placeTime buckets, but as lists pre-sized from the last ship scan ( The MutableBlockPos half moved to #564, with the escape covered: the mutable only serves the skip path (air / left-behind, most of the bounding box) and switches to |
Experimental motivation
JumpShip.save()allocates five arrays sized to the full bounding volume before it knows how many blocks will actually move.Scope
MutableBlockPoswhile scanning.jumpBlocksordering.Allocation evidence and limitations
The old code reserved exactly
5 * boundingVolumereference slots. The new code avoids that fixed reservation: 5,000 slots at volume 1,000; 500,000 at volume 100,000; and 5,000,000 at volume 1,000,000. At the default tier-3 per-side limit, a 193-cubed bounding box would have reserved 35,945,285 reference slots. JVM byte cost depends on reference width and array headers.test NO-SOURCE).Manual testing pending
Compare mass, volume, transformer results, final block order, tile data, and successful movement against upstream.