Delay in openhab reaction time with openhabian on PI3/4 caused by file swap service?

Dear community,

I want to share with you an expereince which I made and how I solved it.
I am using openhab since some years now. With openhab 2.0 and 2.5 on raspberry pi 3 and 4 I noticed very often a delay of several second (4-6s) whan I call a rule. I searched since a long time for a solution. Actually I swithed to Pi4 to solve it. But problem remains.

Than I stumbled by accident over the log2ram project I thought its a good idea to install it, to make my SD card longer lasting. With this project comes also the recommedation to install and disable raspbian file swap services.

I did this and beleive me or not. Since than the delays in the reaction time on rules are gone and I am happy!! It works perfect since a few weeks now.

Did anybody else face similar problems? Make it sense to introduce this in openhabian in the future?
What does the community think about this?


i use 2.5.x on rpib3+ (many…) run fast even with 100+ rules but the swapfree is near 0% ! memory free is arround 30%, i’m worrie about the sd cart fail … zarm is really a way to go ?

This is interesting. I also see delay in rule triggering.

Do you simply install the zram-swap-config as explained on github or are there additional steps?

Yes @SpaceGlider, first I installed log2ram (I assume this has no big influence) than zram like discribed on GitHub. I think main step was to disable swaping at the end of the description:

sudo systemctl disable dphys-swapfile

But I did not experiment arround which step finally made the difference.
Would be interessting to here your experence!!

@isoparme: If you don’t have an issue at all I would not change something. I installed log2ram to protect my SD card. zram does not help here, I think.

Another option, if you have concerns about the SD card, is to use an SSD. The price for a small SSD and case is cheap enough that I can never see me going back to using an SD card. :grinning:

I use a 120GB SSD that my Rpi 3 B+ boots from and have the SD card removed. OH works great on this and if interested let me know, I will share a link to the case used as I’ve read that not all SATA to USB cases work.


Sorry guys I started this thread because of 4-5s delays in rule excecution. Not because of fear about my SD card… :slight_smile:

1 Like

Forgot to mention SSD helped with this also. :wink:

@H102, Yes I agree! Did this on my second raspberry with nextcloud on it and its much faster now. But on my openhab I don’t see a need for a SSD. The CPU is ideling arround most of the time. So why spending that effort.

ZRAM is already a feature of openHABian, why don’t you just use it ?

1 Like

@mstormi Just because, I did not know. Thanks for the hint!
Is there any reason why its not active by default?

Good question.

(customised) ZRAM & ZSWAP is activated by default on Armbian for about 5-6 years and its proven to work as expected, enabled and used where its safe. On more diverse hardware and with more complicated use cases.

For more complex caching/zram-ing methods (IMHO not needed) - power cut is ofc not healthy - can lead to corruption and data loss - if you use lots of caching methods and not write things reguraly. That’s clear and its a trade but If you take care about that, you will be fine. The rest is automatical and user mainly don’t need to care about tweaking settings. If you have one app and one hardware, to take care for, you can prepare perfect settings …

@mstormi, @igorp The point is the description in ZRAM is very detailed and technical. Really great effort. Thanks for this. But I would never understood from this description that it can improve the delay in my rules so significant. So I think for “normal users” it would be nice to get some short HOWto with an hint why to it make sense activate that feature.

Would also be nice to know if more people have same experience like me. May be I am an exception.

Again: In my case I had arround every 5 to 10 rule excecutions an delay of 4-6s and also 5000ms timeout messages in the log very often. This is gone now. Really big step forward! I only can connect this improvement with activating zram feature.

This decision should not be passed to end-user. Most of them have no clue - enable and forget. Advanced users can go deep and fine tune for their special needs. For them, a @mstormi research can be a useful guide.

It is and it can be improved further. If you have UPS. Or a board with UPS.

If you had read openHAB(ian) docs from the start you would have had that “HOWTO”
(write an own document saying enable that in openhabian-config ? Come on, that’s ridiculous)
The description thread linked to above is also being linked to in the official docs.
I’d say that’s more than enough ‘why’.

But your initial assumption is somewhat wrong. Neither is ZRAM built to address your specific rules delay problem, nor does it necessarily help everyone to have that problem.
Note I didn’t confirm it was ZRAM to help you.
Ok it positively affects memory availability, but that it helped with your problem was merely a side effect rather than primary intention. It all depends on the details such as your HW, how big is your OH, what’s your Java parameters, what else do you run in addition to OH.

Definitely no!
openHABian has a different philosophy.
Make it an offer, explain the implications. But in the end, it’s the user’s responsibility to decide.
Everybody has to do the trade-off for himself, and not everybody - including openHABian maintainers - is convinced it’s needed and more beneficial than harmful. So it’s up to everybody for himself to decide, no matter if he’s technically right or wrong there.
We might choose to make it the default one day, but since it has its drawbacks, too, it’s just an option for now.

1 Like

Armbian has fully functional solution enabled …

… on a much greater user base. My recommendation, once again, a year later: implement it and enable by default. If you need reasoning and expert opinions - research Armbian forums on this topic. This is not something new. Topic has been researched much more then Raspbian or Openhabian maintainers ever will.

True. Your implementation is not there yet.

Stop twisting statements.
My “No” was a reply to your statement “This decision should not be passed to end-user”, not on enabling ZRAM per default.

And stop your provocative and offending statements.
We don’t tolerate that sort of communication in this community.
That I’m stating as a moderator.

If you decide to default some feature you are taking (some) responsiblity away from users. Actions are directly corelated. Stop seeing things twisted? (is a provocation, yes. Is that already out of tolerance?)

My intention is to put some pressure to improve things for users, not to offend anyone. I am sorry if that was too much. Nothing more to add here.


After the hard discussion which I forced with this thread about log2ram and zram I switched to a cheap 120GB SSD to replace my SD card. Its running for a few weeks now and the delays are also gone… Very nice solution and small investment.

I don’t use log2ram and zram anymore to lower the risk of corrupted system.

Thanks for the hints of @mstormi and @igorp.