You are not logged in.

#1 2015-09-23 23:05:04

eduncan911
Member
Registered: 2015-05-02
Posts: 93
Website

fstrim.timer (TRIM): increase frequency?

Should you increase the frequency of SSD TRIM's commands on a server?  The default is to run once a week.

tl;dr

Just installed Arch on a bare metal server onto a 2 year old SSD that I was using with USB3.0 for many years, copying 50+ GB files several dozen times a week.  SMART shows good health on the SSD.

Do note that TRIM doesn't run over USB3.0.  So, perhaps, TRIM was never run for this SSD.

After the very basic install, I just enabled the `fstrim.timer` service for the os SSD, and saw this:

$ journalctl -u fstrim
-- Logs begin at Tue 2015-09-22 00:50:41 EDT, end at Wed 2015-09-23 18:55:21 EDT. --
Sep 23 18:51:00 mal systemd[1]: Starting Discard unused blocks...
Sep 23 18:51:43 mal systemd[1]: Started Discard unused blocks.

The first clue that something was happening was the HDD light on the server light solid, for well more than 30+ seconds when I enabled it.

Found the log entry above and was like, "43 seconds to run a TRIM command?" 

I also noticed that `iotop` showed 100% disk activity while this was happening.

Since I will be hosting close to 5 or 7 VMs, mostly Linux and 1 Windows, I am thinking of increasing the frequency of "fstrim."  Maybe, once an hour?

When I run it again, multiple times, it exits fast:

$ journalctl -u fstrim
-- Logs begin at Tue 2015-09-22 00:50:41 EDT, end at Wed 2015-09-23 18:55:21 EDT. --
Sep 23 18:51:00 mal systemd[1]: Starting Discard unused blocks...
Sep 23 18:51:43 mal systemd[1]: Started Discard unused blocks.
Sep 23 18:52:17 mal systemd[1]: Starting Discard unused blocks...
Sep 23 18:52:18 mal systemd[1]: Started Discard unused blocks.
Sep 23 18:55:11 mal systemd[1]: Starting Discard unused blocks...
Sep 23 18:55:11 mal systemd[1]: Started Discard unused blocks.

Last edited by eduncan911 (2015-09-23 23:05:26)

Offline

#2 2015-09-24 06:03:34

mauritiusdadd
Member
From: Benevento, Italy
Registered: 2013-10-27
Posts: 776

Re: fstrim.timer (TRIM): increase frequency?

If you just want to change the timer interval, you can try to create a simple drop-in snippet for the timer https://wiki.archlinux.org/index.php/Sy … n_snippets.

(Note: I never tried it on a timer, so I cannot assure you that it works)

--edit: PS:

When you run it multiple times, it exits fast only because there are no pages to be discarded yet.

Last edited by mauritiusdadd (2015-09-24 06:05:09)


About me - github

-- When you have eliminated the impossible, whatever remains, however improbable, must be the truth -- Spock | Sherlock Holmes

Offline

#3 2015-09-24 06:12:18

eduncan911
Member
Registered: 2015-05-02
Posts: 93
Website

Re: fstrim.timer (TRIM): increase frequency?

Yep, already created the drop-in snippet.  Was just asking if anyone set it on a schedule more than the default weekly that it is set to.

Yep, runs fast because of no discarding to do.  I may try to write a few GB and delete and time it.

Offline

#4 2015-09-24 13:51:01

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: fstrim.timer (TRIM): increase frequency?

I've been running ext4 (over lvm over luks) on my laptop with the discard mount option and so far I haven't seen any slowdowns or had any problems, you could also consider that. If your workload is not read/write intensive then having the fs mounted with the discard option should not slowdown things noticeably(1), with the added benefit that it will not retrim already trimmed space as the timer unit will do if you reboot your machine and run the service again.

(1) It will ruin deleted file recovery though as things will be gone instantly.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#5 2015-09-24 13:58:51

frostschutz
Member
Registered: 2013-11-15
Posts: 1,409

Re: fstrim.timer (TRIM): increase frequency?

eduncan911 wrote:

Should you increase the frequency of SSD TRIM's commands on a server?  The default is to run once a week.

It depends on how full your filesystems are and how much data you write in total.

If you have 100GB free and write 10GB per week, you could consider monthly TRIM instead of weekly.

If you have 10GB free and write 100GB per week, it might help to have daily TRIM instead. Basically that's when you're left with no free blocks and hit speed penalties.

R00KIE wrote:

(1) It will ruin deleted file recovery though as things will be gone instantly.

TRIM destroys data, that's what it does. Data it believes to be deleted will be gone. fstrim is a compromise between still using TRIM to help the SSD keep its performance in the long-term, and still being able to recover deleted files (if you notice the problem soon enough and prevent the fstrim task from running). It's a good compromise considering that all other writes to a filesystem may damage your deleted stuff as well, so even without TRIM you don't have all that much time to try to recover things.

Last edited by frostschutz (2015-09-24 14:01:48)

Offline

Board footer

Powered by FluxBB