APPLE SILICON M1 VS INTEL i9

                                            APPLE SILICON M1 VS INTEL i9


How CPU Works?

The central processing unit or CPU is like the engine in your car or the brain in your skull and is like a really fancy calculator, used to run the applications on your computer. When you write software in a language like javascript or python, you're actually writing a set of instructions that will be executed as machine code by a CPU. Which itself is a carefully crafted piece of metal and silicon, that contains billions of tiny transistors or on/off switches, that represent ones and zeros to perform mathematical calculations. A CPU will combine multiple transistors together to form logic gates for example, And will take two binary inputs and validate that both are true to produce a true output, It only takes a few basic logic gates to solve highly complex computational problems. Modern chips contain billions of transistors, and they can be flipped on and off billions of times per second. The state of the CPU is synchronized by an oscillator known as the Clock Generator, in general, the more times the clock can pulse per second the faster the CPU can compute and is normally measured in Gigahertz. Gamers will sometimes overclock their CPUs to gain more performance, at the cost of higher temperatures and a lower life expectancy.

Instruction Cycle

To run applications, it interacts with the system memory or RAM, in a series of four steps known as the machine or instruction cycle. Step one is the fetch phase, think of a software program as a set of instructions stored in the RAM, the CPU has registers to temporarily store the address and memory that it wants to interact with. The program counter starts at 0 and copies that address to the memory address register, then the control unit sends out a signal to copy. The data from that address to the instruction register, at which point it needs to figure out how to use this instruction in the decode phase the control unit parses the actual bits. Most importantly, the opt code contains the instruction like add or subtract and the operand is the address in memory, to perform that operation on the final execute stage takes the decoded information and passes it as electrical signals to the relevant parts of the CPU. The arithmetic logic unit or ALU can perform math on the data, and then store the results in RAM to change the state of the program. The cycle is repeated billions of times per second, and modern chips utilize multiple CPU cores to run multiple computations in parallel. That's how a CPU works under the hood, but there's a lot more you should know about processor architectures if you're a developer.

I am here to take you beyond 100 seconds in your quest to learn how processor architectures differ and how those differences affect our productivity as developers. I'll show you what the apple silicon chip and a refrigerator have in common and then I'll share some of my own experiences with using developer tools and build execution on the first generation Apple Silicon chip called the M1 chip, as compared to the intel chip first and foremost. I just want to say that my personal productivity as a developer depends less on the processors inside my computer and more on how much coffee I had and whether I'm trying to work after a big meal. But aside from human factors let's dig deeper into why the new Apple Silicon Machines have been really kicking up a storm and changing the industry software development including spoiler alert, the M1 machines have been beating the intel machines in pretty much every build test I've thrown at it except a couple. But it's not all roses so let's talk about some downsides later too. 

APPLE SILICON M1 VS INTEL i9

So why is it so fast? The first point I want to discuss is the physicality differences of the Apple Silicon way vs the old intel and AMD way, this is what apple silicon and your refrigerator at home have in common. All right imagine for a minute that you want to make a turkey with cheese sandwich, you go over to the refrigerator and in one place you have the turkey breast, the cheese, the mayonnaise, the mustard, all those ingredients are right there in one place and you don't have to run around the house to gather them. You don't have to drive to lots of stores to pick them up and this saves you lots of time and energy, this kind of efficiency can be found in the New Apple Silicon chips, because they aren't just a new processor. Apple silicon is a collection of many chips that are housed inside one silicon container this type of system is known as a System on Chip (SoC) and it's essentially an entire computer on one chip. The main CPU, the GPU, the I/O controller, the ML engine, they're all co-located so when the task is to make an electronic sandwich so to speak, or in other words to do some work that involves all these different components an SoC is going to be a lot more efficient, in terms of energy usage, using only a tiny bit of power. And at the same time, it's going to be faster than say a typical machine, that has all the components separate. Intel-based machines have a CPU that's a single chip and memory is located somewhere else on the motherboard, the I/O is somewhere else. The individual components might be even more powerful than the ones available at the moment on the latest Apple Silicon-based machines, but that comes at a cost. Since these powerful components are like supermarkets that carry different sandwich ingredients, as a result when you want a sandwich on an intel machine you'll have to drive all over town because one store will have the turkey, another store will have the cheese, yet another store will have the mayonnaise. Each store might be really good at its own process and have the best Ingredients, but each store also takes a lot of power to run losing out on efficiency. And since all you really want is just to make a simple sandwich you're wasting a ton of time and energy picking up the ingredients from all the different stores. Of course, some might say the drawback with the System on Chip (SOC) design is that at least for now with the current selection of Apple Macs, you won't be able to upgrade or change any of the components, you get what's on the menu and that's it!! But that's not news to most people, that are familiar with the Apple Ecosystem. Once you accept that idea, you might even see the benefits of having a more efficient design where all the components are on one chip and they outweigh the cons and still provide better performance than the alternative.

Performance Benchmarking

All right that's enough talk about food!! So how does this all affect real-world development workflows, so doing a bunch of developer-focused tests on the latest Apple Silicon Machines, as well as comparing them to other machines like the Intel Macs and PC machines too and in general, the new design has been showing really great promise for my own workflows as a developer. Now there are lots of technology stacks that developers use of course, and I'm trying builds in a few of them. But now let me share some of the results I've seen with node and javascript tests and after that, I'll also discuss the tech stacks that have the biggest gains on the new machines and also the stacks that have the biggest losses right now at the moment. I started off trying out some existing javascript tests, that are in the browser and then in node. The browser test consisted of running a speedometer which is a browser benchmark, that measures the responsiveness of web Applicationsapplications. It uses demo web apps to simulate their actions, such as adding to-do items you visit the app in a browser of choice. I tried chrome and safari for this and you execute the automated test, that runs through a collection of applications built with some of the more popular UI frameworks. Like Angular, React, Amber even vanilla JS and Jquery and a whole bunch more, and then this test reports the results as a single number. When it's done this number represents the runs per minute, and the higher the better. When it was finished, I found that it had significantly more iterations on the M1 Safari. The best results even going off the scale, and chrome did pretty well too. I also ran some javascript benchmarks in a node environment and found a pretty CPU-intensive algorithm called Fancuuch Redux, that's implemented in Javascript and created for benchmarks game. A website that collects algorithms and tests in different languages and while my 16-inch Macbook Pro with the Intel Core i9 Processor did beat the Macbook Air, with the M1 chip it really didn't do so. When you consider the price differences between the machines, the fact that the M1 stayed cool throughout the test, and that the battery hardly even took a hit on the M1. You might be thinking whether the extra few seconds saved while running this benchmark on the intel i9 is really worth the money. So running benchmarks is often very telling, but it doesn't necessarily line up with real-world scenarios. So that's why I also like to conduct my own tests, whether using my own projects or other open-source projects that are out there and that commenters sent to me. I ran a build of the official native script plugins repository, which is a project based on NX workspaces. If you're not familiar with NX workspaces it allows you to scale large javascript and other tech stack projects. In the test, the build that was based and took about three minutes on each machine, only differed in build time by tens of seconds. With the M1 Macbook Air beating out the Intel Macbook Pro two out of three times.

Best/Worst Dev Stacks for M1

So let's talk about what dev stacks benefit the most from, the new Apple Silicon Chips at this time. For javascript developers, the benefits are already visible however, if you're building mobile apps for IOs for compiling C++ code then this is where you'll see a 40 to 50 percent improvement in build times. I ran a few Xcode builds and Swift builds and I did some C++ algorithms and built OpenCV and WebKit, in all those tests the M1 came out on top. So what dev stacks benefit the least? So far in my own testing, any builds that have to do with running natively built software and building using native tooling have absolutely destroyed Intel and speed and battery performance. Native being compiled for the Apple Silicon architecture, even when running some software via Apple's Rosetta, that's the translation layer that allows you to run Intel and AMD based AMD-based x64 and x86 programs on the new Apple Hardware. Even some of those software packages ran better than on Intel and that's just amazing, but some workflows aren't ready yet in my opinion. If you are an android developer, android studio and official android emulators work on Apple Silicon, but they're currently using Rosetta for Translations. While Rosetta is generally pretty good at running x86 targeted code on arm chips it's not enough for the CPU-hungry android workflows. I found the results to be not very usable at the moment the latest version of .net which is version 5, right now isn't fully supported to run on an arm simple console. Applications ran just fine for me, but testing any web workflows like asp.net core doesn't work at all.

Summing it Up

Now it's expected that by the end of this year .net Six will come out. It's in alpha right now and we'll have full support for the arm. Until then if you need to develop.net apps I suggest using a PC with Windows and if you think you can use a virtual windows machine. I've tested this as well, Parallels is the only vendor that currently supports the M1 chip to create a virtual Windows environment. But the issue is that the windows guest operating system for the arm is still quite immature and needs a lot of work also Visual Studio 2019, the latest visual studio offering from Microsoft is unfortunately not compatible with the arm at all. My test is not stable even using the built-in windows Translation of x64 software to run on arm hardware for game developers that use unity. I'm pleased to say that it works surprisingly well on Apple Silicon via Rosetta, however, it's not as performant as running natively on x86. Overall Apple Silicon has really put a boost into many workflows for developers and other professions and eventually even gaming. With the M1 tests, we're seeing the improvements with just their entry-level machines the upcoming 2nd and 3rd generation Apple Silicon machines will be even more performant. I think it's really gonna help us as developers move to the next level and think it's just gonna lift up the entire industry to follow the updates on the New Apple Silicon Chips as they relate to us developers.

0 Comments