Database Cleanup

First thing I want to say is how grateful I am that the memory leaks have been brought under control. No more memory growth over time even when the hub is up for over 2 weeks. Just set my reboot rule to run 4 weeks before performing a boot with database rebuild.

Now that things appear to be stable, my process control engineer impulses are kicking in. Process stability is one of the most important factor for efficient operation.

In the first week after a boot the hub seems to settle down into a daily pattern just in time for the Daily Cleanup app to run and cause a significant disturbance that takes the hub and the Periodic Cleanup app most of the next day to recover.

Based on that observation, it seems that the Daily Cleanup app should stop running at most a week after boot up.

I volunteer to test that idea or join the beta if necessary.

My retired process control engineer impulses are kicking in again.

My first realization was that in many cases the daily cleanup job causes significant disturbances to the stability of the memory usage.

The second realization is that the periodic cleanup job also causes significant disturbances.

The next realization is that the conditions are dfferent on every hub. On any given hub the devices, the number, type and communication protocols are most likely different. The active apps and rules are also different. With that in mind, there is no way that standard cleanup tools will lead to stable memory usage on all hubs.

Based on 40+ years of experience, the standard cleanup tools may work well on many hubs, but likely not very well on most hubs.

The goal should not be having the minimum memory usage. That gives periodic hign CPU utilization.

The goal is to have steady state conditions for the Database size, Free Memory, Java Direct and JVM size. This should lead to consistantly low CPU utilzation and low CPU temperature.

The first idea that comes to mind is fuzzy logic. Simple models should lead to fairly stable memory usage.

Assuming that the OS and database are built on open source software, Hubitat should be able to hire two contractors, a memory expert and a fuzzy logic expert. They should be able to piece together a working model for each hub model.

Remember, the goal is consistant CPU utilization and temperature.

A few follow up comments:

• Suggest that as a company, Hubitat's goal for memory management and other system processes should be that hubs run at a consistently low CPU utilization so there is always sufficient CPU power to support dynamic processes.

• Daily Cleanup creates unnecessary disturbances by making step changes in database size that take significant time for the hub to recover. As a result, Daily Cleanup should be turned off

• Routine Cleanup sometimes makes smaller step changes to database size. These changes take less time to recover from, but should also be turned off.

• Routine Cleanup should make small changes that are limited by higher CPU utilization. In other words, when CPU utilization is below a target value a certain small amount of cleanup should be performed. The amount should be factored by the amount that the CPU Utilization is below the target value.

• Database size, Free Memory and JVM Free Memory all react independently, so their cleanup routines should run at different times so the effects of each on CPU utilization can be gauged.

Comments? @gopher.ny @bobbyD