Rule complexity breaks OpenHab/Java?

Back in the days of OH2 we discovered that complex maths evaluations like that could become compilation sinkholes. I think each step brings exponential workload.

In particular, integer maths came with a penalty. It seems always better to use Number types (which is essentially the “native” type for DSL) and only force integer results when you have to.

Breaking down an evaluation into simpler steps gives the compiler measurably less work to do.

So

// instead of
var v_B   = ( (360.0 / 365.0) * (v_D - 81) ) * pi180

//try
var interA = 360.0 / 365.0  // why not pre-calculate that constant anyway
var interB = v_D - 81.0
var v_B   = ( interA * interB ) * pi180

EDIT - some discussion here

That was the “old rules engine” but I don’t imagine much has changed for DSL really.

2 Likes