12

This is what I'm getting now, with a Crucial MX300 750GB SSD (with latest firmware [there are no firmware updates yet]).

lptp [ blah ]: sudo hdparm -Tt /dev/sda

/dev/sda:
 Timing cached reads:   10202 MB in  2.00 seconds = 5103.20 MB/sec
 Timing buffered disk reads: 128 MB in  3.06 seconds =  41.88 MB/sec

See that buffered disk read speed!!!! SOOOO SLOWWW!!!! When I first setup my laptop, I was seeing over 400MB/sec, which was perfectly fine with me considering this is an older laptop, and everything is luks encrypted is well.

This is my /etc/fstab. I've enabled trim, manually ran trim, enabled/disabled features, rebooted, everything. I can't get those fast speeds to come back:

/dev/mapper/ubuntu--gnome--vg-root /               ext4    noatime,nodiratime,errors=remount-ro,barrier=0,discard 0       1

Just so it's clear, these are the options I'm using. I've tried various combinations of them to no avail:

noatime,nodiratime,errors=remount-ro,barrier=0,discard

Any tips? This is driving me crazy.

Oh, also, I'm running Ubuntu 16.04 (x64) on a Lenovo T420 with 16GB ram and an i7 processor:

 lptp [ blah ]: lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.1 LTS
Release:    16.04
Codename:   xenial

Smartctl output:

 lptp [ blah ]: sudo smartctl /dev/sda -a
smartctl 6.5 2016-01-24 r4214 [x86_64-linux-4.4.0-38-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:     Crucial_CT750MX300SSD1
Serial Number:    XXXXXX
LU WWN Device Id: 5 XXXXX XXXXXXX
Firmware Version: M0CR011
User Capacity:    750,156,374,016 bytes [750 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    Solid State Device
Form Factor:      2.5 inches
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   ACS-3 T13/2161-D revision 5
SATA Version is:  SATA 3.2, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Tue Nov  1 21:22:05 2016 CDT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x00) Offline data collection activity
                    was never started.
                    Auto Offline Data Collection: Disabled.
Self-test execution status:      (   0) The previous self-test routine completed
                    without error or no self-test has ever 
                    been run.
Total time to complete Offline 
data collection:        ( 1987) seconds.
Offline data collection
capabilities:            (0x7b) SMART execute Offline immediate.
                    Auto Offline data collection on/off support.
                    Suspend Offline collection upon new
                    command.
                    Offline surface scan supported.
                    Self-test supported.
                    Conveyance Self-test supported.
                    Selective Self-test supported.
SMART capabilities:            (0x0003) Saves SMART data before entering
                    power-saving mode.
                    Supports SMART auto save timer.
Error logging capability:        (0x01) Error logging supported.
                    General Purpose Logging supported.
Short self-test routine 
recommended polling time:    (   2) minutes.
Extended self-test routine
recommended polling time:    (  10) minutes.
Conveyance self-test routine
recommended polling time:    (   3) minutes.
SCT capabilities:          (0x0035) SCT Status supported.
                    SCT Feature Control supported.
                    SCT Data Table supported.

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x002f   100   100   000    Pre-fail  Always       -       0
  5 Reallocated_Sector_Ct   0x0032   100   100   010    Old_age   Always       -       0
  9 Power_On_Hours          0x0032   100   100   000    Old_age   Always       -       52
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       41
171 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       0
172 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       0
173 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       1
174 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       11
183 Runtime_Bad_Block       0x0032   100   100   000    Old_age   Always       -       0
184 End-to-End_Error        0x0032   100   100   000    Old_age   Always       -       0
187 Reported_Uncorrect      0x0032   100   100   000    Old_age   Always       -       0
194 Temperature_Celsius     0x0022   059   052   000    Old_age   Always       -       41 (Min/Max 21/48)
196 Reallocated_Event_Count 0x0032   100   100   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0032   100   100   000    Old_age   Always       -       0
202 Unknown_SSD_Attribute   0x0030   100   100   001    Old_age   Offline      -       0
206 Unknown_SSD_Attribute   0x000e   100   100   000    Old_age   Always       -       0
246 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       138859820
247 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       4354463
248 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       1675456
180 Unused_Rsvd_Blk_Cnt_Tot 0x0033   000   000   000    Pre-fail  Always       -       3558
210 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       0

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
No self-tests have been logged.  [To run self-tests, use: smartctl -t]

SMART Selective self-test log data structure revision number 1
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

What's killing me is that IT WAS WORKING FOR A WHILE. It worked one day, and then it stopped the next, and I didn't even do anything (that I can think of) that should have changed it.

UPDATE

Tested a specific device (/dev/sda1), but same slow results:

lptp [ ~ ]: sudo hdparm -Tt /dev/sda1

/dev/sda1:
 Timing cached reads:   13130 MB in  2.00 seconds = 6568.77 MB/sec
 Timing buffered disk reads: 128 MB in  3.06 seconds =  41.79 MB/sec

UPDATE

Tested on a logical partition too:

 lptp [ ~ ]: sudo hdparm -Tt /dev/mapper/ubuntu--gnome--vg-root 

/dev/mapper/ubuntu--gnome--vg-root:
 Timing cached reads:   11468 MB in  2.00 seconds = 5736.85 MB/sec
 Timing buffered disk reads: 178 MB in  3.04 seconds =  58.47 MB/sec

UPDATE dd test

This test shows that it's even slower than hdparm shows...

 lptp [ blah ]:  dd if=/dev/zero of=tempfile bs=1M count=1024 conv=fdatasync,notrunc status=progress
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 35.0156 s, 30.7 MB/s
 lptp [ blah ]: sudo bash -c "echo 3 > /proc/sys/vm/drop_caches"
 lptp [ blah ]: dd if=tempfile of=/dev/null bs=1M count=1024 status=progress
1066401792 bytes (1.1 GB, 1017 MiB) copied, 34.0193 s, 31.3 MB/s
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 34.256 s, 31.3 MB/s

UPDATE: Partition Alignment

Here's the partition alignment on my laptop:

lptp [ ~ ]: sudo parted
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p                                                                
Model: ATA Crucial_CT750MX3 (scsi)
Disk /dev/sda: 750GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End    Size   Type      File system  Flags
 1      1049kB  512MB  511MB  primary   ext2         boot
 2      513MB   750GB  750GB  extended
 5      513MB   750GB  750GB  logical

(parted) align-check opt 1                                                       
1 aligned
(parted) align-check opt 2
2 not aligned
(parted) align-check opt 5
5 aligned
(parted)

I'm not sure what to think of partition 2 not being aligned :^/ but partitions 1 and 5 are though.

Also, here's the partitions as seen from fdisk -l

Device     Boot   Start        End    Sectors   Size Id Type
/dev/sda1  *       2048     999423     997376   487M 83 Linux
/dev/sda2       1001470 1465147391 1464145922 698.2G  5 Extended
/dev/sda5       1001472 1465147391 1464145920 698.2G 83 Linux

UPDATE: FIXED? I changed the scheduler to a noop scheduler (instead of deadline). That seems to have worked (did this by changing /etc/default/grub to have the line:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash elevator=noop"

And then updating grub with sudo update-grub2 and rebooting.

I'm going to wait a few days to see if it works after a few more reboots/usage before I make an answer and accept it.

Current speeds now after changing the scheduler:

 lptp [ ~ ]: sudo hdparm -Tt /dev/sda

/dev/sda:
 Timing cached reads:   12388 MB in  2.00 seconds = 6197.19 MB/sec
 Timing buffered disk reads: 1454 MB in  3.00 seconds = 484.59 MB/sec

Options in fstab are:

noatime,nodiratime,errors=remount-ro,barrier=0

enter image description here

"FIX" UPDATE

After using it for a bit and rebooting a few times, it's BACK TO THE SLOW SPEEDS :( :( :( :( :( :(

UPDATE - POSSIBLE "FIX"

I had the thought that perhaps my laptop is doing some battery-saving optimizations when it's booted and running off the battery. After one simple test of booting with the charger plugged in, it's back to its really fast speeds. I'm fairly certain this is the case - all the time it tested at fast speeds I had the charger plugged in. I'll run a few more tests to verify, but I'm fairly certain this is what was causing the slowdown.

  • What happens if you test the speed for a particular partition eg /dev/sda1 instead of /dev/sda? – thomasrutter Nov 2 '16 at 2:33
  • good question - I'll try it and update my question – d0c_s4vage Nov 2 '16 at 2:33
  • Also on the logical partition eg /dev/mapper/ubuntu--gnome--vg-root – thomasrutter Nov 2 '16 at 2:35
  • tested /dev/sda1, gonna test the logical partition too – d0c_s4vage Nov 2 '16 at 2:36
  • k, tested both, no luck :6/ – d0c_s4vage Nov 2 '16 at 2:37
19

The quick answer:

sudo hdparm -B254 /dev/sda

The long answer:

It appears that Linux or laptops in general (verified on both Lenovo and Dells) default to APM level 80h (128) when booted on battery and FEh (254) when booted on AC power.

For most SSDs, you won't notice much difference. Lite-on SSDs seem to not support power management at all and always run at max speed. Intel SSDs seem to run at about 75% full speed at APM level 128, and 100% speed at APM level 254/255. Crucial SSDs however seem to run at about 6% full speed at APM level 128 (booted on battery) when compared to APM level 254 (booted on AC power).

The bad news is that there is no bug and no fault here. The ATA spec is sufficiently vague that Crucial SSDs running super slow in APM mode 128 is allowed and is compliant with the spec. Similarly a laptop defaulting to APM level 80h (128) is perfectly reasonable. The spec just says:

Table 106 — APM levels
COUNT field Level
00h Reserved
01h Minimum power consumption with Standby mode
02h..7Fh Intermediate power management levels with Standby mode
80h Minimum power consumption without Standby mode
81h..FDh Intermediate power management levels without Standby mode
FEh Maximum performance
FFh Reserved

(From the ATA spec)

Here is my experience with a Crucial MX300 SSD booted on battery power:

root@ubuntu:~# hdparm -B /dev/sda

/dev/sda:
 APM_level  = 128

root@ubuntu:~# hdparm -t /dev/sda

/dev/sda:
 Timing buffered disk reads:  94 MB in  3.02 seconds =  31.11 MB/sec

root@ubuntu:~# hdparm -B254 /dev/sda

/dev/sda:
 setting Advanced Power Management level to 0xfe (254)
 APM_level  = 254

root@ubuntu:~# hdparm -t /dev/sda

/dev/sda:
 Timing buffered disk reads: 1466 MB in  3.00 seconds = 488.44 MB/sec
| improve this answer | |
  • Same: (apologies for lack of formatting, indent doesn't seem to work in comments) $ sudo hdparm -t /dev/sdb2 /dev/sdb2: Timing buffered disk reads: 76 MB in 3.01 seconds = 25.23 MB/sec $ sudo hdparm -t /dev/sda3 $ sudo hdparm -B /dev/sdb /dev/sdb: APM_level = 128 $ sudo hdparm -B254 /dev/sdb /dev/sdb: setting Advanced Power Management level to 0xfe (254) APM_level = 254 $ sudo hdparm -t /dev/sdb2 /dev/sdb2: Timing buffered disk reads: 1448 MB in 3.00 seconds = 482.28 MB/sec – KevinButler Feb 17 '17 at 2:47
  • Wow. Just wow. This answer is immensely helpful. One more thing: if you use GNOME, their Disks utility actually allows to set the APM level on its GUI. – Venemo Aug 27 '17 at 22:51
  • I don't think it's a complete answer because I get same issue on Samsung SSD 840 EVO 120GB (APM_level = not supported) on a desktop PC (i.e. never on battery). There must be more popular reasons for read slowdowns. – cprn Feb 23 at 16:45
  • Very good analysis, although there is not much difference with WD ssd, but it is a great help to understand this problem. thanks – ajcg Apr 4 at 17:13
6

You may want to check /etc/hdparm.conf where you can configure the the apm level for power and battery mode.

Add

apm = 254
apm_battery = 254

to /etc/hdparm.conf

| improve this answer | |
4

I consistently found that I was able to hit the fast speeds when I booted the laptop while being plugged in. If I booted the laptop while it was running off the battery, and then plugged in, I was still stuck on the slow speeds.

This may have been something specific to my laptop (Lenovo T420). I changed all the BIOS settings to not save any power, to go for maximum performance; however, this did not let it have the fast speeds when only using the battery. I still had to be plugged in when I booted to have the fast speeds.

Another note: I can be plugged in when I boot, and then once booted, unplug the laptop. The laptop will keep the fast speeds until it boots up the next time.

ANSWER: Be plugged in when you boot.

| improve this answer | |
0

Please use a new enough kernel (v4.15+), try to use med_power_with_dipm for your Crucial MX300.

LPM min_power does not work well for all drivers, if med_power_with_dipm works for you, we should use a new quirk to let it fallback to med_power_with_dipm when min_power gets selected.

Also, please file a bug at Launchpad, so Ubuntu kernel engineers can solve the bug, or raise the issue to upstream.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.