CentOS 6.8 & Samsung SSD unable to trim

Discussions about using Mac OS X guests (on Apple hardware) in VirtualBox.
Post Reply
ericovk
Posts: 8
Joined: 4. Apr 2012, 11:53
Primary OS: Mac OS X other
VBox Version: OSE Debian
Guest OSses: CentOS 6.8 and 7.0

CentOS 6.8 & Samsung SSD unable to trim

Post by ericovk »

I was having speed trouble on CentOS & my Samsung EVO 500GB SSD drive.
hdparm -t /dev/sda1 gave me speeds aroubd 30MB/s

After enabling "Use Host IO cache" speeds are getting better at ± 250~350 MB/s. It's still not the 500MB/s that speed test I am getting in Mac OS El Capitan with Disk Sensei. (different tests show disk speeds of 500Mb/s read, 350MB/s write and 165 MB/s rewrite).

In both CentOS and OS X, it isn't possible anymore to enable TRIM support.

CentOS output disk info:

Code: Select all

# hdparm -I /dev/sda

/dev/sda:

ATA device, with non-removable media
	Model Number:       VBOX HARDDISK                           
	Serial Number:      VBdc6ad498-24be90e2 
	Firmware Revision:  1.0     
Standards:
	Used: ATA/ATAPI-6 published, ANSI INCITS 361-2002 
	Supported: 6 5 4 
Configuration:
	Logical		max	current
	cylinders	16383	16383
	heads		16	16
	sectors/track	63	63
	--
	CHS current addressable sectors:   16514064
	LBA    user addressable sectors:  209715200
	LBA48  user addressable sectors:  209715200
	Logical/Physical Sector size:           512 bytes
	device size with M = 1024*1024:      102400 MBytes
	device size with M = 1000*1000:      107374 MBytes (107 GB)
	cache/buffer size  = 256 KBytes (type=DualPortCache)
Capabilities:
	LBA, IORDY(cannot be disabled)
	Queue depth: 32
	Standby timer values: spec'd by Vendor, no device specific minimum
	R/W multiple sector transfer: Max = 128	Current = 128
	DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6 
	     Cycle time: min=120ns recommended=120ns
	PIO: pio0 pio1 pio2 pio3 pio4 
	     Cycle time: no flow control=120ns  IORDY flow control=120ns
Commands/features:
	Enabled	Supported:
	   *	Power Management feature set
	   *	Write cache
	   *	Look-ahead
	   *	48-bit Address feature set
	   *	Mandatory FLUSH_CACHE
	   *	FLUSH_CACHE_EXT
	   *	Gen2 signaling speed (3.0Gb/s)
	   *	Native Command Queueing (NCQ)
Anyone knows what's wrong with my settings?
I am running on a Mac Mini Server with SATA3 support.
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: CentOS 6.8 & Samsung SSD unable to trim

Post by socratis »

  1. You'll never get you host's native speed in a guest. By definition.
  2. As you discovered, enabling the "Use Host I/O Cache" does make a difference.
  3. You should enable the "Solid-state Drive" option for your virtual HD. It's not going to make things faster, but it might give you the TRIM support that you're looking for.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
ericovk
Posts: 8
Joined: 4. Apr 2012, 11:53
Primary OS: Mac OS X other
VBox Version: OSE Debian
Guest OSses: CentOS 6.8 and 7.0

Re: CentOS 6.8 & Samsung SSD unable to trim

Post by ericovk »

Thanks @socratis: but I am getting 500MB/s speeds on a new box I installed today when I repeat the benchmark a couple of times.

Today I installed a new server next to my current box. CentOS 7 / Nginx / PHP-FPM / etc. The biggest different is that I created a 10 GB fixed hdd size.

My older box is a CentOS 6.8 / Apache / PHP-FPM / with variable disk size. (max 100 GB).

I don't understand the outcome of these tests as they vary a lot.

root@old_centos_6.8_box:~# hdparm -t /dev/sda

/dev/sda:
Timing buffered disk reads: 258 MB in 3.00 seconds = 85.91 MB/sec
root@old_centos_6.8_box:~# hdparm -t /dev/sda

/dev/sda:
Timing buffered disk reads: 632 MB in 3.01 seconds = 210.00 MB/sec
root@old_centos_6.8_box:~# hdparm -t /dev/sda

/dev/sda:
Timing buffered disk reads: 696 MB in 3.02 seconds = 230.44 MB/sec
root@old_centos_6.8_box~# hdparm -t /dev/sda

/dev/sda:
Timing buffered disk reads: 766 MB in 3.01 seconds = 254.36 MB/sec
root@old_centos_6.8_box:~# hdparm -t /dev/sda1

/dev/sda1:
Timing buffered disk reads: 500 MB in 1.24 seconds = 403.46 MB/sec
root@old_centos_6.8_box:~# hdparm -t /dev/sda1

/dev/sda1:
Timing buffered disk reads: 500 MB in 1.26 seconds = 396.04 MB/sec
root@old_centos_6.8_boxbe:~# hdparm -t /dev/sda1

/dev/sda1:
Timing buffered disk reads: 500 MB in 1.27 seconds = 393.30 MB/sec

(Mind the difference between /dev/sda and /dev/sda1)

The new CentOS 7 box gives me instant disk speed:

hdparm -t /dev/sda

/dev/sda:
Timing buffered disk reads: 1134 MB in 3.00 seconds = 377.48 MB/sec

But why? How come? Why is this older box slower until I repeat the test many times?
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: CentOS 6.8 & Samsung SSD unable to trim

Post by socratis »

Please read the following: Minimum information needed for assistance.
As far as the "VBox.log.zip" goes, here's what you do:
  1. Start the VM. Not from a saved or suspended state. Clean start.
  2. Take the steps required to generate/observe the problem.
  3. Shut down the VM. Not suspended, not paused. Shut down.
  4. Right-click on the VM in the VirtualBox Manager.
  5. Select "Show Log..."
  6. Save it (just the first log, VBox.log), ZIP it and attach it in your response (see the "Upload attachment" at the bottom of the form).
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
ericovk
Posts: 8
Joined: 4. Apr 2012, 11:53
Primary OS: Mac OS X other
VBox Version: OSE Debian
Guest OSses: CentOS 6.8 and 7.0

Re: CentOS 6.8 & Samsung SSD unable to trim

Post by ericovk »

The problem is that I haven't got a clue where to look. I attached the log file that you were asking for. Can't find anything awkward. The disk with the issues is "thiscouldbe 20160628-disk1.vdi"

I do know that it's not the SSD itself, but it's inside the virtual machine.

Some more info of the disk.
# file -sL /dev/sda
/dev/sda: x86 boot sector; GRand Unified Bootloader, stage1 version 0x3, boot drive 0x80, 1st sector stage2 0x849fc, GRUB version 0.94; partition 1: ID=0x83, active, starthead 32, startsector 2048, 1024000 sectors; partition 2: ID=0x8e, starthead 221, startsector 1026048, 208689152 sectors, code offset 0x48

# fdisk -l

Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00021af7

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 13055 104344576 8e Linux LVM

Disk /dev/sdb: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_server-lv_root: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_server-lv_swap: 6325 MB, 6325010432 bytes
255 heads, 63 sectors/track, 768 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_server-lv_home: 46.8 GB, 46833598464 bytes
255 heads, 63 sectors/track, 5693 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Attachments
virtualbox.log
(118.33 KiB) Downloaded 22 times
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: CentOS 6.8 & Samsung SSD unable to trim

Post by socratis »

00:00:01.468761   NumCPUs           <integer> = 0x0000000000000004 (4)
...
00:00:01.596585 CPUM: Physical host cores: 4
You have 4 physical cores in your Mac and you assign all of them to the guest. Not a great idea, because you're going to starve your host. Drop it down to 2, max 3. Otherwise the performance might suffer. I don't know if that is the source of your worries.
00:00:01.469614   VRamSize         <integer> = 0x0000000000c00000 (12 582 912, 12 MB)
That's way too low of a VRAM setting. Try to take it to at least 64 MB.
00:00:08.881772 VMMDev: Guest Log: int13_harddisk_ext: function 41, unmapped device for ELDL=8f
00:00:08.882282 VMMDev: Guest Log: int13_harddisk: function 02, unmapped device for ELDL=8f
You have several instances of those. I don't know exactly what they mean, but "I have a bad feeling about this"™.

As for the benchmarks, there is a saying; never trust benchmarks run on a VM. Finally, for the finer details of your HD configuration, I think I'll pass the baton to more Linux and HardDrive experts than myself (you know who you are ;) ).

BTW, the title and original question was referring to the TRIM support. You never told me if enabling the SSD flag in the VM settings helped you. You went straight to the benchmarks...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: CentOS 6.8 & Samsung SSD unable to trim

Post by mpack »

ericovk wrote:Thanks @socratis: but I am getting 500MB/s speeds on a new box I installed today when I repeat the benchmark a couple of times.
Not a good thing to do when testing I/O speed. Every time after the first you are testing the speed of the combined host and guest cache's.

Benchmarks run inside VMs are often misleading.
ericovk
Posts: 8
Joined: 4. Apr 2012, 11:53
Primary OS: Mac OS X other
VBox Version: OSE Debian
Guest OSses: CentOS 6.8 and 7.0

Re: CentOS 6.8 & Samsung SSD unable to trim

Post by ericovk »

If benchmarks run inside VM are misleading, how do I measure / benchmark the right way?

An outcome of 15x higher speed (on first tests inside CentOS) is a big difference. It doensn't matter when I try to run this test, or how many times I run it.

@Socrates: Sorry about the somewhat misleading title. I am searching for an answer on how my CentOS is lacking speed. I thought enabling TRIM could be THE answer to this. As it really shouldn't lack speed with a Quad Core i7, 16GB RAM and a Samsung EVO 500GB drive. OS X is fully dedicated to run Virtualbox, and this box is the only box running on this system.
The second VM box is showing me that there is something wrong with my current server box. Last weekend I tried to build another fresh install. Hdparm is also showing me 400 ~ 500 MB/s speed on this box.

As for the cores: I have 8 cores total. Virtualbox's settings are still "in the green" on 4 cores.
VRAM isn't being used imho. Therefor I set it to the lowest green setting.
I don't know eather about this notice

Code: Select all

VMMDev: Guest Log: int13_harddisk_ext: function 41, unmapped device for ELDL=8f
But the other VM box (see attachment Nginx-2016-07-10-21-33-35.log) is showing me the same error, but bot the lack of speed.

I attached newer log files. Unfortunately editing settings to above hint didn't improve the box's speed.
Attachments
cpu settings.png
cpu settings.png (78.81 KiB) Viewed 4129 times
thiscouldbe 20160628-2016-07-11-11-57-49.log
(115.82 KiB) Downloaded 15 times
Nginx-2016-07-10-21-33-35.log
(108.6 KiB) Downloaded 19 times
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: CentOS 6.8 & Samsung SSD unable to trim

Post by socratis »

ericovk wrote:As for the cores: I have 8 cores total. Virtualbox's settings are still "in the green" on 4 cores.
No you don't have 8 cores. You have 4 physical and 8 logical cores. VirtualBox cares only about physical ones. We have the same exact processor, so I know. You may want to search for "MacCPUID" from Intel and see for yourself (under the Misc tab). I'm not sure why VirtualBox shows you're in the green up to 8.
ericovk wrote:If benchmarks run inside VM are misleading, how do I measure / benchmark the right way?
There is no right or wrong way to benchmark a VM. There is no way. Especially on the I/O side. You could potentially benchmark network I/O, but I wouldn't count on it.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: CentOS 6.8 & Samsung SSD unable to trim

Post by Perryg »

Actually the screen shot is accurate. It is a matter of the users reading it wrong. It says 8 CPUs total or vCPU as I like to call it. This is not cores though. Hyper-threads turn a 4 core processor into a 4 core-8 thread ( vCPU) processor.

You may also be interested in the following CPU Cores versus threads
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: CentOS 6.8 & Samsung SSD unable to trim

Post by socratis »

socratis wrote:I'm not sure why VirtualBox shows you're in the green up to 8.
Note to self: pay closer attention to the screenshots of the post you're replying to.

Perry of course you're right, I didn't even notice the screenshot. It's not in the green up to 8, only up to 4.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
ericovk
Posts: 8
Joined: 4. Apr 2012, 11:53
Primary OS: Mac OS X other
VBox Version: OSE Debian
Guest OSses: CentOS 6.8 and 7.0

Re: CentOS 6.8 & Samsung SSD unable to trim

Post by ericovk »

So, what you guys are saying is that I can't compare the old vm stats (centos 6.8 / dynamic disk / installed + 2 years ago):

Code: Select all

hdparm -t /dev/sda

/dev/sda: Timing buffered disk reads: 110 MB in  3.05 seconds =  36.12 MB/sec
with the new vm? (centos 7 / fixed disk size / same physical machine and ssd disk)

Code: Select all

hdparm -t /dev/sda

/dev/sda: Timing buffered disk reads: 1346 MB in  3.00 seconds = 448.48 MB/sec
Post Reply