How macOS manages M1 CPU cores
eclecticlight.co
eclecticlight.co
This is actually not correct. If you decompress something with Archive Utility, you'll see that it does spend some time on all the cores, although it's definitely not using them equally. It's just that it doesn't spend very much time on them, because it does not parallelize tasks very well, so most of the time it will be effectively running on 1-2 threads with the other cores idle, which macOS will split over the efficiency cores and perhaps bring in one of the P-core clusters if it likes. For the very limited portions of the process that Archive Utility is actually computationally bottlenecked, AppleFSCompression will farm out the work to all the cores. When writing unxip (https://github.com/saagarjha/unxip) I found that you will actually lose to Archive Utility if you don't use all the cores at least part of the way.
> There are two situations in which code appears to run exclusively on a single P core, though: during the boot process, before the kernel initialises and runs the other cores, code runs on just a single active P core.
I'm not 100% sure on this, but I believe the processor comes out of reset on an Icestorm core?
For plain old zip this is excusable since it comes from the 80s, but for modern compression utilities they really should do better.
Which is really unfortunate, because bzip2 is not a very good compressor otherwise. It outperforms gzip on compression ratio, but is beat out by anything modern, and is extremely slow, even when parallelized.
A lot of modern compressors can be made parallelizable (and, as a bonus seekable!) by breaking the input/output into chunks and compressing each chunk independently. This loses a bit of compression efficiency, but surprisingly little for sufficiently large blocks.
(This isn't what pigz does, by the way. pigz keeps state between each compressed block, which prevents parallel decoding.)
> For plain old zip this is excusable
Do you mean gzip? PKZIP decompression is actually somewhat parallelizable, because each file is compressed independently of the other files in the archive -- I'm not sure anyone actually does this, though.
What you can't do is decompress a single archive member in parallel.
That's odd. Zip and Rar, at least, have indexes that point to individual files in the archive and it should be trivial to decompress files in a thread pool with as many cores you want. That's not as easy when you have a tar.bz or tar.gz2 file because you only see files as the .tar file is extracted.
[1]: Benchmarks available at http://facebook.github.io/zstd/#benchmarks
Source (https://1014.org/?article=854)
This explains Justin Frankel's observations in the article above. It's a bit annoying there seems to be no way to force a process to only run on the P cores with no throttling. Having mostly bought a M1 Mac for music production, I keep running into this exact issue. Light workloads invoke more processing glitches than running loads of tracks and plugins at the same time.
Hopefully developers will eventually get more granular control of this for high-performance apps, battery life be damned.
I'm not sure about the throttling side of things as I've mostly worked with M1 Mac Mini, but Logic Pro has CPU thread settings to limit things to just P cores. My guess is that it will take time for other DAW's to implement similar features.
Can't say I've had many issues performance wise in Logic, but I've had some crashing with newer plugins like Korg's recent plugin version of the OP-Six. Especially when memory use ramps up. Reported my findings back to Korg's tech support, but no solutions yet.
I run Ableton, FL, Pro Tools and Logic (mainly working in Ableton) and my goal is to record at 48k with a buffer length of 32 samples, with very light use of plugins. In my testing with the exact same plugins, Logic would consistently have buffer overflows every minute or so.
Ableton ran far more stable (especially in Rosetta), but PT was the only DAW to do it without hiccups. My initial guess is that the AAX plugin format is more tightly coupled to its internal processing, improving performance. But I was quite shocked to find out that Logic (Apple's own software) performed the worst.
Plugin development in general is a shitshow where most devs seemingly only do enough to get them barely working, so I'm not surprised most of them misbehave on ARM. It's a bit sad that we're two years into the Apple Silicon transition and performance still is so rocky.
Ableton, while it is my main daw and by far my favorite, is pretty CPU heavy as of Version 11.(10 was not quite as bad) The others are more or less similar in performance in terms of track count and latency. Ableton is completely usable but I usually start having to freeze tracks as the track count hits ~24ish depending on what plugins Im using.
With Logic, I can usually get closer to 2x that amount, but I should probably do a more apples to apples comparison.
I do have my eyes on the Mac Studio as my next Audio computer, but Im hoping to stretch my iMac Pros lifespan closer to the 10 year mark if I can...
More complexity = more room for errors especially on a new cpu architecture.
corrscope is a PyQt app with a background thread which streams video frames to a ffplay process, which shows these frames in a video player window along with synchronized audio. During playback, ffplay is focused and corrscope lies in the background generating video frames.
> On M1 processors, if you open preview, after 40 or so seconds, the preview may suddenly slow down and audio will stop playing. This is because macOS thinks ffplay is the active app, and Corrscope is a background job burning CPU, so it moves Corrscope to an Efficiency core, slowing it down.
> There is no fix for this issue at the moment. As a workaround, you can click on Corrscope's window to avoid the slowdown, and drag it aside so it doesn't obstruct the preview.
Setting the background worker thread to QOS_CLASS_USER_INTERACTIVE does not prevent it from being moved to E-cores. This is a rather severe issue which damages the user experience, and I haven't found a workaround yet (outside of moving video playback in-process). How do Chrome and Firefox (and Safari I suppose) give their worker processes P-cores while users are interacting with the browser window process?
How would I opt a program out of App Nap? Should I trust https://pypi.org/project/appnope/?
// Call NSProcessInfo to disable AppNap et al.
NSActivityOptions activityOptions =
NSActivityIdleDisplaySleepDisabled |
NSActivityIdleSystemSleepDisabled |
NSActivityLatencyCritical;
NSProcessInfo* procInfo = [NSProcessInfo processInfo];
m_NoSleepActivity = [procInfo beginActivityWithOptions:activityOptions reason:@"Running some stuff"];Generally if a UI process makes IPC calls out to a daemon or other process, the Mach kernel is supposed to keep track of prioritization and an on-behalf-of relationship for the daemon. That is, if the kernel already thinks the foreground app is P-core eligible, any work it initiates in other processes via IPC should be P-core eligible as well, through a “voucher” object that is passed between processes: https://opensource.apple.com/source/xnu/xnu-3789.41.3/osfmk/...
I’m not sure the mechanism you’re using to put video playback out-of-process, but if there’s any IPC calls involved, make sure they’re originating from a UI task, and not the other way around? Hopefully this gives you something to go on.
This seems weird or wrong. Given that M1 Ultra are two M1 Max bolted together (apparently in a way that is somewhat unconventional, but in effect neat) I don't see how that would be done in hardware or even why the authors would want to it work like that (it is my understanding that the whole reason for clusters is that whole cluster has same clock, which is somewhat hard and pointless to do when half of it resides on different die).
Maybe it is only an software abstraction and in HW there are two 2xIcestorm clusters?
Most likely some unsolved priority inversion bug doing that. Linux actually bumps up the priority of "nice" tasks when something else is waiting on them, which goes a long way to address this issue.
Additionally I wonder why Apple chose to change the number of efficiency cores between M1 and M1-P, M1-M and M1-U?
Technology like Thread Director is simply not ready on Linux yet. Period. You're not going to get intelligent process management a-la M1 or MacOS quite yet, mostly because Intel hasn't quite finished rolling out Alder Lake to the server market. It'll take some time, but I fully expect us to get there.
The flip side of that coin, however, is that the core management is already quite good. Intel had previously merged some basic code for managing heterogeneous systems during the Rocket Lake rollout (iirc), and it does a pretty good job of keeping you on the E-cores most of the time. As far as I can tell, it's original intention was to get the kernel to run processes on lower-binned cores until it needed to turbo, at which point it would heavily prioritize the faster ones. This helped distribute the workload and save some power, but it also came in clutch for Linux users with Alder Lake. So long as the same code works on ARM, I can image the situation will be quite good. Most people would probably never notice the difference.
Only M1 Ultra seems to be comparable to the 12900k so that's not completely fair. It still seems to be ~2-3 times more power efficient though.
Also if you ever owned a top end Intel MBP you'll know how much pain Intel can inflict on you.
I never really got this arguement, especially when you're talking about a laptop that will happily draw 40w+ if you crank the display brightness. Arguing about the merits of a 7w CPU vs a 15w one sounds like people are missing the forest for the trees.
Edit: was your 40W for total power consumption? If so, then going from 20W cpu to 10W cpu is still a 25% energy consumption reduction (as well as a cooler lap and better battery life).
Responsible use of energy directly leads to higher performance. You can also restate this: software is a performance bottleneck in a modern CPU.
https://www.xda-developers.com/intel-13th-gen-raptor-lake/#i...
I have a separate heating system for my house thank you very much :)
Yea, but unlike the M1 series, you probably have a big hunk of copper on top of your CPU. It really isn't a fair comparison. Intel needs a miracle. Actually, we all need a miracle, because Apple just changed the whole industry and I really hope they get some competition.
[Wish HN would let me edit for longer.]