Excessive recompiling on almost every touch of item and sometimes rules

Running openHAB 5.2.0 on Windows

I notice the last time (months) a lot more recompiling of large numbers of items-files when changing a single item or sometimes changing a rule.

I thought recompiling of items in other item-files should only occur when one of the items in the changed item-file is also in the other rule.

Or could it now be the case that every changed item belonging to a group also lets the other itemfiles recompile when there are items from the same group in that other file? I have some large groups spanning items in multiple groups, for instance for persistence settings.

I notice the recompiling because I get a lot of errors of non existing items in rules and lack of responsiveness of openHAB. It can take several minutes (sometimes up to 10) before the system is quiet again.

Who has an idea or explanation? I tried all kind of debug options using the console but could not get a finger behind the issue.

I don’t know of anything that’s changed in how the config files are loaded and parsed. I definitely would expect certain changes to cascade across multiple files.

It definitely used to be the case that any change to any .item file would cause all the rights to reload. I think it was made smarter than that some time ago. I don’t know how smart it is though. And if a Group gets modified or even if it’s in a fine that’s modified, I could see that cascading to multiple files.

If you can find some sort of pattern it might be worth filling an issue.

Thanks Rich. A pattern is impossible to find. it is not on one items-file but no matter which file, the same happens almost all the time.

It would be nice if someone could shine al ight on the mechanism involved in reloading items.

If you can write down the steps to reproduce it, someone can test it / take a look. Otherwise, afaik, there is no current bug in reloading of items/things.

As for rules, there were recent work (i.e. in the past 2 years) to do with pre-compilation of JS.

It is impossible to write this down. Actually it is simple to reproduce on my machine.

-open an itemfile

-change the name of, or remove or ad a file and save it.

Watch what happens. The utilization of the Windows machine increases and the error messages appear of not found/unrecognized items. Program execution gets slow. Changes in the Sitemap only appears after a long time.

i have the feeling, the longer the items file the more impact the change has. The items are mostly only used in one rule and in the Sitemap. They mostly belong to one group, defined in the top of that file. I think his behaviour has started some month ago, around version 5.1 or a followed milestone or snapshot.

I invested the issue further and it looks the cause is a large items file. I have an items file for my (recently added) MercedesMe binding. It contains more then 100 items. A change cause the “OH-rulesRefresher” from blocking all other activities of openHAB. Other processes time out and cause new errors.

The worst thing that can happen, is making a syntax error in the file. After that (or the correction of the error) it takes very long (5 to 10 minutes) to recover from this situation. All the time the OH-rulesRefresher blocks other rules.

Al the items in the mentioned file are connected to a channel of the binding.

Example:

Number:Dimensionless   MercedesChargeMaxSoc                 "Maximum state of charge"     (gMercedes) {channel="mercedesme:hybrid:7a2ea39a6d:W1NKJ5GB1VF658577:charge#max-soc"}

After I found the cause of this issue, I remeber I had similar problems after adding the Modbus binding, also with large item files.

Below an example of how (ttop on Console) it looks after adding two lines to the item file.

 TID NAME                                     STATE         T-BLOCKED #-BLOCKED    T-CPU  %
-CPU                         3330 RequestManager-Queue-0                   waiting           0.000         1 7:32.640  0.00%
                          186 OH-OSGiEventManager                      timed_waiting     0.000         4 7:10.812  0.00%
                           28 Start Level: Equinox Container: 75ba2... waiting           0.000        96 6:59.593  0.00%
                          178 EMF Reference Cleaner                    waiting           0.000         0 5:30.703  0.00%
                          352 OH-rulesRefresher-1                      blocked        2:48.700       588 3:49.328  0.00%
                          706 nioEventLoopGroup-2-4                    runnable          0.028      7266 3:32.031  0.00%
                         5698 OH-eventexecutor-20-1                    waiting           0.000         3 3:31.703  0.00%
                          375 OH-eventexecutor-7-1                     waiting           0.001       108 2:57.890  0.00%
                          188 Scanner-0                                timed_waiting     0.000         0 2:28.406  0.00%
                          381 OH-eventexecutor-9-1                     waiting           0.052       630 1:14.937  0.00%
                        20616 OH-rule-scheduler-1-1                    blocked        1:18.210         6 1:06.656  0.00%
                          285 pool-23-thread-1                         waiting           0.000         0 1:01.546  0.00%
                          579 OH-usb-serial-discovery-windows-1        timed_waiting     0.000         0   50.484  0.00%
                          282 OH-eventexecutor-2-1                     waiting           0.000         0   49.921  0.00%
                          379 OH-items-1                               timed_waiting     0.000        70   45.109  0.00%
                          383 OH-items-3                               timed_waiting     0.000        65   44.703  0.00%
                          544 OH-items-5                               timed_waiting     0.000        64   44.281  0.00%
                          545 OH-items-6                               timed_waiting     0.000        52   43.296  0.00%

I suppose this is normal behaviour.

Is this an RPi 3 or some other underesourced machine? The key resource to pay attention to is RAM.

I wonder if the YAML format might parse and load more effeciently than the DSL parser. It might be worth a try. You should be able to just select all the Items you want in MainUI and selecty “copy” at the bottom and choose “yaml”. That will copy the full definition of all the selected Items to the clipboard in the new YAML format. You can then paste that to a file as an easy way to convert from DSL to YAML.

It’s what I would expect on a machine that is stuck like you describe. On a healthy system though you should see very few if any threads stuck in a blocked or timed_waiting state.

But it’s the rules, not the Items that are the problem according to this. When you change the Items, the rules need to be reparsed/compiled too often, especially if there are “Member of” triggers.

This is something you come up with.

Change of programming language and environment (VScode) to end up at perharp finding it did not solve anything. At this moment not the way to go for me. But thanks anyway for the suggestion.

Yes my machine is a very efficient low power machine.

Device Name HomeControl
Processor Intel(R) Atom™ x5-Z8350 CPU @ 1.44GHz 1.44 GHz
Installed RAM 4,00 GB (3,81 GB usable)
Storage 115 GB SSD VID:D6 58K722
Graphics Card Intel(R) HD Graphics (114 MB)
System Type 64-bit operating system, x64-based processor

and I am happy with it.

I will try to find out if splitting up the files in smaller portions solves my issues.

The solution to this kind of issues should not always be the use of more powerfull machines. We see where this leads to. The smallest programs now are several gigabytes (up to hundreds like Adobe Acrobat) large and need a very fast and power hungry cpu. In my time we had programs in the size of Megabytes doing about the same on a small Celeron processor!

But Rich, thanks for your information. Always appreciated.

A 64bit-processor running on a 64-bit OS takes about 2x2 the amount of RAM of a 32/32 bit system, so yours is the x86 equivalent of a 1 GB RPi 3.
Which is known to be a problem since OH 5 introduced 64 bit Java.

The main point is still valid, though.
Compile frequency has increased a lot (although I can’t tell either which situations changed).

Plus, compilation is still single threaded. If it was multithreaded, this would improve the situation a lot as about any system has 4+ processor cores, all but one which are unused.

To be clear: it is not about compiling a single rules file on multiple cores in parallel.
It is rather about compiling every rules file in parallel rather than to serialize this process as openHAB did since day 1 and still does.

Thank you Markus for your insights. I’ll consider, when it get too annoying, to replace my OH machine to something more powerful. The other thing is, when everything is running, it only runs on less then 25% of the CPU power. Javaload is only 5%.

If you want to know if the problem is the size of the files, number of Items, or something else then yes “this is what I come up with”.

If you don’t to do experiments (especially something so easy) to find the source of the problem, I can’t/won’t help you. No one is saying you have to stay using YAML forever.

It’s not. But an RPi with only 1 GB RAM is not and has not be sufficient to run OH and has not been for quite some years. Even with the expanded need for RAM with 64-bit, 4 GB should be plenty. You could verify by checking top to see if SWAP is being used.

I have an Intel x5-Z8350 CPU with 4GB. No problems with swapping or whatsoever.

KarafJVM 21%

KarafCPU 37%

KarafCompile (mm:ss) 00:16

KarafThreads 343

KarafHeapSize 948664 B kb

Now I know what triggers my (I mean OH’s) behaviour I can live with it.

Thanks anyway.

top - 20:02:24. OS: Windows 10 10.0, amd64, 4 cpus. Classes: 35422 loaded, 1475 unloaded, 36897 loaded total. Threads: 348, peak: 396, started: 4195.
emory: heap: 644,0 MiB / 2,0 GiB, non heap: 311,6 MiB. GC: G1 Young Generation: 168 col. / 20.933 s, G1 Concurrent GC: 68 col. / 3.751 s, G1 Old Generation: 0 col. / 0.000 s.

No memory problems at all. I assigned 2GB but only half of it get used.

Exactly how big is your items file - how many items are in it? How many items in total do you have on your system?

I could perhaps generate the same number of items on a constrained JVM and see if this can be reproduced to see where the problem lies.

Nice you will perhaps take the effort to reproduce my issue.

In total I have 1310 items in 57 item files.

The concerning item file is with 110 items.

The start of this items file is as follows:

Group gMercedes

Number                 MercedesVehicleLock                  "Lock status/control"         (gMercedes) {channel="mercedesme:hybrid:7a2ea39a6d:W1NKJ5GB1VF658577:vehicle#lock"}
Number                 MercedesVehicleWindows               "Raam-status"      (gMercedes) {channel="mercedesme:hybrid:7a2ea39a6d:W1NKJ5GB1VF658577:vehicle#windows"}
Number                 MercedesVehicleDoorStatus            "Deur-status"                 (gMercedes) {channel="mercedesme:hybrid:7a2ea39a6d:W1NKJ5GB1VF658577:vehicle#door-status"}
Number                 MercedesVehicleIgnition              "Contact"                    (gMercedes) {channel="mercedesme:hybrid:7a2ea39a6d:W1NKJ5GB1VF658577:vehicle#ignition"}
Switch                 MercedesVehicleParkBrake             "Parkeerrem"           (gMercedes) {channel="mercedesme:hybrid:7a2ea39a6d:W1NKJ5GB1VF658577:vehicle#park-brake"}

String                 MercedesVehicleFeatureCapabilities   "Feature capabilities"        (gMercedes) {channel="mercedesme:hybrid:7a2ea39a6d:W1NKJ5GB1VF658577:vehicle#feature-capabilities"}
String                 MercedesVehicleCommandCapabilities   "Command capabilities"        (gMercedes) {channel="mercedesme:hybrid:7a2ea39a6d:W1NKJ5GB1VF658577:vehicle#command-capabilities"}
//String                 MercedesVehicleProtoUpdate           "Proto data update"         (gMercedes) {channel="mercedesme:hybrid:7a2ea39a6d:W1NKJ5GB1VF658577:vehicle#proto-update"}

Contact                MercedesDoorsFrontLeft               "Deur linksvoor[%s]"          (gMercedes) {channel="mercedesme:hybrid:7a2ea39a6d:W1NKJ5GB1VF658577:doors#front-left"}
Contact                MercedesDoorsFrontRight              "Deur rechtsvoor[%s]"         (gMercedes) {channel="mercedesme:hybrid:7a2ea39a6d:W1NKJ5GB1VF658577:doors#front-right"}
Contact                MercedesDoorsRearLeft                "Deur linksachter[%s]"        (gMercedes) {channel="mercedesme:hybrid:7a2ea39a6d:W1NKJ5GB1VF658577:doors#rear-left"}
Contact                MercedesDoorsRearRight               "Deur rechtsachter[%s]"       (gMercedes) {channel="mercedesme:hybrid:7a2ea39a6d:W1NKJ5GB1VF658577:doors#rear-right"}
Contact                MercedesDoorsDeckLid                 "Achterklep[%s]"              (gMercedes) {channel="mercedesme:hybrid:7a2ea39a6d:W1NKJ5GB1VF658577:doors#deck-lid"}
Contact                MercedesDoorsEngineHood              "Motorkap[%s]"                (gMercedes) {channel="mercedesme:hybrid:7a2ea39a6d:W1NKJ5GB1VF658577:doors#engine-hood"}
Number                 MercedesDoorsSunroof                 "Zonnedak[%s]"                (gMercedes) {channel="mercedesme:hybrid:7a2ea39a6d:W1NKJ5GB1VF658577:doors#sunroof"}
Number                 MercedesDoorsSunroofFrontBlind       "Zonnedak rollo[%s]"          (gMercedes) {channel="mercedesme:hybrid:7a2ea39a6d:W1NKJ5GB1VF658577:doors#sunroof-front-blind"}

I have put my log for the core to DEBUG and noticed the following.

Every change to an items file results in a total refresh/compile of all rules!

The items gets changed and then about after 5 to 10 seconds the recompiling starts, blocking all rules.

In the log I see

2026-08-07 10:49:19.103 [DEBUG] [.model.core.internal.ModelRepositoryImpl] - reloadAllModelsOfType rules
2026-08-07 10:49:19.104 [DEBUG] [.model.core.internal.ModelRepositoryImpl] - reloadAllModelsOfType script
2026-08-07 10:49:19.108 [DEBUG] [.model.core.internal.ModelRepositoryImpl] - Refreshing resource 'cv.rules'

Some ‘normal’ loglines further down:

[el.rule.runtime.internal.DSLRuleProvider] - modelChanged MODIFIED cv.rules
[.core.automation.internal.RuleEngineImpl] - Compiling rule 'cv-1' ...
[.core.automation.internal.RuleEngineImpl] - Compiling rule 'cv-2' ...

Then all rules in the cv.rules file gets recompiled.

This continues for all rule files. Everytime starting with:

[el.rule.runtime.internal.DSLRuleProvider] - modelChanged MODIFIED settings.rules

This then continues for all rules. What could be the reason the ‘reloadAllModelsOfType rules’ gets always triggered? And why does it think the “modelChanged MODIFIED”?

The whole process started when adding an item to the mercedes.rules file.

[INFO ] [.model.core.internal.ModelRepositoryImpl] - Loading DSL model 'mercedes.items'
....
...
[DEBUG] [.core.model.rule.jvmmodel.RulesRefresher] - Item "MercedesVehicleFeatureCapabilities" added => rules are going to be refreshed
[DEBUG] [odel.script.jvmmodel.ScriptItemRefresher] - Item "MercedesVehicleFeatureCapabilities" added => scripts are going to be refreshed

Perhaps @rlkoshak has an idea?

Are you specifically referring to rules and only rules (*.rules files) when you said “items”?

I.e. is this related to Things or Items too or just Rules?

I think especially items.

But in the meantime I foun this discussing about this subject. There lies probably the cause of the issue.

https://github.com/openhab/openhab-core/issues/5592

It is about calling reloadAllModelsOfType rules

2026-08-07 12:07:25.428 [DEBUG] [.model.core.internal.ModelRepositoryImpl] - reloadAllModelsOfType rules
2026-08-07 12:07:25.429 [DEBUG] [.model.core.internal.ModelRepositoryImpl] - reloadAllModelsOfType script

There looks to be a problem in OH 5.2 and not specifically my config. I will continue my investigation.

With Things and Items, on every reload, the entire file needs to be read, parsed and then compared against all existing Things / Items. Only then, the changed Things/Items can be identified and updated.

With Rules, there is no way to tell whether a rule is the same or not, so in addition to everything in the file being re-parsed, all the previous rules from that file must be deleted, and the ones just loaded re-added.