This past month has been a brutal succession of hidden hardware flaws being exposed. First, the revelation that iOS has indeed been throttling CPUs on older devices based on their claim to improve battery life. Second, the Meltdown/Spectre attack vectors threaten to slowdown CPUs ~20% in order to fix a security hole caused by an eager caching performance boost.
Adding another anecdote, this past month I noticed Jekyll compile times and NPM install times on my 2016 Surface Book laptop were extremely painful. I thought it was maybe a Bash on Windows issue, but upon further investigation I found a 2-3x difference between when my laptop was plugged in and when I was on battery. Microsoft folks eventually instructed me that the taskbar’s battery icon has a performance slider you can use to boost your speed.
It isn’t far fetched that a device would reduce power consumption when on battery, it makes the device last longer, makes users happier. This explains iOS’ less-than-stellar performance in Low Power mode. I know this mode well because my last phone probably spent 80% if its life in Low Power mode.
What’s this mean for websites? Well, we can’t rely on device names and numbers as a corollary for performance. Even a device that shipped with a great CPU, might be unknowingly crippled by the OS or some other battery saving feature. This creates another lens in the already broad landscape of hostile browsers and devices.
And with Battery Status API being a security concern, augmenting sites for Low Power mode isn’t an option either. We’re sending code to inconsistent executors.
[T]he old bottleneck for web performance used to be the network. But the new bottleneck for web performance is the CPU, and particularly the main thread. –Lin Clark
But it’s not all bad. Kudos to browsers, they have been working to pull rendering off the main thread. That’s good for websites. I’ve heard Googlers talk about splitting logic into asynchronous Workers. This is good for websites too. My UI and logic are so mixed up, I’m not sure where I can squeeze gains like these, but I’ll be looking for opportunities. Web Assembly stands to revolutionize applications as well. So that future is exciting and new.