On my test Linux box with a Transcend TS2TMTE662T2-G1 SSD installed. I created a 100GB dummy file on my 1.8TB ext4 partition, and then I ran cat <bigdummy.bin >/dev/null
to sequentially read the data from that file as quickly as possible.
With cat
running, I ran iostat -t nvme0n1p6 --human 1
in a different shell window to monitor what the SSD's read-performance was like... it looks pretty good, I'm reading in ~2.2 gigabytes per second:
Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscd
nvme0n1p6 18232.00 2.2G 0.0k 0.0k 2.2G 0.0k 0.0k
I then used rm
to delete about 600GB of (unrelated) files from the partition, and then I ran fstrim --all
to tell the SSD to start erasing the newly-discarded blocks. While that trimming was going on, I looked at iostat
's output again to see how my cat
process's read-performance was now faring:
Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscd
nvme0n1p6 215.00 18.1M 0.0k 8.8G 18.1M 0.0k 8.8G
Ecch, not very good at all. Read bandwidth has been reduced to a measly 18MB/sec, and the transactions-per-second is similarly down by a factor of 100.
It's probably unreasonable for me to expect 100% of normal read performance from an SSD that is also in the middle of doing 8.8G/s
of kb_dscd
's... but since the block-discarding operation isn't particularly time-critical (in that I don't care that much whether it completes in 30 seconds or continues for 30 minutes), is there any way for me to slow that process down so that my drive's read-performance won't be so badly impacted while it is going on? e.g. if the SSD was only doing 500 M/s of kb_dscd
operations, it would (perhaps) have more time left over to handle its normal read-I/O tasks at something approaching its usual rate?
(motivation: this is for a media streaming box that will eventually want to do simultaneous recording and playback, potentially 24/7, and it would be really nice if I could periodically initiate TRIM operations without significantly impacting the box's ability to continue streaming content at the same time.)
fstrim
accepts-o
(offset) and-l
(length) options. You can use them to limit the amount of trimmed LBA per command invocation.