Poor IO performance - PCIe NVMe Samsung 950 pro
Solution 1:
Thank you for your question, it has been incredibly helpful for me.
I have a very similar experience, different hardware setup (I am using an Intel NVMe SSD). But I am also running Ubuntu 16.04. Given your evidence and a similar result found in this article I was convinced that the issue was with how Ubuntu was setting up the NVMe drives.
I was determined to solve the issue without giving up completely on Ubuntu. But no matter what I did, I was not able to get speeds above 2000 MB/sec when testing with hdparm exactly as you described.
So, I did some digging, and found a guide provided by Intel. I tried everything they suggested in this guide and found that one part was different. Near the bottom it discusses aligning the drive partitions correctly. This is the one part that didn't match up with my installation. My starting block was not divisible by 4096 bytes. It was using a 512 byte sector size instead of a 4k sector size.
Sure enough, I formatted the disk to start the partition at a value divisible by 4096 and FINALLY I was able to break speeds of 2000 MB/s.
Right now it is averaging 2.3 GB/s when I expect it to be a bit higher. I blame this on the fact that when I run sudo fdisk -l
the NVMe drive is still shown with a physical sector size of 512 bytes. I plan to continue investigating but I hope this helps you!
Solution 2:
Caution: This answer is old. As of Linux 4.19 blk_mq is the default scheduler. It is most likely that the problem for your PCIe NVMe SSD running slow stems form elsewhere.
Original answer:
Please add
scsi_mod.use_blk_mq=1
to your kernel boot parameters, otherwise I don't think you will see the benefit of NVMe's increased command queue and command per queue.
Note: I know it's for arch but you might also want to take a look at the Wiki for more info about tuning I/O.
Solution 3:
This thread is one year old (October 2016). One of the highest upvoted answers recommends an Intel NVMe driver that is two years old (2015).
In February 2017 though Samsung released a Firmware Update that uses a Linux based boot ISO installer. On the same link there are drivers you can install for Windows 7/8/10. I'll be installing both soon on my new Samsung 960 Pro and brand new Dell based i7-6700 laptop. Along with flashing BIOS and updating other Dell based drivers.
I think it's important to revisit these old threads and provide new users with current (as of October 11, 2017 anyways) links so they have all options open.
There are many google searches returned for slow performance of Samsung 960 Pro under Linux being half the speed of Windows so I encourage everyone to search out as many options as possible.
After implementing scsi_mod.use_blk_mq=1
kernel parameter:
$ systemd-analyze
Startup finished in 7.052s (firmware) + 6.644s (loader) + 2.427s (kernel) + 8.440s (userspace) = 24.565s
Removing the kernel parameter and rebooting:
$ systemd-analyze
Startup finished in 7.060s (firmware) + 6.045s (loader) + 2.712s (kernel) + 8.168s (userspace) = 23.986s
So it would appear now that scsi_mod.use_blk_mq=1
makes system slower not faster. At one time it may have been beneficial though.