简体   繁体   中英

RAMdisk reads seem to be no faster than hard disk (HDD) reads

I created a RAM disk and write speed seems to be 3x as fast, but read speeds are no better than my hard disk. I didn't think this was possible, I thought RAM would always be faster than HDD. Can this be true? Or is my code wrong and garbage in = garbage out?

mkdir /tmp/test
mount -t tmpfs -o size=1g myramdisk /tmp/ramdisk

#RAM DISK WRITE SPEED
dd if=/dev/zero of=/tmp/ramdisk/zero bs=4k count=100000

#HDD WRITE SPEED
dd if=/dev/zero of=/tmp/test/zero bs=4k count=100000

#RAM DISK READ SPEED
dd if=/tmp/ramdisk/zero of=/dev/null bs=4k count=100000

#HDD DISK READ SPEED
dd if=/tmp/test/zero of=/dev/null bs=4k count=100000

rm /tmp/ramdisk/zero
rm /tmp/test/zero

umount /tmp/ramdisk

rmdir /tmp/ramdisk
rmdir /tmp/test

Returns:

100000+0 records out
409600000 bytes (410 MB, 391 MiB) copied, 0.749689 s, 546 MB/s
100000+0 records in
100000+0 records out
409600000 bytes (410 MB, 391 MiB) copied, 2.32925 s, 176 MB/s
100000+0 records in
100000+0 records out
409600000 bytes (410 MB, 391 MiB) copied, 0.39752 s, 1.0 GB/s
100000+0 records in
100000+0 records out
409600000 bytes (410 MB, 391 MiB) copied, 0.365228 s, 1.1 GB/s

My server is AMD Opteron 3350 HE (4168), 4GB RAM (3.7GB free before I created the RAM disk), HDD is 7200 RPM.

it might be that your hdd access is already cached due to previous reads

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM