Open PuffShr1k3 opened 10 months ago
Here are py-spys for where the time is spent
Its all the enumeration in the backup models. backups.models.backups
called from
def nextBackup(self, now: datetime, include_pending=True):
latest = max(filter(lambda s: not s.ignore() and (not s.isPending() or include_pending), self.backups.values()),
default=None, key=lambda s: s.date())
if latest:
latest = latest.date()
return self._nextBackup(now, latest)
I think most of them could be changed to properties and use @cached_property
than the overhead would likely disappear
There are some subtle problems caching those properties would cause.
I can make some little fixes that should cut the time used there in half, though its kind of mysterious that its spending so much time calculating .ignore()
. Do you have a lot of backups?
I'll also add a new configuration option that the performance sensitive like yourself can use. Right now the addon checks once/second if it should make a backup so new backups always happen on time. I'll make this configurable so you can sacrifice a little scheduling accuracy to do less computation.
At least on my systems:
system 1: 87 ignored backups. 4 non-ignored backups. system 2: 92 ignored backups. 4 non-ignored backups.
I noticed I had 40 ignored backups, deleted older backups, so now I only have 9 ignored, which reduced the CPU usage from 0.4% to 0.3%. I did notice that Google Drive backup identified the changes in the amount of backups very quickly, which ties in with how the adon checks once a second. I'm happy to sacrifice scheduling accuracy for less computational overhead. Thank you for looking into this, let me know if I can help test, provide logs, etc.
Is it possible the idle CPU usage could be reduced please? Albeit the usage is low, but if sitting idle, could the CPU usage be brought down a bit - Other addons use 0% if not in use.
I have lengthened the intervals to attempt to mitigate polling being a culprit:
Nonetheless, thank you for this extension - Having fire and forget backups is a huge stress relief.