Both guides you link to have you enable the discard
mount option for your filesystem. In my experience, this kills performance. On every sync after a file has been deleted, a TRIM request gets sent, causing the disk to freeze up for 2 to 3 seconds. (This will be hardware-dependent.)
To see whether this is the problem, try testing fsync
performance as suggested in this thread:
Running Theodore Ts'os "fsync-tester" while doing Linus' torture test
while : ; do time sh -c "dd if=/dev/zero of=bigfile bs=8M count=256 ; sync; rm bigfile"; done
shows it clearly
Sync should be fast on an SSD. In my case and that poster's case, each sync causes a lockup of several seconds. See also https://patrick-nagel.net/blog/archives/337 for a similar example.
If you see similar behavior, you should disable automatic TRIM by removing the discard
option from your fstab. (But keep the noatime
or relatime
option that you probably added.)
Instead, periodically run fstrim
on your filesystem, e.g. using cron
. Several ways to do this are given in this article. This way you should still get the benefits of TRIM without the performance problems.