Maybe the java experts can comment on this…
Problem: Rules can take 10-20 seconds to trigger if they not have triggered very recently. My theory is that a JIT compiler runs over them before they are executed, and after some time of not using it, the result is purged from memory. Thus it has to be compiled again, which takes time on my Raspi (3+).
My solution: I put this in the rule file that I want to prevent from being recompiled:
rule "keep this thing in memory" //use the compiled code in this rule file every minute when Time cron "0 0/1 * 1/1 * ? *" then logInfo("Motionrules","cron execution to prevent gargabe collection of compiled rules") end
It triggers every minute. Any thoughts on this? I can even replace it with an even less expensive function, and will cost next to nothing in term of processor time. It will block some memory, but it is for stuff that is needed instantly and the motion sensor stuff also triggers regularly, so it will live in memory often.