by CraigJPerry · 4y ago · 0 comments
If i run android emulator (consuming 4-6Gb) + iPhone simulator (1-2Gb) + react native hot reload toolchain (1-4gb) + vscode (1-2gb) + firefox (1-3gb) all concurrently, then my memory pressure is around 65%, i have about 3gb swapped but very little paging activity.
Everything feels snappy.
What is this magic? I was convinced it would be the speedy SSD masking the page faults but there’s very little swapping going on.
Quite taken with it tbh. Still think MacOS is crap overall though. Soon as linux is viable on M1 as a daily driver, i am checking out of macos.
A few years ago I was trying to reproduce a memory issue in a C++ app by sending it a ton of the same thing over and over again.. on my OS X laptop I couldn't reproduce the problem at all, until I had it send random data.
If you open "Activity Monitor" and look at the memory tab, it will show you a value for "Compressed"
see https://appleinsider.com/articles/13/06/13/compressed-memory... or similar for more info.
[this is technically true on the Mac, but your Mac app isn't going to get jetsam'd like your iOS app will]
Further the pages themselves (for a large allocation) don't all get touched when freed so the kernel can skip decompressing them.
Measure the behavior of your application. Most of the time freeing cached values is the correct response to memory pressure, or use things like NSCache that handle it for you.
You honestly shouldn't use NSCache as nobody understands what it does, or tests its eviction behavior, and what it actually does - evict everything under memory pressure - is probably the time you want your cache to work.
I can imagine destructors in most languages involving touching the memory, just curious if a free syscall alone does it or not.
It's better to free things as you go rather than wait for warnings.
Also, there is a matter of the compression algorithm selection. With modern kernel using anything but lz4 or zstd is rather suboptimal.
But then again I have Samsung 980 PRO SSD in my laptop and with it I just disabled memory compression and use the real swap. The read speed is like 2 times faster then lz4 decompression and while the write speed is like 3 times less than lz4, it does not tax CPU which is a big bonus when I compile a big C++ project that does occasionally triggers the need for SWAP even with 32 GB of RAM.
https://www.anandtech.com/show/17024/apple-m1-max-performanc...
This is in no way exclusive to Apple.
I suspect your setup isn't using hw acceleration for video decode.
Where did you get your 150mW figure from?
Perhaps not, but on most Intel laptops (especially those with comparable form factors to an air or pro), you're probably at least going to have a fan spinning up playing 4k60 content.
I’ll test and check back soon.
I am considering buying a 24” iMac now as well.
This is a weird position to hold. You just argued why macOS does some fundamental things (at least memory management) really well.
diskpart and diskmgmt.msc are fine, but gparted does nearly anything feasible, it’s indispensable.
Then you just run ‘mount’ and ‘df -h’ a lot and in the end that’s similar to ‘net use’ on Windows + My Computer wrapped into one.
“Everything is a file” is a useful paradigm, and then just think of your disk as an image file in a fixed spot.
Sorry if this winds up a ramble or you’re well aware.
Even if you dont like the macOS GUI, I dont think any reasonable evaluation could call macOS 'crap overall'.
Distros like Ubuntu, are excellent, but they just dont have feature parity with macOS.
Would it not depend on the workload? I hear a lot of web developers and content creators who share this sentiment; fair enough. But there's a number of consumer markets who would indeed drag MacOS for lacking 32-bit support, decent container compatibility or a package manager. It's overall less compatible with software than Windows or even Linux, and if you want to do development outside of the Apple ecosystem or besides the web, getting a proper development environment up and running is an exercise on the treadmill of neverending maintenance. It certainly doesn't look appealing to a gaming crowd or people writing software for Windows (with M1 cross-compiling is dead in the water), it can't do Boot Camp anymore and it's a nightmare for DevOps folks who want to run Docker tests on their laptop.
I can understand who likes MacOS and why they'd like it, but if you do anything other than text editing or media encoding for a living then the benefits of using MacOS start to deteriorate very quickly.
- ram compression (fast CPU helps that this is non-noticeable)
- aggressive swapping on a fast SSD (you'll notice that macOS swaps unused pages even if there is ram left to make space for file caches)
- the M1 is just very fast, especially ram, so it's snappy overall
“Apple Silicon” is very highly optimized for strict reference counting (instead of garbage collection). The retain/release performance is just off-the-wall — even in Rosetta. Details here: https://blog.metaobject.com/2020/11/m1-memory-and-performanc...
Anecdotally, I spent most of last year in Docker, XCode and Node on an 8gb Air, smoove sailing
And regardless of that, the instructions speed the atomic operations required when updating references in a mulithreaded environment. It's lowering active CPU use. They're not going to do anything to reduce the impact of a mostly idle application in the background on the rest of the system.
The reference counting mechanism itself does mean you don't have to walk memory as much to do garbage collection, which risks pulling rarely used memory back in from swap. But that was true on the Intel Macs, too.
HN is such a useful community for finding little tidbits of brain candy like this.
There's also this informative comment [1] from the post author (Marcel Weiher) explaining some details:
"This doesn't use less RAM, it decreases the performance cost of using the more frugal RC."
It's kind of crazy how well 8GB does. On a PC when you have all the pre-installed crapware +++ 8GB is really too low these days.
To be fair, I'm doing DS on this so end up dealing with really large in-memory datasets, so I hit this relatively often.
If swapping just means moving large contiguous pages that are completely inactive, it's a bunch of writes which neither slows hot memory access nor the ssd.
If, on the other hand, you're swapping out pages that frequently need to be re-read, that's another story.
So if swapping works well, that's to some degree a sign that your software has bloated "dead" memory regions.
If you want a quiet device with low battery consumption and don't care about performance you can downclock/disable turbo boost and get that on other devices, with better Linux support.
Considering what the Asahi team has been doing so far and their reports I'm positive the CPU isn't a problem (since it's ARM). If they can get decent GPU performance (power consumption mostly) I'll be all over them.
My hopeless optimism, and the fact I don't consider Apple "magic".
Now I'm on a 64GB M1 Max and things are super snappy again. (Monterey on the other hand is buggy as hell, simple things like tap to click and pinch to zoom are broken. [1])
[1] https://forums.macrumors.com/threads/tap-to-click-issues-on-...
You can tell Apple has been optimizing a web browser on their own silicon for a long time.
And you were doing so well! ;-)
WRT M1 hardware, thats my experience too!
I picked up an M1 Mac mini 8/256 on the Apple Refurb Store as a stop gap machine whilst I waited for the Pro laptops. I ended up waiting a long time!
But it was amazing. The 256GB drive was a bit tight, and fills up a little too quickly. But overall, it was the best computer I'd ever owned!
In the early days I had USB related kernel panics, but later macOS updates seemed to fix all that!
I replaced it with a 16" M1 Pro 16/1TB, and the Mac mini is now working out it's (hopefully) long life in my server cabinet!
But the mind-blowing part is the CPU where on some tasks I can get desktop-i9-like level of performance.
I daily drive 3 Linux devices and 2 macOS. macOS isn’t close to crap. It’s better than Linux in some contexts and worse in others. Overall about par.
I think Windows is crap and yet it has billions (!) of users.
Yes desktop Linux is probably better these days for casual users of many degrees, but those users should probably be using ChromeOS (disregarding privacy questions, only UX) whereas the Linux desktop gives you the choices of boatloads of desktop environments and configurability. There's a reason Windows is the most used "computer operating system" (disregard android and ios).
I'm very happy on Linux myself just to be clear, but there are reasons why we're just a few percent of the market, and using free as in Libre and gratis software mostly.
If I could get an M1 working as well with Ubuntu I'd switch in a second (currently on a Thinkpad).
So the amazing memory management you love so much is likely part of the crap os you don't.
> Soon as linux is viable on M1 as a daily driver, i am checking out of macos.
Might as well check out of the apple ecosystem and save yourself some money while you're at it. AMD is supposedly releasing an Arm SoC and theyre also working on one with Samsung (likely mobile). Whether either of them are Laptop/desktop ready or comparable to the M1 is unknown (unlikely competitive without a comparable software ecosystem).