mojira.dev
MC-124838

NBT target selector argument is very poorly optimized

I have been messing around with the new NBT target selector, and I noticed this in the built-in debugger:

[00] commandFunctions - 18.26%/18.26%
[01] |   minecraft:tick - 99.53%/18.18%
[02] |   |   execute as @e[nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",tag:{Unbreakable:1b,Damage:2}}}] run tag @s add tc_wrench_hold - 26.63%/4.84%

If you look at the performance usage, it seems quite high (26.63%/4.84%!) compared to this example:

[02] |   |   execute as @s[tag=tc_wrench_canuse] at @s[tag=tc_wrench_canuse] if block ~ ~ ~ minecraft:piston[facing=up] run function techcraft:wrench/actions/rotate_piston_0 - 0.90%/0.16%

Comments 2

This has nothing to do with the nbt selector argument. On your first command, you have execute as @e[nbt=...], and on the other command, just @s (so basically nothing). No wonder why one is wait faster than the other. With as @e[nbt=...], you loop through every entity in the world and test their nbt, so really you can't compare both cases.

If you want to point out potential optimizations issues, try to use two very similar commands, in the same controlled environment (like in MC-124072)

Is this still an issue when using comparable selectors?

iLiquid

(Unassigned)

Unconfirmed

Minecraft 18w05a

Retrieved