Is it there a system in minetest to execute low priority functions if the main loop is idle?
It should be able to add a function to a queue and the function is executed at the end of a frame, if the frame is idle. If the frame takes longer it should be possible to skip some frames.
I don't know if minetest.after works like this. As far as i know minetest.after calles the functions, idle or not.
It should be more like this
Minetest.queue(1, function()) where the 1 is the maximum time to wait. If it is possible, the function could be called earlier.
I think this might help minetest to increase the performance