I know right now it's all anecdata but I noticed this as well! My 2020 M1 Mac's battery life has significantly decreased as well, to the point where I need to charge twice a day like I used to for the old Intel Mac's.
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.
Wow, that's a lot of cycles! Mine is 11 months old and has 46. I use it mostly plugged in with a second monitor, but I just recently took a trip and never charged it, even though I wrote 2/3 of a new app in Xcode.
Haha yeah! It's nice to see that other's machines are fairing up well. I'm a student so my machine gets a fair bit of wear and tear and theres just not much I can do about that unfortunately.
Ah, that's terrible. They just took away my Lenovo laptop with Linux to set me up with a 'platformed' Intel MacBook Pro, and CrowdStrike is eating CPU all the time.
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.
Parallels running ARM Windows (and Linux obvs) is now very good. And if it is Windows you're using, then Microsoft announced (last week?) that it is now a supported platform.
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.
IT sent out a bunch of emails asking us to all set up crowdstrike. I decided to ignore them and see if their threat of checking up on it was fake. 6 months later and nothing. Glad I avoided this rubbish.
I was having similar battery life on my 2020 Intel MBP, and I found turning off the "Manage battery longevity (As your battery ages, maximum capacity is reduced to extend battery lifespan.)" setting improved battery life by an additional few hours.
Your work is skimping on the battery. My work machine (a Precision 7550) easily runs all work day on battery, even with horrible battery hogs like Microsoft Teams running.
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.
Depends on what apps he's running. I suspect Xcode is pretty optimized (but buggy as all git-go -I should know. I use it all day), but Slack and VSCode are electron apps, and Electron is notorious for eating power.
I'll take your word for it. Most of my time is spent on a tethered machine.
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.
I wonder if it depends on the codebase in question. I've not had too much trouble with Xcode being power hungry on moderately-sized codebases that are entirely or almost entirely idiomatic Swift with Swift Package Manager handling dependencies.
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 spend most of my day in Xcode and the only time I see this is when there's a pane with a file open that has contents that makes SourceKit choke. As noted in on of my other comments, in my experience this is usually caused by code smells like deeply nested blocks, really long optional chains, or lots of casting. SwiftUI can also do it with more complex views, which is one of the reasons I've been sticking to UIKit.
I'm moving to a Mac Mini and an iPad Pro. More expensive? Maybe. I just don't need to carry around an extra keyboard, screen, and battery that could go bad. Tablets are so good these days that laptops make little sense IMO.
There's also the powermetrics command line tool. It shows much more than activity monitor. If activity monitor doesn't give you what you need, try it. man powermetrics.
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.
JetBrains Rider is a cross-platform .NET IDE based on the IntelliJ platform and ReSharper.
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.
I use Rider daily on an M1 and easily get through the day. I'm not compiling every second, but using it pretty consistently along with slack/chrome/etc.
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.
> Any good alternatives for C#, or anyway to make VS Code less draining
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.
It’s not for everybody, but choose a good text editor with syntax features, read documentation and related code, use a lightweight build system, and write without an IDE. It’s really not that difficult, is transferable to any framework or language, and forces you to learn APIs and code bases.
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.
VsCode extensions contribute significantly to battery drain as well. The more extensions you have running, coupled with a larger codebase, the more compute needed to reindex for autocompletion, warnings etc.
Is it just me, or is VSCode kind of confusing on how exactly everything works/integrates? When I've tried using it for Python work, getting it to use the right venv/binary seemed difficult and it has all these add-ons that I don't know where they're installed or fetched from.
I feel old. I just want highlighting and intellisense to work.
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.
Right, in this particular case it looks like a VSCode extension gonna wild since the battery dropped in constant pace which is an indication of constant load and the system reports VSCode dominance in energy use.
I develop in Python with (neo)vim and pyright as LSP client. Pyright often has regressions where it will consume 100% of one core for about a minute after every key press. The bug usually goes away with the next update... to reappear a few weeks later.
Editors are pretty efficient, linters on the other hand not so much.
Was thinking the same… although Vim plugins are a crapshoot regarding efficiency. Seems like sometimes there’s just no winning move: either you have nice tools and no battery life, or long battery life but subpar tooling.
My M1 MBP hasn't been able to last over 4 hours since I got it... but for work I have to use Slack and Teams.
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.
Mine gave me 10 hours easy. With electron slack and other apps. The trick is to kill all Intel apps which you can filter out. Once I do that it just keeps running and remains cold.
Any chance your IT/Infosec team has software running on your work machine? I've seen times when security software will chew up CPU when the machine is idle.
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).
There's a ton of that sort of software, but with the upgrade to Ventura they dropped a whole range of them and really pared it down. Much of that stuff doesn't take up a whole lot of CPU anymore.
My anecdata: M1 MacBook Air, and I haven't noticed such a drastic difference in battery life in a day in Xcode vs. a day in Visual Studio Code. However, I run a very lean install of VS Code, plugin-wise, which certainly helps.
Overall I've found myself impressed with VS Code's efficiency and performance as an Electron app, especially versus Discord (gross) or Teams (awful).
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.
Seems Electron for the win. I think upgrading to M2 MBP will help a bit until M3 pro is out. Lets be honest M1 MBP is dinosaur when it comes to modern dev tools like Slack or VSCode etc.
And that is why developers should shun Electron apps. The fact that every developer uses them is shameful. We should have more self respect to not use memory hogs and inefficient programs.
My work machine is an M1 Pro, and there are days where I forget to plug it in and I still have maybe 33% capacity left at the end of the day.
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.
I got a 2021 M1 MacBook Pro a few months ago. Battery life is better than on my previous 2012 MacBook Pro, but not as good as I'd expected. I don't do anything heavy on the computer—browser, Discord (which I know is Electron), Excel, and ssh—and the M1's battery only lasts for about six hours. Can using Chrome as the browser and not Safari make that much of a difference?
In my web dev work I use Chrome, Firefox, Safari, and Safari Tech Preview on a 2021 M1 MacBook Pro. My (anecdotal) experience is yes, Chrome eats M1 battery. This is true for Chromium as well, so Electron apps eat battery too. Some people have found significant battery life savings from avoiding Rosetta; maybe check if your Excel is running native Apple silicon or through Rosetta (iirc they very recently updated Excel for Mac to run native).
My Excel is indeed running natively, but I did find via Activity Monitor two other leftover things that are Intel that I should either get rid of, or update. I doubt they're the cause of any significant battery drain compared to Chrome (actually Edge now, but I doubt it's any better given the Chromium base), and I have other Intel software without Apple Silicon alternative, but it was still a useful thing to do.
Yeah the culprit is largely VSCode and electron/chromium apps. This why I personally switched into native apps for my dev work. Currently using Sublime Text and as much as possible I use tools like a site specific browser tool, Unite 4 to lower reliance on electron apps. Also I don't always have build systems on especially Docker and similar VMs
91 comments
[ 0.18 ms ] story [ 129 ms ] threadAlthough 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
https://mac.getutm.app/
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.
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.
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.
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 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...
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.
Maybe I'm not thrashing it hard enough.
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.
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.
I feel old. I just want highlighting and intellisense to work.
Yes they are. But why can my crappy work laptop with an i7-1185 do it then?
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.
Because this sounds like constant 100% CPU usage on at least one core.
Editors are pretty efficient, linters on the other hand not so much.
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).
Overall I've found myself impressed with VS Code's efficiency and performance as an Electron app, especially versus Discord (gross) or Teams (awful).
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.
That's amazing that you would come to this conclusion, rather than the tools are atrocious.
Docker will sabotage performance and battery life.
The worst are x86 processes. Make sure to have only ARM processes.
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.