linuxmint / timeshift

System restore tool for Linux. Creates filesystem snapshots using rsync+hardlinks, or BTRFS snapshots. Supports scheduled snapshots, multiple backup levels, and exclude filters. Snapshots can be restored while system is running or from Live CD/USB.
2.33k stars 82 forks source link

The Timeshift (rsync) backup process slows foreground processes #28

Open anjohnson opened 2 years ago

anjohnson commented 2 years ago

Describe the bug When Timeshift starts an hourly system backup on my older CORE i3 laptop it immediately steals much of the available CPU power, significantly slowing my foreground processes. I have recently taken to running renice +5 on the backup process to drop its priority (I haven't checked what the optimal nice level should be though). Doing that resolves the issue without stopping the backup completely, but there is no way to have that happen automatically without hand-editing the /etc/cron.d/timeshift-hourly file, which could easily get reverted by a configuration change or upgrade.

To Reproduce Steps to reproduce the behavior:

  1. Configure Timeshift using RSYNC on a lower-powered system (mine has 12GB of RAM but only 4*1.9GHz HT CPUs and a spinning-rust HD).
  2. Be doing something interactive that involves multiple processes when a backup starts.
  3. Watch the interactive system performance slow significantly.
  4. Running sudo renice +5 <pid> (where <pid> is that of the timeshift process) restores the interactive performance without preventing the backup from completing.

Expected behavior Timeshift backups can be made at a lower priority (higher nice level) without affecting other foreground processes. If it can't/shouldn't use a fixed nice level for some reason (which looks like it would be a very simple change to the code that generates the crontab file), please give users the ability to configure their own nice level for the backup process.

System

stephan-dev commented 2 years ago

I've had the same problem for a long time, with an older version, Timeshift 18.9.1.2 (Mint 19), but with a fast i5, with SSD storage.
When I think about newbies, I think this is the biggest Mint problem currently : During each Timeshift sync, my system slows down extremely, to the point that it interrupts something as simple as taking notes in Joplin (e.g. wait for 5 seconds for the typed sentence to display) (a noob would panic, esp. if s/he doesn't have the applet detecting a Timeshift sync). I'm not even talking about activities greedier than mere note taking.
My only unusual setup is that I backup to my one and only SSD (same [encrypted] SSD as the OS).

I have never attempted a normal renice, as my problem is not exactly the same as you : htop doesn't show any clogging of my CPU. Doesn't show any clogging at all, actually. That's why I've added an optional colum for I/O. But it's hard to interpret, possibly because of (unrelated) authorization problems on my htop config. I didn't try ionice (I/O renice). I don't remember seeing "100% use" of SSD, but I'm not sure about this. It's still a mystery for me. I mentioned joplin freezes, but it's the same with a simple text editor...

I didn't inquire more as it's not that bad a problem for me. But even if this doesn't get a fix, your idea of editing the cron file with nice is already quite useful (in my case, it might be ionice). A qwant search "timeshift + renice" brought me here.

(I just don't understand why use renice before execution, can nice be used instead in that case, to set the priority before launching of the task?)

anjohnson commented 2 years ago

I use renice after the backup has already started. If I were to edit the /etc/cron.d/timeshift-hourly file I would insert something like nice -5 into the command line, although I haven't actually tried doing that.

stephan-dev commented 2 years ago

ok, I get it now, thanks.

stephan-dev commented 2 years ago

This might be the place to ask : https://github.com/teejee2008/timeshift/issues/ (4k stars)

anjohnson commented 2 years ago

There do seem to be several issues there already, e.g. 475 which also points to 146 and #328. 330 looks like a fix PR that uses both nice and ionice.

stephan-dev commented 2 years ago

Interesting findings. I read the PR. I saw an ionice line that seems commented out, so I went back in history (master branch). Apparently ionice -c idle was implemented in october 2018, in this repo, aka upstream. https://github.com/teejee2008/timeshift/commit/bdb819eee8539b46babae373dac99227cda1033f . The PR is from that same month. Apparently a slightly different version was accepted and merged.
Apparently the Linux Mint version didn't follow.
Compare https://github.com/linuxmint/timeshift/blob/master/src/Utility/RsyncTask.vala
and https://github.com/teejee2008/timeshift/blob/master/src/Utility/RsyncTask.vala

The PR you mentioned has a recent, March 2022 comment, asking for merging, because he has I/O lagging problems. So either ionice -c idle doesn't work, or maybe @chasebolt is using our version without knowing, the linux Mint version, that doesn't have the fix.
Am I right ?