I've put a fair bit of effort into performance, and my experience was that calculating the colours for each lab is relatively insignificant compared to just iterating through all of them. The updates are strided, meaning not every lab is updated every frame, and I've played around with the iteration approach to get it as fast as possible. I'd like to be able to only update labs when they're on screen, but unfortunately Factorio's synchronisation rules mean that everything needs to be kept in sync for all players.
Still, I'm open to any improvements if you're able to find optimisations that I missed!