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

Item data serialization is significantly slower than before

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 1.20.5 Pre-Release 3
    • 1.20.5 Pre-Release 1
    • None
    • Confirmed
    • Commands, Performance
    • Important
    • Platform

      When an item with a lot of data is in your inventory, the act of simply checking the player's NBT data causes a lot of lag.

      In the example I give in the reproduction steps, the data pack uses three very simple execute if data commands every tick, which in combination with a book with about 250 pages of data in your inventory, makes the game nearly unplayable. This was not the case in 1.20.4, where you can't even tell the difference.

      How to reproduce:

      1. Create a world in 1.20.4 and include attached the data pack.
        The data pack includes a ticking file with the following code:
        execute if data entity @p warden_spawn_tracker
        execute if data entity @p warden_spawn_tracker
        execute if data entity @p warden_spawn_tracker 
      2. Measure the ms/tick when you don't have anything with a lot of data in your inventory.
      3. Give yourself a book with a lot of data, by doing /loot give @s loot namespace:old
      4. While holding the book, compare the ms/tick to how it was before. There shouldn't be any noticeable difference.
      5. Create a world in version 1.20.5-pre1 and repeat steps 1-2.
      6. Give yourself a book with a lot of data, by doing /loot give @s loot namespace:new
      7. Notice how the ms/tick now spikes and causes significant server lag. It's amplified even further while holding the item, most likely due to SelectedItem existing when doing so.

      These are the results I got when testing:

        1.20.4 1.20.5-pre1
      No book in inventory ~7 ms/tick ~5 ms/tick
      Book in hand Still ~7 ms/tick ~50 ms/tick

            gegy1000 [Mojang] Gegy
            Ellivers Ellivers
            Votes:
            5 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: