There are two problems with "random" in the computing world. First, "random" isn't truly random, it's only pseudo-random, and the process of making pseudo-random numbers more random is a relatively time consuming process. To help keep your smartphone or tablet whizzing along, the operating system has a pool of "randomness" that be used to help processes that need a random number. As this pool is used the random bits are depleted and need to be restocked with a new set of randomness. Sometimes the random pool gets used up, resulting in processes being "blocked" while the randomness is replenished.
Remember how we mentioned that the process of making these random numbers takes some amount of time? While your device is hunting around for "randomness" your processes are lagging. To address that a developer asked what would happen if we made "random" just a little less random? Would that speed things up? The result is an app called Seeder 1.1 Entropy Generator which is said to provide "significant lag reduction" for root users. How does it do that, and does it work?
Here's what the developer has to say:
On some (older) versions of Android, the JVM (and other components) read large amounts of random data from the blocking /dev/random device. On newer builds, this problem has been solved, yet depletion of the input entropy pool still seems to slow devices.
So, I cross-compiled rngd, and used it to feed /dev/urandom into /dev/random at 1 second intervals.
Result? Significant lag reduction!
Chrome, maps, and other heavy applications switch instantaneously, and map tiles populate as fast as I can scroll. You know how sometimes when you hit the home button, it takes 5-10 seconds for the home screen to repopulate? Yeah. Blocking on read of /dev/random. Problem solved. But don't take my word for it .. give it a shot!
So we did. We installed the app on both a Nexus 4 and a Nexus 7 and went about a normal day. Benchmarks didn't yield much change from stock, but day to day activities seemed snappier! Maybe this app could really improve all around performance!
Unfortunately there is a lot of heated debate around this "fix". Arguments from "it makes you less secure" to "it doesn't work" are being thrown around left and right. People are passionate on both sides of the isle: either it's the greatest thing since sliced bread — or it's nothing more than a placebo. Then a CyanogenMod maintainer chimed in:
IMNSHO the recent entropy pool fad is bull***. The only users of /dev/random are libcrypto (used for cryptographic operations like SSL connections, ssh key generation, and so on), wpa_supplicant/hostapd (to generate WEP/WPA keys while in AP mode), and the libraries that generate random partition IDs when you do an ext2/3/4 format. None of those 3 users are in the path of app execution, so feeding random from urandom does nothing except make random... well... less random.
The only conceivable reason some devices may feel faster is because by constantly polling the PRNG, it keeps the device's I/O in constant use (which in turn, depending on device, will make the CPU stick to higher clock frequencies to keep up and/or ramp up the IO scheduler).
But does it work? Ironically, the answer is yes — but probably not for the reason that the developer intended to solve. In our tests Chrome was snappier and Google Maps was much quicker drawing tiles. Why? Probably not because the entropy pool was any quicker, but because the CPU and I/O processes were being "kept hot" by the app constantly updating the system with the new, "less random" bits. In short, the CPU wasn't returning to a slower speed as frequently, resulting in a faster experience — and shorter battery life.
All in all, it was in interesting experiment, but I think we can put this magic voodoo to bed. Sure, it may work, just not as intended, and it's probably not worth the cost in terms of battery life.
Want to give it a try for yourself? You can download the app here.
Image Credit: Dilbert by Scott Adams