Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-183249

Carving Mask BitSets created for lower chunk statuses

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: 1.15.2
    • Fix Version/s: 20w21a
    • Labels:
      None
    • Confirmation Status:
      Plausible
    • Category:
      Performance

      Description

      In analyzing heap memory usage, it was noticed that long[] was a serious contender...

      In tracing it back, it was found that BitSet​s used for Carving Masks were the heaviest user, stored as a reference from ProtoChunk, which was linked to the ChunkHolder.

       

      The ChunkHolder is holding a ref from the status future cache.

       

      This is due to the fact that during Chunk Saving, the carving masks are saved regardless of chunk status, so saving creates the 65k BitSet​s and saves them, even at statuses like StructureStart which we have TONS of....

      Then when that ProtoChunk is loaded again, those 65k BitSet​s are loaded into memory and kept around in the cache even when that chunk isn't promoting to FULL.

       

      Fix is pretty simple, don't write CarvingMasks unless they've actually been generated when saving.

       

      for (int l = 0; l < k; ++l) {
          WorldGenStage.Features worldgenstage_features = aworldgenstage_features[l];
      
          // Paper start - don't create carving mask bitsets if not even at that chunk status yet
          BitSet mask = protochunk.getCarvingMaskIfSet(worldgenstage_features);
          if (mask != null) {
              nbttagcompound3.setByteArray(worldgenstage_features.toString(), mask.toByteArray());
          }
          // Paper end
      }
      

        Attachments

          Activity

            People

            Assignee:
            boq [Mojang] Bartosz Bok
            Reporter:
            aikar Aikar
            Votes:
            5 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              CHK: