UtenteRasp
Posts: 17
Joined: Sat Jun 27, 2020 7:35 am

Raspberry pi 4 with ssd but slow performance

Thu Apr 22, 2021 5:55 pm

To have greater reliability but also to improve the performance of reading and writing I bought an ssd for the raspberry pi 4, cloned the system I already had in the sd card and everything went well. However I am noticing that the performance has not improved but there are some problems. The boot alone takes longer than when it was booted from the sd card and, once the system is started, it also gives problems in opening programs as it jams, losing a lot to open something. In these phases I sometimes see that the cpu is high and the system panics. At the second reopening of the same programs, however, it goes fast and there are no problems. Someone else has happened a similar episode, do you have any ideas to solve the problem?


UtenteRasp
Posts: 17
Joined: Sat Jun 27, 2020 7:35 am

Re: Raspberry pi 4 with ssd but slow performance

Thu Apr 22, 2021 6:10 pm

Solskogen wrote:
Thu Apr 22, 2021 6:00 pm
viewtopic.php?f=28&t=245931
Thanks for the reply. I tested the read and write speed via dd and the results were 170MB/s for write and 240MB/s for read. I alto test with the included tool on Raspberry Pi Os and the ssd pass the test. The problem happens only on the first execution of a program. From the second time it goes fast without problems. So my problem is not related to the speed of reading and writing of the ssd but to the launch of programs.

swampdog
Posts: 614
Joined: Fri Dec 04, 2015 11:22 am

Re: Raspberry pi 4 with ssd but slow performance

Thu Apr 22, 2021 8:08 pm

Linux uses free memory. You can get an idea with the 'top' command (hit 'q' to get out of 'top'). Unless the memory is needed for something else it caches stuff so subsequent execution of a file is likely not to have accessed the ssd at all. There are other commands such as 'vmstat' & 'iostat' and of course 'tail -f'. eg:

Code: Select all

$ vmstat 1
$ iostat -N 1
$ sudo tail -f /var/log/syslog
Run "tail -f" in a separate terminal. ctrl-c to get out of them.

It is of course possible something when amiss in cloning. Do a fresh install and see if the problem persists. You can always clone it again.

pidd
Posts: 1892
Joined: Fri May 29, 2020 8:29 pm
Location: Wirral, UK
Contact: Website

Re: Raspberry pi 4 with ssd but slow performance

Thu Apr 22, 2021 8:33 pm

Have you taken the SD card out?

UtenteRasp
Posts: 17
Joined: Sat Jun 27, 2020 7:35 am

Re: Raspberry pi 4 with ssd but slow performance

Thu Apr 22, 2021 9:33 pm

swampdog wrote:
Thu Apr 22, 2021 8:08 pm
Linux uses free memory. You can get an idea with the 'top' command (hit 'q' to get out of 'top'). Unless the memory is needed for something else it caches stuff so subsequent execution of a file is likely not to have accessed the ssd at all. There are other commands such as 'vmstat' & 'iostat' and of course 'tail -f'. eg:

Code: Select all

$ vmstat 1
$ iostat -N 1
$ sudo tail -f /var/log/syslog
Run "tail -f" in a separate terminal. ctrl-c to get out of them.

It is of course possible something when amiss in cloning. Do a fresh install and see if the problem persists. You can always clone it again.
Thanks for the reply. Before cloning the sd card, I tried Twister Os in ssd doing a fresh installation. However it have the same problem

UtenteRasp
Posts: 17
Joined: Sat Jun 27, 2020 7:35 am

Re: Raspberry pi 4 with ssd but slow performance

Thu Apr 22, 2021 9:34 pm

pidd wrote:
Thu Apr 22, 2021 8:33 pm
Have you taken the SD card out?
Yes

UtenteRasp
Posts: 17
Joined: Sat Jun 27, 2020 7:35 am

Re: Raspberry pi 4 with ssd but slow performance

Fri Apr 23, 2021 8:42 am

[UPDATE]: Thanks everyone for the advice. I tried to see any errors with dmesg and found uas errors. So I performed the above procedure and the problem seems to be solved at the expense of theoretical performance. In fact, at least it is better than before. Now I have another question, given the uas errors, the problem is with the adapter and not with the ssd. it's correct?

User avatar
CaptainMidnight
Posts: 226
Joined: Sun Nov 03, 2019 4:32 pm
Location: UK

Re: Raspberry pi 4 with ssd but slow performance

Fri Apr 23, 2021 8:58 am

UtenteRasp wrote:
Fri Apr 23, 2021 8:42 am
[UPDATE]: Thanks everyone for the advice. I tried to see any errors with dmesg and found uas errors. So I performed the above procedure and the problem seems to be solved at the expense of theoretical performance. In fact, at least it is better than before. Now I have another question, given the uas errors, the problem is with the adapter and not with the ssd. it's correct?

Yes, if the use of quirks gives you a reliable system (i.e. disables the use of UAS protocol for your ssd) then your issue exists within the compatibility, or lack of it, of your USB to SSD controller chipset.
"Never get out of the boat." Absolutely goddamn right!
Unless you were goin' all the way...

UtenteRasp
Posts: 17
Joined: Sat Jun 27, 2020 7:35 am

Re: Raspberry pi 4 with ssd but slow performance

Fri Apr 23, 2021 9:07 am

CaptainMidnight wrote:
Fri Apr 23, 2021 8:58 am
UtenteRasp wrote:
Fri Apr 23, 2021 8:42 am
[UPDATE]: Thanks everyone for the advice. I tried to see any errors with dmesg and found uas errors. So I performed the above procedure and the problem seems to be solved at the expense of theoretical performance. In fact, at least it is better than before. Now I have another question, given the uas errors, the problem is with the adapter and not with the ssd. it's correct?

Yes, if the use of quirks gives you a reliable system (i.e. disables the use of UAS protocol for your ssd) then your issue exists within the compatibility, or lack of it, of your USB to SSD controller chipset.
Could it also be due to an outdated system?

User avatar
HawaiianPi
Posts: 6305
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Raspberry pi 4 with ssd but slow performance

Fri Apr 23, 2021 9:32 am

UtenteRasp wrote:
Fri Apr 23, 2021 8:42 am
... and found uas errors. So I performed the above procedure and the problem seems to be solved at the expense of theoretical performance.
That's not really a solution as much as a workaround, because most adapters and enclosures with broken UAS support also don't support TRIM (which is an important function for maintaining SSD performance and longevity).

What is the make and model of the SSD (and enclosure or adapter cable, if applicable)?

Also, what does the lsusb command return with the SSD connected?

UtenteRasp wrote:
Fri Apr 23, 2021 9:07 am
Could it also be due to an outdated system?
Possibly. There have been improvements and fixes for some troublesome adapters, but more often the problem is with the chipset and firmware in the adapter cable or enclosure itself. JMicron USB 3.0 bridge chips have been particularly troublesome on the Pi4.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2582
Joined: Thu Jul 11, 2013 2:37 pm

Re: Raspberry pi 4 with ssd but slow performance

Fri Apr 23, 2021 10:41 am

TRIM support is possible on mass storage adapters that have a working command pass-through implementation. hdparm -I shows the device capabilities (Data set management TRIM supported / Deterministic read ZEROs after TRIM) and lsblk --discard shows whether the block device supports block discard (DISC-MAX column).

If I use a Jmicron JMS578 (the type that doesn't have a compatible UAS implementation), set quirks for mass-storage mode, and follow the guide here -> https://www.glump.net/howto/desktop/ena ... d-on-linux then on an USB3 analyzer I see SCSI pass-through commands with opcode 42h (DISCARD) when executing fstrim.
Rockets are loud.
https://astro-pi.org

UtenteRasp
Posts: 17
Joined: Sat Jun 27, 2020 7:35 am

Re: Raspberry pi 4 with ssd but slow performance

Fri Apr 23, 2021 10:50 am

HawaiianPi wrote:
Fri Apr 23, 2021 9:32 am
UtenteRasp wrote:
Fri Apr 23, 2021 8:42 am
... and found uas errors. So I performed the above procedure and the problem seems to be solved at the expense of theoretical performance.
That's not really a solution as much as a workaround, because most adapters and enclosures with broken UAS support also don't support TRIM (which is an important function for maintaining SSD performance and longevity).

What is the make and model of the SSD (and enclosure or adapter cable, if applicable)?

Also, what does the lsusb command return with the SSD connected?

UtenteRasp wrote:
Fri Apr 23, 2021 9:07 am
Could it also be due to an outdated system?
Possibly. There have been improvements and fixes for some troublesome adapters, but more often the problem is with the chipset and firmware in the adapter cable or enclosure itself. JMicron USB 3.0 bridge chips have been particularly troublesome on the Pi4.
Thanks for the reply. I bought an internal torosus ssd and a classic cable that supports both 2.5 and 3.5 disks with power supply, the brand should be CableDeconn. The cable description stated that it supported UASP. i tried running lsusb-t command and this is the result after i did the procedure:

Code: Select all

lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
    |__ Port 2: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 4: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 4: Dev 3, If 1, Class=Human Interface Device, Driver=usbhid, 12M
Before the procedure "Driver" attribute was "uas". lsusb not specify the detail of device

UtenteRasp
Posts: 17
Joined: Sat Jun 27, 2020 7:35 am

Re: Raspberry pi 4 with ssd but slow performance

Fri Apr 23, 2021 12:07 pm

jdb wrote:
Fri Apr 23, 2021 10:41 am
TRIM support is possible on mass storage adapters that have a working command pass-through implementation. hdparm -I shows the device capabilities (Data set management TRIM supported / Deterministic read ZEROs after TRIM) and lsblk --discard shows whether the block device supports block discard (DISC-MAX column).

If I use a Jmicron JMS578 (the type that doesn't have a compatible UAS implementation), set quirks for mass-storage mode, and follow the guide here -> https://www.glump.net/howto/desktop/ena ... d-on-linux then on an USB3 analyzer I see SCSI pass-through commands with opcode 42h (DISCARD) when executing fstrim.
I have performed the procedure to enable trim and now I have these results:

Code: Select all

sudo fstrim -v /
/: 47,8 GiB (51316240384 bytes) trimmed
and

Code: Select all

lsblk --discard
NAME   DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda           0      512B       4G         0
├─sda1        0      512B       4G         0
└─sda2        0      512B       4G         0
i think everything works correctly.

pidd
Posts: 1892
Joined: Fri May 29, 2020 8:29 pm
Location: Wirral, UK
Contact: Website

Re: Raspberry pi 4 with ssd but slow performance

Fri Apr 23, 2021 7:48 pm

UtenteRasp wrote:
Fri Apr 23, 2021 12:07 pm
:

Code: Select all

sudo fstrim -v /
/: 47,8 GiB (51316240384 bytes) trimmed
That only tells you what the OS thinks it has sent to the drive, it might have not got past the interface.

The way I check that discard/TRIM is definitely working is to periodically look at the SMART data for the drive and check that the erase count jumps up in blocks after a periodic TRIM has been performed.

I have little trust in the interface chipset's firmware telling the truth as many of them claim to be full uasp compatible but aren't.

UtenteRasp
Posts: 17
Joined: Sat Jun 27, 2020 7:35 am

Re: Raspberry pi 4 with ssd but slow performance

Fri Apr 23, 2021 8:14 pm

pidd wrote:
Fri Apr 23, 2021 7:48 pm
UtenteRasp wrote:
Fri Apr 23, 2021 12:07 pm
:

Code: Select all

sudo fstrim -v /
/: 47,8 GiB (51316240384 bytes) trimmed
That only tells you what the OS thinks it has sent to the drive, it might have not got past the interface.

The way I check that discard/TRIM is definitely working is to periodically look at the SMART data for the drive and check that the erase count jumps up in blocks after a periodic TRIM has been performed.

I have little trust in the interface chipset's firmware telling the truth as many of them claim to be full uasp compatible but aren't.
Thanks for the reply. Before the procedure to enable trim the command fstrim -v / was giving an error as not supported. I think it works now but I'll try to do some tests.

Return to “General discussion”