Friday, November 20, 2015

Yet another hdd vs ssd comparison

There are many article online that articulate how fast a solid state drive in comparison to a spinning hard disk drive. But ones wonder really, just how fast is ssd. I mean if your earning is limited and the current spinning disk is working fine, there is no compelling reason to make the change and at the same time, it will be difficult to afford a ssd considering the cost per gb. As of this writing, a samsung 850 pro 512GB selling at compuzone malaysia at a staggering pricing of 1378MYR!!! But there is a kind soul who generously donate ssd to me and as a gesture of good will back to him, here in I will write a blog describe my experience migrating from a Hitachi/HGST Travelstar Z7K500 HGST HTS725050A7E630 to a Samsung SSD 850 PRO 512GB.

One things for sure, ssd weight is so light. It is only 66gram! In comparison with hdd at 95gram. For the first timer, ssd weight is so light that it confused me like did it actually contain the size of 512GB.

For the spinning hdd, I took 5 samples, 1min 41sec, 1min 34sec, 1min 34sec, 1min 34sec and 1min 31sec. All measurements from the moment I push the power button until I see the login screen. Of cause, there many services running during bootup. On average, the bootup time is around  1min 48sec.

Next, I benchmark the current hdd with hdparm and dd.

 user@localhost:~$ sudo hdparm -t /dev/sda5  
   
 /dev/sda5:  
  Timing buffered disk reads: 322 MB in 3.01 seconds = 107.12 MB/sec  
 user@localhost:~$ sudo hdparm -t /dev/sda5  
   
 /dev/sda5:  
  Timing buffered disk reads: 322 MB in 3.01 seconds = 107.13 MB/sec  
 user@localhost:~$ sudo hdparm -t /dev/sda5  
   
 /dev/sda5:  
  Timing buffered disk reads: 322 MB in 3.01 seconds = 107.12 MB/sec  
   
   
 user@localhost:~$ sudo hdparm -T /dev/sda5  
   
 /dev/sda5:  
  Timing cached reads:  5778 MB in 2.00 seconds = 2889.25 MB/sec  
 user@localhost:~$ sudo hdparm -T /dev/sda5  
   
 /dev/sda5:  
  Timing cached reads:  5726 MB in 2.00 seconds = 2863.32 MB/sec  
 user@localhost:~$ sudo hdparm -T /dev/sda5  
   
 /dev/sda5:  
  Timing cached reads:  5702 MB in 2.00 seconds = 2850.84 MB/sec  

I have performed 3 tests with cache and without cache reading. On average, non caching read speed is about 107.12MB/sec and caching read speed is 2867.80MB/sec . The parameter for hdparm is shown below.
       -t     Perform timings of device reads for benchmark and comparison purposes.  For meaningful results, this operation should be repeated 2-3 times on an otherwise inactive system
(no  other active processes) with at least a couple of megabytes of free memory.  This displays the speed of reading through the buffer cache to the disk without any prior caching of data.  This measurement is an indication of how fast the drive can sustain sequential data reads under Linux, without any filesystem overhead.  To ensure  accurate measurements, the buffer cache is flushed during the processing of -t using the BLKFLSBUF ioctl.
       -T     Perform  timings of cache reads for benchmark and comparison purposes.  For meaningful results, this operation should be repeated 2-3 times on an otherwise inactive system
 (no other active processes) with at least a couple of megabytes of free memory.  This displays the speed of reading directly from  the  Linux  buffer  cache  without  disk access.  This measurement is essentially an indication of the throughput of the processor, cache, and memory of the system under test.

Next, I use command dd to do higher layer benchmark on the disk. See below.

 user@localhost:~$ time sh -c "dd if=/dev/zero of=ddfile bs=8k count=250000 && sync"; rm -f ddfile  
 250000+0 records in  
 250000+0 records out  
 2048000000 bytes (2.0 GB) copied, 32.5028 s, 63.0 MB/s  
   
 real     0m41.773s  
 user     0m0.068s  
 sys     0m4.048s  
 user@localhost:~$ time sh -c "dd if=/dev/zero of=ddfile bs=8k count=250000 && sync"; rm -f ddfile  
 250000+0 records in  
 250000+0 records out  
 2048000000 bytes (2.0 GB) copied, 27.1676 s, 75.4 MB/s  
   
 real     0m37.012s  
 user     0m0.056s  
 sys     0m3.848s  
 user@localhost:~$ time sh -c "dd if=/dev/zero of=ddfile bs=8k count=250000 && sync"; rm -f ddfile  
 250000+0 records in  
 250000+0 records out  
 2048000000 bytes (2.0 GB) copied, 19.4599 s, 105 MB/s  
   
 real     0m37.929s  
 user     0m0.064s  
 sys     0m3.740s  

So the arithmetic, ( 8 x 1024 x 250000 / 2014 / 1024 ) / real so that give 46.75MB/sec, 52.77MB/sec and 51.49MB/sec respectively on all three tests and on average 50.33MB/sec.

Now to the samsung ssd.

 root@localhost:~# sudo hdparm -t /dev/sda6  
   
 /dev/sda6:  
  Timing buffered disk reads: 770 MB in 3.01 seconds = 256.00 MB/sec  
 root@localhost:~# sudo hdparm -t /dev/sda6  
   
 /dev/sda6:  
  Timing buffered disk reads: 762 MB in 3.00 seconds = 253.98 MB/sec  
 root@localhost:~# sudo hdparm -t /dev/sda6  
   
 /dev/sda6:  
  Timing buffered disk reads: 758 MB in 3.00 seconds = 252.44 MB/sec  
   
   
 root@localhost:~# sudo hdparm -T /dev/sda6   
   
 /dev/sda6:  
  Timing cached reads:  5820 MB in 2.00 seconds = 2910.31 MB/sec  
 root@localhost:~# sudo hdparm -T /dev/sda6   
   
 /dev/sda6:  
  Timing cached reads:  6022 MB in 2.00 seconds = 3011.33 MB/sec  
 root@localhost:~# sudo hdparm -T /dev/sda6   
   
 /dev/sda6:  
  Timing cached reads:  5698 MB in 2.00 seconds = 2849.14 MB/sec  
 root@localhost:~#   
   
   
 root@localhost:~# time sh -c "dd if=/dev/zero of=ddfile bs=8k count=250000 && sync"; rm -f ddfile   
 250000+0 records in  
 250000+0 records out  
 2048000000 bytes (2.0 GB) copied, 4.14268 s, 494 MB/s  
   
 real     0m8.280s  
 user     0m0.040s  
 sys     0m2.084s  
 root@localhost:~# time sh -c "dd if=/dev/zero of=ddfile bs=8k count=250000 && sync"; rm -f ddfile   
 250000+0 records in  
 250000+0 records out  
 2048000000 bytes (2.0 GB) copied, 4.18595 s, 489 MB/s  
   
 real     0m8.279s  
 user     0m0.068s  
 sys     0m2.036s  
 root@localhost:~# time sh -c "dd if=/dev/zero of=ddfile bs=8k count=250000 && sync"; rm -f ddfile   
 250000+0 records in  
 250000+0 records out  
 2048000000 bytes (2.0 GB) copied, 3.94227 s, 519 MB/s  
   
 real     0m8.258s  
 user     0m0.080s  
 sys     0m2.060s  
   

On average, non caching read speed is 253.67MB/sec and caching read speed is 2926.93MB/sec. As for dd tests, on average, 236.10MB/sec. On average, the bootup time is around  30sec! The significant change is during after grub and the login shown is around 3 seconds or less. Although the rated for this ssd for sequantil read and write is 550/520MB/sec, maybe it was because of my old system bandwidth maxing out.

Significant time reduced during bootup and disk read is clearly seen from the statistics above. As for user experience, everything become so fast! To put into comparison, hdd to ssd is like proton car to F1 car. I think in the future, it will help in term of programming like code grepping and code find.


UPDATE: with adjustment to the grub timeout and changes to the POST to fast boot, now my cold boot to login screen is improved to 20seconds!

No comments:

Post a Comment