gcobb321 / icloud3

iCloud3 v3 - iCloud3 is an advanced iDevice tracker that uses Apple iCloud account and HA Companion App data for presence detection and location based automations.
MIT License
498 stars 52 forks source link

End of day file maintenance #333

Open jshep321 opened 2 months ago

jshep321 commented 2 months ago

I happened to walk past a motion sensor at exactly 12am that usually instantly turns on a light via an automation in node red. It took several seconds to turn on. I looked at the cpu usage and it was crazy high on my pi5. Looking at the icloud3 log and the HA logbook I see a ton of updates during the file maintenance.

I have a nvme SSD directly attached.

I am using iCloud3 v3.

Any way to "nice" this end of day maintenance so the system doesn't get loaded?

gcobb321 commented 2 months ago

There are several tasks that are done at midnight:

  1. The log files are archived and renamed.
  2. Various counters are reset.
  3. The Waze History DB maintenance is done. This includes deleting duplicate records and compressing the DB files.
  4. The Waze History DB route times and distances are recalculated for all records if it is detected that a tracked from zone (Home) location has moved more than 100m or it was requested in the Event Log Actions.. This can take some time based on the number of records. It usually runs in a separate thread (controlled by HA and Python) and should not impact what is going on too much. This doesn't happen very often and a message is displayed in the Event Log.