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

"limit" selector parameter with "arbitrary" sorting does not stop searching early

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 22w46a
    • 1.19.2
    • None
    • Confirmed
    • Commands, Performance
    • Important

      During development of 1.13, Dinnerbone made strong indications that the limit selector parameter had performance implications: including it would allow arbitrary-sort selectors to short-circuit, returning early once sufficient entities pass the criteria, without the need to check all entities.

      This has actually never worked. @e[limit=1] performs identically to @e in all versions since 1.13.

      How to reproduce

      Download and open the attached world. It's a 1.13 world, so should load and work in all versions since. There are 512 armor stands.

      Pull the lever on the left, which runs an execute if entity command 10,000 times per tick, using limit=1. Notice the state-of-the-art redstone repeaters measuring server performance on the right.

      Now turn that lever off and pull the lever on the right, which runs the same command but without limit=1. Notice identical server performance, indicating that the limit=1 is not optimized.

        1. image-2022-10-08-19-28-21-650.png
          23 kB
          [Mod] tryashtar
        2. image-2022-10-08-19-28-54-595.png
          30 kB
          [Mod] tryashtar

            slicedlime [Mojang] slicedlime
            tryashtar [Mod] tryashtar
            Votes:
            8 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: