Closed p-ouellette closed 5 years ago
On my tests (w/ LuaJIT), get_filtered_items
is ~250% slower since https://github.com/minetest-mods/craftguide/commit/fc2d2e585c464fe1892cb778c0bd83b04deae2dd.
It's even worse with your changes, ~350% slower (up to 130+ ms).
This might be faster if updating discovered items gets moved out of the progressive filter. Doing that would make a much bigger difference in any case.
Go for it then.
I didn't benchmark anything but I can't detect any difference in performance between this commit, https://github.com/minetest-mods/craftguide/commit/fc2d2e585c464fe1892cb778c0bd83b04deae2dd and https://github.com/minetest-mods/craftguide/commit/4560457504a377fc84f5435a38fcc99eb87e4372. Maybe the performance regression you noticed was due to https://github.com/minetest-mods/craftguide/commit/c1b1bef263f8f8889e1303b0678f17ec263d942b? That commit does make a pretty big difference for me.
get_filtered_items
callsapply_recipe_filters
for each of theinit_items
and the progressive filter updates the discovered items. So the discovered items get updated hundreds of times every time the guide is opened. Updating discovered items outside of the filter should fix this. Maybe a globalstep, but updating all players at the same time could be problematic.At e6268a395f7309a2bd16fd3ad8f59fa92b202ad4 the guide opens instantly and at c1b1bef263f8f8889e1303b0678f17ec263d942b the delay is very noticable.