9 ms·
Counting cycles and instructions on the Apple M1 processor
- liaukovv 6y agoWould be nice to see similar test run on intel and amd processors
- mhh__ 6y agoIntel and AMD both document their performance counters extensively (unlike Apple) so if you have Linux installed you should be good to go to do it yourself.
- liaukovv 6y agoI sure would be if my intel processor wasnt 6 generations old
- mhh__ 6y agoMy Intel atom netbook from 2009 has some PMCs, so worth a try
- liaukovv 6y agoI meant more that its a bit pointless to compare 2020 apple processor to 2014 intel processor without knowing what 2020 intel processor can do
- mhh__ 6y agoLook into intel Devcloud. Basically you get about six months of free cloud jobs to play with, with the microarchitectural counters enables.
- genmud 6y agoI was skeptical about the m1 processors, specifically around performance on something like a desktop where you expect snappy performance. I have definitely changed my thoughts and if apple can solve getting more ram in their systems (it’s pretty shameful that in 2021 you max out at 16gb on a MacBook Pro), I feel like they are going to knock it out of the park with their new architecture.
- dylan604 6y agoIt wasn't until 2017ish before getting 32GB in a MacBook Pro. So the fact that they have 16GB in the first gen seems about right. According to Apple's propaganda and blogospere, the M1 is much more efficient not "needing" the extra RAM. That's just too much for my old dog to wrap my mind around.
- cyberpunk 6y agoI’m using one as a daily driver (red teaming) and it easily handles a couple busy vms, term, few services, editor, obsidian, slack/teams/whatever and browser.. I stopped even bothering carrying the charger with it.. Sometimes I look at activity monitor and it is swapping a bit but I don’t notice any perf degradation so I stopped thinking about it.. shrug
- genmud 6y agoI'm sure that swapping isn't a huge deal, but the big issue is around longevity of the SSD. If you have workloads that use more than 16gb of ram, swapping a lot will prematurely wear the SSD, which isn't replaceable.
- cyberpunk 6y agoI think this has been largely debunked by now, early SSDs had these problems but newer ones? not so much..; I mean, here's what smart says about the drive in my Mac atm: Percentage Used: 0% Data Units Read: 12,515,207 [6.40 TB] Data Units Written: 13,202,995 [6.75 TB] Host Read Commands: 264,092,805 Host Write Commands: 158,635,815 Controller Busy Time: 0 Power Cycles: 188 Power On Hours: 223 The % used is (I think) the lost capacity due to wear, I've fairly hammered it so far and it's not even at 1%.. I'm pretty sure I'll get at least a few years out of it based on that..
- mnadkvlb 6y agoCould anyone explain the instructions/float metric ? Just tried running the same code on an M1 Air from blog, and i get quite different number of instructions/float, whereas the instructions/cycle are pretty close: # parsing random numbers model: generate random numbers uniformly in the interval [0.000000,1.000000] volume: 10000 floats volume = 0.0762939 MB strtod 376.04 instructions/float (+/- 0.0 %) 75.53 cycles/float (+/- 0.0 %) 4.98 instructions/cycle 88.95 branches/float (+/- 0.0 %) 0.6005 mis. branches/float fastfloat 162.01 instructions/float (+/- 0.0 %) 22.01 cycles/float (+/- 0.0 %) 7.36 instructions/cycle 38.00 branches/float (+/- 0.0 %) 0.0001 mis. branches/float
- liaukovv 6y agoI assume thats how many instructions it takes to parse one float?
- mnadkvlb 6y agothanks a lot, yea it makes sense. Edit: it seems weird when i think that on the blog it takes 490 instructions whereas in my case it takes 360. That is roughly 26% less instructions required than on blog. Instructions per cycle are more or less same on both results, telling me that my M1 Air is somehow using less instructions to run the same code (or is faster)
- tubbyjr 6y agoI have not bought an Apple product... evar But I said I would get the first production-ready ARM Laptop chip... It had to be an Apple, here I am writing this on an M1 Laptop now (to my credit I am trying to minimize as much of the home phoning via various means, albeit I understand I'm using complete spyware). ARM/RISC is the future.
- Angostura 6y ago> I understand I'm using complete spyware What makes you say that? There is relatively little phoning home in MacOS
- jolmg 6y agoI don't really follow Apple news, but I do remember this: https://sneak.berlin/20201112/your-computer-isnt-yours/ https://sneak.berlin/20201112/your-computer-isnt-yours/ > On modern versions of macOS, you simply can’t power on your computer, launch a text editor or eBook reader, and write or read, without a log of your activity being transmitted and stored. > It turns out that in the current version of the macOS, the OS sends to Apple a hash (unique identifier) of each and every program you run, when you run it. Lots of people didn’t realize this, because it’s silent and invisible and it fails instantly and gracefully when you’re offline, but today the server got really slow and it didn’t hit the fail-fast code path, and everyone’s apps failed to open if they were connected to the internet. > Because it does this using the internet, the server sees your IP, of course, and knows what time the request came in. An IP address allows for coarse, city-level and ISP-level geolocation... > Apple (or anyone else) can, of course, calculate these hashes for common programs: everything in the App Store, the Creative Cloud, Tor Browser, cracking or reverse engineering tools, whatever. > This means that Apple knows when you’re at home. When you’re at work. What apps you open there, and how often. They know when you open Premiere over at a friend’s house on their Wi-Fi, and they know when you open Tor Browser in a hotel on a trip to another city.
- astrange 6y agoThis post is factually incorrect, it does not send a hash of the application (instead an identifier that can be shared across apps) and the server doesn't save any logs.
- dougall 6y agoGreat post - glad some of that code has been useful! If it's of interest, these performance events (and the whitelist for this API), are described by Apple at https://github.com/apple/darwin-xnu/blob/main/osfmk/arm64/kpc.c https://github.com/apple/darwin-xnu/blob/main/osfmk/arm64/kp... Instruments.app is the official way to access performance counters. I believe it can use a few more (non-whitelisted) events, which are described in /usr/share/kpep/a14.plist - I couldn't figure out how to hijack the single-consumer API that I think it's using. (Edit: it seems it just shows non-whitelisted events in the GUI, but doesn't let me use them.) (And, for my own measurements, I use a kernel module to bypass the whitelist, which is even more likely to blow up the computer, and definitely not recommended: https://github.com/dougallj/applecpu/tree/main/timer-hacks https://github.com/dougallj/applecpu/tree/main/timer-hacks )
- kragen 6y agoInteresting! Do you need Apple's permission to write a kernel module? Have you tried running this kind of instrumentation on Linux on M1?
- dougall 6y agoI don't really understand the kernel module process/policy - it was a lot of trying random things and seeing what worked. But I think you shouldn't need permission, as long as you're building it and running it on your own machine. But I do have an Apple developer account that costs money to let you develop on iOS, so that might have been a factor. You do need to disable some security features to run kernel modules. I'd rather be running this kind of instrumentation on Linux (or without a kernel, e.g. using m1n1), but I haven't set that up yet. (It'd be nice to lock the CPU to a frequency, and pin threads to cores, etc.)
- kragen 6y agoThank you!