The Test: Comparing /dev/random speed on Linux and BSD
Date: January 6, 2012
IBM ThinkPad (1.8GHz) | |||
DragonFly | random | 129770365 | bytes/sec |
urandom | 79501725 | bytes/sec | |
OpenBSD | random | 92374770 | bytes/sec |
FreeBSD | random | 35212262 | bytes/sec |
Debian | urandom | 3576499 | bytes/sec |
NetBSD | urandom | 1379969 | bytes/sec |
Single-core Dell OptiPlex (2.54GHz) | |||
DragonFly | random | 160196377 | bytes/sec |
urandom | 81261656 | bytes/sec | |
OpenBSD | random | 150056320 | bytes/sec |
FreeBSD | random | 29790795 | bytes/sec |
Debian | urandom | 2388368 | bytes/sec |
NetBSD | urandom | 941130 | bytes/sec |
Gateway Solo laptop (600MHz) | |||
DragonFly | random | 39643501 | bytes/sec |
urandom | 20024305 | bytes/sec | |
OpenBSD | random | 28902905 | bytes/sec |
FreeBSD | random | 10608869 | bytes/sec |
Debian | urandom | 1002416 | bytes/sec |
NetBSD | urandom | 421040 | bytes/sec |
Operating systems tested:
- DragonFly BSD 2.10.1 i386
- OpenBSD 5.0 i386
- FreeBSD 8.2 i386
- Debian GNU/Linux 6.0.3 i386
- NetBSD 5.1 i386
Methodology: I downloaded and burned ISO installation images for DragonFly, FreeBSD, Debian, and NetBSD, and used my existing (official release) OpenBSD CDs to perform fresh, bare-metal installs on three different computers: a 1.8GHz IBM ThinkPad, a 2.54GHz Dell OptiPlex, and a 600MHz Gateway Solo. No VMs were used, and default installation parameters were accepted. (Only non-default choice: The UFS filesystem was chosen over HAMMER on DragonFly, given the small disks of the test machines.) I rebooted each machine after installation, logged in, and ran dd if=/dev/random bs=32k of=/dev/null, experimenting with different blocksize values before picking the fastest in each case. I then ran dd, using the count parameter in conjunction with the blocksize to write an equal number of bytes for each OS to /dev/null, thereby getting the purest numbers on /dev/random device speed.
Discussion: DragonFly has the highest /dev/random performance with OpenBSD following close behind. The /dev/random devices on DragonFly and OpenBSD are so fast that when wiping drives on these test machines, /dev/zero would not offer a performance improvement over /dev/random, as the disk itself is the limiting factor.
Please note that:
- On OpenBSD, all /dev/*random devices use the same code.
- On FreeBSD, /dev/urandom is a symlink to /dev/random.
- On Linux and NetBSD, /dev/random was too slow to record useful data and so /dev/urandom was chosen.
- On DragonFly BSD, /dev/random is inexplicably faster than /dev/urandom. This contradicts the current (as of Jan. 6, 2012) random(4) manual page which states that "The /dev/urandom device uses a different and much faster algorithm, but one which is not considered to be as secure (though for all practical purposes it probably is good enough)."