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

TnT Explosion Performance has dropped significantly in newer versions

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.21.1, 24w35a
    • None
    • Community Consensus
    • Entities, Performance
    • Normal
    • Platform

      Through a meta analysis of various minecraft versions and a simple test case involving 100 TnT exploding every 4 gameticks there seems to have been a significant decline in the performance of the TnT explosion code starting in version 1.20.3 and continuing to the latest release. This can be seen in the attatched screenshots showing the milliseconds per tick (/50 ms) of the same test case in different versions

      Snapshot 24w33a improved the performance slightly however it still remains at least 2x worse than in 1.20.2 which was found the be the last version where explosion code was most performant in the recent update pool.

      Savva looked into the code and found 1.20.3 introduced 2 lag causes to explosion code:

      • calculating the exposure twice for each entity, but it is already fixed as stated in MC-272414 and after looking at code and testing in game we can verify that this specific issue is indeed fixed.
      • something within the block removal logic (its interactWithBlocks method in ServerExplosion.java). We're not sure that there is only one lag causer within, but we can verify that the lag comes from somewhere there, as it is the only part of explosion code which changed significantly from 1.20.2 to 24w33a
        To verify that the issue lies within the block removal, one can use the same setup as shown in the screenshots above, but with a liquid source where the explosions happen, that way each explosion will collect no block positions for blocks to be exploded, thus skipping almost the entire block removal part of the explosion but not the other parts of the explosion, and indeed from our testing there is no lag difference in between 1.20.2 and 24w34a with water present.
        Yet without water the lag difference between versions is about x1.5

      100 TnT explosions is a relatively moderate amount in the average players gameplay environment. As shown in older versions such as 1.19.4 and 1.20.2 this amount of TnT would only consume half of the computation time for my particular machine that is possibly better than what most players could afford.

      Proliferation of Minecraft's code without consideration for the impacts on performance threatens to push newer players on lower end systems out of the Minecraft community and so these optimization issues should be taken with great concern.

        1. 2024-08-29_12.40.20.png
          2024-08-29_12.40.20.png
          499 kB
        2. 2024-08-29_12.41.40.png
          2024-08-29_12.41.40.png
          499 kB
        3. 2024-08-29_12.48.00.png
          2024-08-29_12.48.00.png
          487 kB
        4. 2024-08-29_12.50.04.png
          2024-08-29_12.50.04.png
          475 kB
        5. 2024-08-29_12.55.03.png
          2024-08-29_12.55.03.png
          533 kB

            Unassigned Unassigned
            cubicmetre
            Votes:
            11 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              CHK: