0

I have a question which is slightly programming related, but it mostly relates to how ext4 works.

I have a program which writes 128MB to a file with changing random aligned offsets. I write 256KB every write call. Now the speed results are significantly different between the two devices.

I have /dev/sda and /dev/sdb both ext4, while sda is 8GB, sdb is 512MB.

For example, a write task on /dev/sda took 0.7 seconds to complete, while the same write took 0.05 seconds to complete on /dev/sdb. Both partitions are on the same hard disk, which is not an SSD.

EDIT: Sorry I forgot to add that this is running on a virtual machine with VirtualBox with the host being a Windows system. Its definitely only one physical drive because my laptop only has one.

EDIT2: I've found the issue, I was running the program on what I thought to be '/dev/sda' but it was a shared folder the I mounted from the host system. I didn't realize the filesystem will be different.

I'm interested to know what behind of scenes stuff could cause such a dramatic change in performance, thanks!

2
  • Considering your disk sizes, are we talking about a legacy system? If so, could this slowdown be caused by the old kernel? Commented Apr 16, 2015 at 11:04
  • @DmitryGrigoryev Yeah i've seen that answer, I'm using a new version of Xubunutu on a VM, so the kernel is 3.2.
    – Xsy
    Commented Apr 16, 2015 at 12:37

1 Answer 1

2

Since this is a little bit too long for a comment here it goes...

There are two things that got me intrigued:

First of all, /dev/sda and /dev/sdb are two different physical drives, otherwise we would be talking about /dev/sda1 and /dev/sda2. So if we are talking about different physical drives their performances may vary.

Second, in case this info is wrong and we have two partitions on the same drive (/dev/sda1 and /dev/sda2), what is the physical drive size? drives greater than 2TB partitions must be properly alligned otherwise you will have performance issues. Could it be that one of your partitions is alligned while the other one is not? Have you tried testing the partitions speed by other means apart from your program? check this to test drive speeds.

4
  • Can you link to a detailed explanation of why a particular alignment must be chosen for drives above 2TB? Commented Apr 16, 2015 at 10:51
  • @Dmitry Grigoryev en.wikipedia.org/wiki/Advanced_Format
    – YoMismo
    Commented Apr 16, 2015 at 11:23
  • Thanks. I thought there was something else besides 4K alignment. Commented Apr 16, 2015 at 11:36
  • Thank you for your answer, It helped me to find the issue, I've edited my original question.
    – Xsy
    Commented Apr 16, 2015 at 13:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .