Hello, engineers! I'm a newer face at Wube and have been mainly working on expansion content for about one year now. Today, I'm here to share some exciting non-expansion news for our Mac players.
As of version 1.1.71, Factorio runs natively on Apple Silicon Macs! On these machines, the game should run faster and use less energy than in previous versions. You can see which binary version you are running in the top-left corner of the main menu.
x86_64 binary for Intel Macs
arm64 binary for Apple Silicon Macs 🥳
This has been a long time coming, but we were never in a good position to implement these improvements... until now.
In February, I traveled from the USA to the Wube offices in Prague for the first time. While waiting in the airport, I decided to work on Factorio with my Intel Macbook Pro. Within 30 minutes, my laptop's battery had depleted more than half of its charge. I had a 22-hour day ahead of me, many more hours of travel planned this year, and a lot of work to do.
I immediately ordered an Apple Silicon MacBook from my seat in the airport.
When it arrived, I was instantly impressed with its battery life. I can now comfortably work on Factorio wherever I am. More importantly, the factory can grow wherever I am. But I wasn't satisfied. As a software engineer and Factorio engineer, I had to ask myself: can I play Factorio for even longer with native Apple Silicon support?
The first problem to solve was multiplayer determinism. Ensuring that the arm64 and x86_64 versions of Factorio behaved identically is critical for multiplayer to function. Luckily at the time, Twinsen was already developing a port for Nintendo Switch (FFF-370) and shared with me his plans to support cross-platform play. So I didn't need to worry about this for now.
The development of the port for Nintendo Switch was super-confidential. Not even the community members who had access to Factorio's source code were permitted to know. So, to avoid leaking the fact that the port was being developed, I postponed working on this project until after the announcement. On October 19th, the time was right to start again.
Next, we needed to update our macOS build process. Our process hadn't been reviewed for years. It contained a few time-consuming steps that were difficult to port for ARM architectures, and it was using outdated compiler versions. With some trial-and-error, I rewrote and simplified Factorio's Mac build instructions, and reduced the time to set up a clean Mac for Factorio development from a few hours to a few minutes (depending on the Internet connection).
With a more streamlined, standardized build process, I set to work updating our build rules to support ARM. This part was simple; they were already structured to support multiple architectures, so I simply added the ARM architecture alongside the x86-64 architecture and fixed a few broken flags. I threw in a few new build rules for generating a universal macOS binary (which was extremely easy), and soon we had a functioning version of Factorio that ran natively on both Apple Silicon and Intel Macs!
The final challenge was deployment. Our macOS build server uses an x86-64 CPU, so I needed to figure out how to compile both the x86-64 and the arm64 versions of Factorio on a single x86-64 machine. Our compilers and linkers worked just fine, but obtaining the C++ libraries for ARM was surprisingly more difficult than it needed to be. After a lot of experimenting, I found the steps that worked most consistently and wrote a custom BASH script that downloads and manually "installs" the arm64 C++ libraries from Homebrew. This is the most hacky part of the whole process, but most developers will never need to do this.
In total, it took about 4 weeks to investigate, develop, test, finalize, and deploy the new macOS build process.
After we had a functioning universal binary, we ran benchmarks and conducted manual tests to see what improved.
We ran benchmarks on 3 different Apple Silicon machines, using the same compiled release binary and run settings. We used the famous flame_Sla 10k map and averaged our results. Here is a summary of our findings:
Overall, we observed that the arm64 version of Factorio performed 19%-25% better in our benchmarks than the x86_64 version.
We even compared runs between macOS 10.13.6 High Sierra, 12.6.1 Monterey, and 13.0 Ventura. We observed no notable performance difference between these OS versions. The differences we observed were all less than 10% and did not consistently favor any particular version.
In addition to running benchmarks, I did a couple very unscientific tests on my laptop (MacBook Pro 14-inch 2021, Apple M1 Max, 64 GB) to check FPS and energy consumption:
*Energy Impact is calculated by Activity Monitor and is purportedly "a relative measure of the current energy consumption of the app (lower is better)".
These results — although not as precise — are similar to the benchmarks. The arm64 version's FPS was about 20% higher and energy impact was about 15% lower than that of the x86_64 version.
These results are exciting, and are definitely better than what I had hoped for! Individual experiences may differ, but so far, players have reported an overall improvement in performance.
My thanks to colleague Therenas, community member Xorimuth, and others with source access for help with troubleshooting and testing the new builds; to colleague Sanqui for his help and patience in updating our deployment machines; and of course to Twinsen for his excellent work on ARM support.
Last weekend, I charged my Macbook to full and opened the mega base our team built during our most recent expansion play-through. I set to work fixing manufacturing problems and troubleshooting logistic issues, expanding the factory, and building defenses. I got lost in the glorious mess we'd built for three and a half hours before needing to recharge, and my game ran at a comfortable 60 FPS the entire time.
Factorio players have a lot of bottlenecks to contend with when building a Factory. Hopefully now, their laptop's battery is one less bottleneck they need to worry about.
See you next time!