Performance of rules in OpenHAB3 (general question)

This is not a request for support with any issue and simply a general question.
Back in the day, when OpenHAB 3 was still in it’s early stages of planning, I seem to remember talk of the desire to remove the Xbase and Xtend components of OpenHAB because they caused slow performance. I could just be not remembering correctly about this but I thought one of the important aspects of developing the next generation rules engine was to eliminate the Xbase and Xtend components.
My question is if I’m recalling correctly, did the Xbase and Xtend components get removed? If so, does running DSL rules cause these components to be loaded? I think I recall that OpenHAB 3 interprets DSL rules and converts them to json (??? I think)
I know the benefits of the new rules engine not being constrained by the number of rules threads and much greater versatility and heard OpenHAB 3 is much quicker.
Feel free to correct me and/or discuss

No. It stores them in JSON format, but they’re still Xtend rules DSL code, just wrapped in JSON.

(some dev please correct me if I’m wrong with my following statement)

Unlike one specific developer insisted on by the time this was discussed, Xtend code compilation/execution speed isn’t slow.
Well maybe yes slow compared to alternatives but not really slow in total figures.
His proposal didn’t make it into OH3 so that’s still the same amount of Xtend in there, more or less.

The main bottleneck in OH2 is its old rules engine. If you change things or items there, that results in all rules files to potentially use these items being recompiled which can take several minutes on slower boxes like Raspis and happens on every startup.
With the OH3 switch to the Next Gen Rules Engine, that behavior now is gone, that’s why it’s so much faster now. DSL compilation still is “slow” but the effect of that is nowhere near that of the time you save now because of so much less need for recompilation.

1 Like

thanks for answering that - i was also curious about that.

i’m inching closer to trying OH3.

Can we just bring our rules files straight across and they’ll still work in OH3? (sorry to piggyback)

No, yeah, your DSL rules will run in OH3 no problems!

1 Like

that would be a one David Graeff

Markus’s explanation matches my understanding but I’m no developer in OH so we may have the same misunderstanding. One thing I’ll add is based on my own observations, I believe rules stored in JSONDB (I. e. defined through the UI) are just in time parsed and compiled. This greatly improves OH startup performance but at the cost of a delay the first time a rule is triggered after an OH restart. So as much as the startup performance had imprved with OH 3, it’s even better with JSONDB rules, though some of that imprved improvement is really just delayed. But that counts too because you don’t have to wait for everything.

From what I understand rules will work unless they have some timing elements. There are some provider changes that use different elements.

Not “timing elements”, a different library to represent instants in time. In OH 2.5 instants in time were represented using the Joda library. In OH 3 instants in time are represented using Java’s built in date time library classes. But these only have to do with how instants in time are represented and have nothing to do with performance.


I meant rules using the old instants would not perform.

XTend got better in newer releases and with Java 11. It’s still not fast and personally I wouldn’t want to rely on it ^^.


Thanks for clarifying David and good to see you

Indeed, welcome back David!


Is it possible in OpenHAB 3 to write rules in Java instead of Xtend/DSL? I read somewhere that Rules in Java would bei possible but i don’t know how.

A simple search would have lead you here

1 Like