SanDisk SSD Plus: Half the performance on Linux than on Windows?
This may not be a good enough answer, but I am new and can't "comment", and wanted to share with you in case it helps:
I used to work with eMMC flash memories, similar hardware underpinnings as SSD. discard_zeroes_data sounds like it could matter. There were very slow features called Erase and especially Trim (like Erase, but on a 4kB read-block basis instead of the much larger Erase Group Block needed for performance. Later a "Discard" feature was introduced which didn't erase the data to all zeros (really all-ones under the hood, but inverted for your convenience), but just changed the state of the data to "don't care".
So if you did a discard on 4kB of data, it was faster because didn't do an erase, but let the firmware know that you didn't need the data anymore, and it kept track of that physical area in a table. This allowed the garbage collection type of mechanism to reclaim that data location (likely re-map it to a different address) later when enough of its neighbours could be erased, copying any needed data to another area as needed and then doing the expensive "Erase" operation in the background.
TBH we ended up disabling discard at first, because it didn't work so well in and caused us performance issues when too much data was left in discard state, and the physical erases never happened.
So I can't tell what "discard_zeros_data" exactly means, but if I were you I'd definitely try changing it to the opposite state and see what happens. If it reads like "subject verb object", then it could be a security feature where it takes the time to forcibly erase even small bits of data (expensive) so that there's no chance that someone can reclaim your old files after you think you've deleted them. I would think that setting this to "Zero" would actually increase performance, if that's how you read it, but you're seeing the opposite.
Also try doing the biggest forcible "erase" that you are able to, whether using special SSD tools, or a full format, or something, and see if the performance is better right after this erase. That will at least give you some information about the problem.
The filesystem type should definitely matter also, but I think this is a constant in your two experiments.
Comparison to USB pendrives
Simple USB pendrives get slower gradually after being used for a while. Such drives have no discard feature (as far as I know; I am not talking about advanced and very expensive pendrives). Wiping the whole drives, overwriting with zeros (or ones internally) will restore the speed again. From my own experience I know that this applies to Sandisk Extreme pendrives, which are fast when new (compared to other simple USB pendrives).
So I can expect, that the discard method (or lack of it) can be responsible for the performance drop also in your Sandisk SSD. I think that @Starman's answer adds valuable information to solve your problem.
You can
try to leave the system running idle overnight and check if it has used the idle time to catch up discarding what should be discarded. If no luck, you can
wipe the free space of the drive and check if that improves the performance,
try to find some mount option in linux, or some setting of the SSD, that will improve the performance.
Tools
-
zerofree
is an efficient tool forext
file systems. See this link,manpages.ubuntu.com/manpages/zesty/man8/zerofree.8.html
-
Otherwise (if you check and doublecheck, that everything is correct) you can use
dd
to create a huge fileblank
containing zeros and wipe it afterwards (slow but works in all file systems).Boot from another drive, for example a live USB drive
cd <mountpoint-of-the-target-partition> # for example: cd /mnt sudo dd if=/dev/zero of=blank bs=4096
Let it run until it stops because the drive is full and after that remove the file
blank
. This assumes that there is no useful file with the nameblank
already.sudo rm blank
Warning:
dd
is a powerful but dangerous tool, so check and double-check that you will not destroy valuable data. To play safe in this case is to backup everything valuable on the connected drives to another location (for example to an external drive that is disconnected afterwards).
Wipe the whole device
My method for USB pendrives is to wipe the whole device (not only the free space between files in a partly filled partition). I think this is the most efficient method for pendrives, but I think there should be some discard setting, that works efficiently in an SSD without wiping the whole device. Anyway, if you want to test, you can try it, and after that create a new partition table and an ext4
partition. See this link
help.ubuntu.com/community/mkusb/wipe#Wipe_the_whole_device
I wanted to add one comment in response to the excellent post by @sudodus, but I'm still currently 4 rep points shy of being allowed to comment, so sticking it in here:
As for leaving things idle - with the eMMC technology I worked on (again, should be similar but not identical to yours), this would not have worked, as the device had to assume that the system designers might cut the core power and only leave the IO power alive.
There is actually a sleep mode to coordinate power savings, but I do remember the eMMC vendors saying they didn't want to just start doing background operations in the middle of no-time, they only run these cleanup type operations in between accepting a command you send it, and before returning the status (result).
It's possible that SSD's are different, having a controller that specifically, during idle time, sends commands to the NAND flash back end that leads to cleanup and re-org of the data blocks inside it. But I wouldn't necessarily expect that to happen, based on my experience.