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

Spawning causes massive TPS CPU load on a flat world.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: Minecraft 1.14.1, Minecraft 1.14.2 Pre-Release 2, Minecraft 1.14.2 Pre-Release 3, Minecraft 1.14.2 Pre-Release 4, Minecraft 1.14.2
    • Labels:
      None
    • Confirmation Status:
      Confirmed
    • Category:
      (Unassigned)

      Description

      Hi,

      There is a problem with spawning code, which can be clearly visible on the following clip:
      https://youtu.be/GGIoeO5btng

      tl;dr; in 1.14 A LOT has been added to entity contructor, which causes lots of CPU. Most mobs won't spawn anyways, so e.g. initializing their brains etc at Constructor rather than with some init() method afterwards is not a good idea. Second component to the CPU drain are collision checks (even before entity is created). 1.14 collision check code seems to be much more complex comparing to 1.13, and despite 1.13 calling it twice for each mob, one call in 1.14 costs about 10 times more. 

      Reproduction steps: create a flat world with one block (white concrete, why not), press Alt F3, observe TPS graph, ->doMobSpawning false, observe graph.

      Evidences:
      Full code (replaced factory method with simple cow constructor for clarity - no effect on the final result)

      [See Exhibit 1]

      Commented out collision check with predefined BBs (without creating a mob)

      [See Exhibit 2]

      Commented out entity creation code - taking a sample cow instead (so skipping CTOR)

      [See Exhibit 3]

        Attachments

        1. Exhibit 1.png
          Exhibit 1.png
          253 kB
        2. Exhibit 2.png
          Exhibit 2.png
          243 kB
        3. Exhibit 3.png
          Exhibit 3.png
          307 kB

          Issue Links

            Activity

              People

              • Assignee:
                boq [Mojang] Bartosz Bok
                Reporter:
                gnembon Gnembon
              • Votes:
                31 Vote for this issue
                Watchers:
                16 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  CHK: