M1 MBP down to 3.5hr battery life when writing code
twitter.com
twitter.com
On my 1 y/o M1 Air I consistently get over 10hrs mixed use. Coding itself is not compute intensive at all but someone is using some build systems, VMs. Docker etc. these things constantly compute stuff and as a result the battery is decimated.
The modern Dev environments are ridiculous, no matter what people say coding Swift on XCode is a breeze. Even if you do dynamic previews with SwiftUI and use simulators, it's still lighter than some web dev stuff.
Because this sounds like constant 100% CPU usage on at least one core.
VsCode + Docker on Mac + devcontainers (at my last job) make for an atrocious development experience. It was a major contributing factor when I left that job.
Maybe I'm not thrashing it hard enough.
I feel old. I just want highlighting and intellisense to work.
In the past 20 years I’ve used Vim to write PHP, Java, Bash, C, C++, Ruby, Perl, JavaScript, Objective-C, Swift, a proprietary S-expression language, and documents in LaTeX. This isn’t something I drop into occasionally, it’s my primary editor used along side compilers and interpreters. I’ve never once said, Vim doesn’t start fast enough or is taking too much memory (though I have caused it to hang based on my own dumb search or replace commands).
There are plenty of native text editors that work just as well. On the Mac I’ve had great experiences with BBEdit, TextMate, and SubEthaEdit. Other people like Sublime. There really is no shortage of great text editors.
Developers need to start treating electron apps like the plague. They are merely low effort attempts at cross platform tools written in the most user hostile way.
edit: https://github.com/OmniSharp exists, and is LSP-ish, but I have never used it.
It's been years since I've used Resharper and maybe things have changed, but if you are looking to improve battery life, it's one of the last things I would start using.
My work laptop is often at full ram usage (16mb) with the fans spinning at full speed.
I used to code in vim and sublime text. The change in system load is shocking. I like Rider and will continue to use it but it's crazy how much of a hog it is.
At least you've upgraded beyond 640k!
I've used VS Code, Rider, and even VS2022 via Parallels, and in the end I switched to VS Mac. It had been a year or so since I last really tried it and in that time it had gone native ARM (faster and less battery drain) and been much improved.
Unless I need legacy stuff or Windows-only dev, I now see no reason to use anything other than Visual Studio Mac on my M1 Air for C# development.
Yes they are. But why can my crappy work laptop with an i7-1185 do it then?
Please, if you use VSCode, use this bisect tool! Use this to bisect your extensions and figure out what's using too much CPU. I did this and it made a HUGE difference. Highly recommended.
If I am on a video call with Teams I am lucky if I get 1.5 hours out of a 100% filled battery, as the Teams "helper" sits at 190% CPU usage during the entire call.
Electron applications are wasting so much CPU time and power.
My personal M1 MBP that I got when it was first released still lasts over 10 hours. I code in VimR with Rust analyzer and compile Rust projects for hours on end. No issues.
Just, no Electron applications and stuff sips battery.
That said, my M1 has all sorts of gnarly IT/Infosec stuff running (banking industry) and even that doesn't seem to make a dent in my battery capacity (on top of using several Electron based apps all day long as well).
Although this could just be my fault as I've already racked up close to 600 cycles on a machine that has only gotten a year and a half's worth of use.
Everything not included in the system (I guess CrowdStrike is checking every executable all the time) super slow. Even doing 'exa -l --icons /' on the shell is sometimes even orders of magnitude slower than my Linux. Around 50ms in Linux, but around 300ms in macOS...
I thinking about setting up everything inside a virtual machine to see if CrowdStrike controls that. It might even be faster.
https://github.com/lima-vm/lima
I checked Virtualbox this week and it's also beta/testing for M1
I've used VS2022 (ARM version) with ARM Windows 11 on an 8GB M1 Air, and it's faster than my work 10th Gen i7.
Obviously if you use X86 and AMD64 stuff in that configuration it's running emulated by ARM Windows, but for most non-dev stuff I use native Mac versions anyway and Parallels gives me Windows 11 either full-screen or as seamless windowed apps. It's impressive.
I could see this being different for a project that's a mix of Swift, Objective-C, C++, etc though or has a lot of messier Swift code of the sort that makes SourceKit grumpy (deeply nested blocks, etc).
I also suspect that it depends on what is being done. I'll bet that some types of languages compile hot, while others, cool.
UPDATE: I just ran Xcode, doing my basic daily tasks (editing and building), using Activity Monitor, and it was pretty mild. It had a HUGE spike, as it started up, then dropped into single- and double-digits, after that.
Overall I've found myself impressed with VS Code's efficiency and performance as an Electron app, especially versus Discord (gross) or Teams (awful).
Editors are pretty efficient, linters on the other hand not so much.
I'm typically in VSCode, XCode, Slack, and Zoom, and have more Chrome tabs open than physics allows. Lots of software building, even the occasional AI image generating sessions, and the battery just keeps on keeping on.
Prior to this machine, my Intel MBP would have melted into a puddle after using its entire battery in 20 minutes.
Edit: I'm using VS Code as my IDE which seems to be the actual issue.
One thing to watch out for: Sometimes the audio driver starts busywaiting after you wake from suspend if you have been using bluetooth. You have to manually kill it in the task manager or it will drain your battery in an hour. You can tell when it happens because the laptop gets hot and the fan starts spinning even though you're not pushing it at all.
Docker will sabotage performance and battery life.
The worst are x86 processes. Make sure to have only ARM processes.
I bought an iPad Pro recently, so I can leave the 16" plugged in at the office.
I'm from the Android world, and that's one feature that -really- helps identify problems, instead of making an overly vague post like this.
Really surprised every platform doesn't have something like that by now...
That's amazing that you would come to this conclusion, rather than the tools are atrocious.