News for hackers. Stuff that matters.
Re:How I doubled the battery life on my Mac by closing one t... by vardump on Wednesday February 17, 2016 @09:06AM (#11117888)
I often do this with OS X Chrome:

  killall -9 -m "Chrome Helper"
It kills all Chrome tab renderers, but you can easily reload them where you left off. Ultimate battery saver.

Chrome seems to even remember textarea / input contents.

Edit: Not that I've ever had any issues with that simple killall, however the following might be safer, it tries to match the process path, name and "--renderer" command line parameter:

  pkill -9 -f "Google Chrome\.app/.*/MacOS/Google Chrome Helper .*--type=renderer"
Re:How I doubled the battery life on my Mac by closing one t... by lukifer on Wednesday February 17, 2016 @10:55AM (#11118649)
Thanks for the tip! I frequently prune task processes manually, and I didn't know that killing all helper processes was safe to do. :D
Re:How I doubled the battery life on my Mac by closing one t... by SeanDav on Wednesday February 17, 2016 @09:42AM (#11118100)
Is there a Windows equivalent process?
Re:How I doubled the battery life on my Mac by closing one t... by vardump on Wednesday February 17, 2016 @09:57AM (#11118217)
Well, this is a bit hackish, but I got this to work with a minute of effort:

wmic Path win32_process Where "CommandLine Like '%chrome.exe\" --type=renderer%'" Call Terminate

Tried it on Windows 10, latest Chrome. Ctrl-r didn't work on those killed tabs, had to click reload button. But other than that, the effect seemed to be same than on OS X.

Use at your own risk.

You can't use taskkill, because on Windows, all Chrome processes have the same file name, chrome.exe.

Edit:

This one should be a bit more reliable and safer. Note that it is not completely visible because of HN CSS:

  wmic Path win32_process Where "CommandLine Like '%--type=renderer%' and Name='chrome.exe'" Call Terminate
Re:How I doubled the battery life on my Mac by closing one t... by zimpenfish on Wednesday February 17, 2016 @08:59AM (#11117853)
I am quite happy with The Great Suspender for automatically suspending tabs - has a good range of options for tweaking.

https://chrome.google.com/webstore/detail/the-great-suspende...

Re:How I doubled the battery life on my Mac by closing one t... by srgseg on Wednesday February 17, 2016 @10:12AM (#11118306)
The OneTab extension can also be used to convert all your hoarded tabs into a list, saving you memory and CPU.

https://chrome.google.com/webstore/detail/onetab/chphlpgkkbo...

Re:How I doubled the battery life on my Mac by closing one t... by DamnInteresting on Wednesday February 17, 2016 @11:55AM (#11119202)
The Great Suspender is indeed great. I also like to use Session Buddy so I can preserve groups of hoarded tabs without actually having them open.

edit to add link: https://chrome.google.com/webstore/detail/session-buddy/edac...

Re:How I doubled the battery life on my Mac by closing one t... by dreen on Wednesday February 17, 2016 @09:24AM (#11117990)
One of the most useful extensions I have. Highly recommended.
Re:How I doubled the battery life on my Mac by closing one t... by mikeash on Wednesday February 17, 2016 @09:24AM (#11117989)
Maximum battery life depends on the CPU being idle most of the time. Running an app that constantly uses the CPU will greatly shorten battery life. A web page constantly running code will make the browser constantly use the CPU.

So... great? All true, but why is this on HN? This is the sort of tip which belongs in a "...For Dummies" book.

Re:How I doubled the battery life on my Mac by closing one t... by sophacles on Wednesday February 17, 2016 @10:42AM (#11118545)
So HN is a great community full of smart people. It attracts new people all the time. Further the larger tech community is a "young" field. As a result of both, there are people who are just learning this, or at a point in their personal growth that this stuff is just clicking or needing to be pointed out. It's OK - those folks need to learn too and articles like this are great for them.

Further software is a gigantic field. There is stuff that is basic to one person that is voodoo to someone else. This is usually bi-directional: things that are basic to you are voodoo to me, and things that are voodoo to you are basic to me. That's another reason this belongs here.

And if nothing else: I suspect there are many people, such as myself who know that some browser tab is responsible for my mbp being warm, or eating battery, but just put up with it for convenience reasons. Until today that is, when we learned about the chrome per-tab task manager tool.

Re:How I doubled the battery life on my Mac by closing one t... by mikeash on Wednesday February 17, 2016 @10:58AM (#11118682)
I'm sure there are some people reading this site for whom this is news, but that doesn't change my point. It's extremely basic information that's more appropriate elsewhere. I don't want the front page to be full of articles like "how to declare a variable" or "what even is a variable" or "how to plug in your monitor." I'm sure there are some people reading this site who don't know how to plug in a monitor, but that doesn't mean such a thing would belong here.
Re:How I doubled the battery life on my Mac by closing one t... by rquantz on Wednesday February 17, 2016 @11:13AM (#11118814)
All right you made your complaint. Now flag the article if you must and let it go, please.
Re:How I doubled the battery life on my Mac by closing one t... by losvedir on Wednesday February 17, 2016 @10:54AM (#11118641)
I didn't know about the Task Manager in Chrome. I've used Activity Monitor before to see that some tab was eating CPU, but I didn't know it was so easy to identify which tab. The article was worth the read to me for that tidbit alone.
Re:How I doubled the battery life on my Mac by closing one t... by mikeash on Wednesday February 17, 2016 @10:55AM (#11118654)
The solution is one Google away. "Which Chrome tab is eating CPU" and first hit.

I accept that this is valuable information, but HN is not really about obvious information that's easily searchable.

Re:How I doubled the battery life on my Mac by closing one t... by whiddershins on Wednesday February 17, 2016 @11:24AM (#11118913)
I dunno man, I'm pretty savvy in general but didn't know you could find process usage per tab in chrome.

I was hoping the top comment here would be interesting, like it would be about why exactly the currency conversion page is so processor intensive and how to make the same exact functionality without that problem.

But, no, it's a discussion about a discussion.

Re:How I doubled the battery life on my Mac by closing one t... by Aeolun on Wednesday February 17, 2016 @09:50AM (#11118165)
I think it is more that this particular tab was somehow responsible for eating half of his battery life. It's not particularly clear that that particular page would consume an an insane amount of CPU/Battery.
Re:How I doubled the battery life on my Mac by closing one t... by primozcigler on Wednesday February 17, 2016 @10:21AM (#11118380)
Exactly. The point is that even if you have 100 tabs open, maybe only 1 will eat 80% of CPU and other 99 will require the rest 20%.

My point was that you cannot simply see the things clearly from the Activity Monitor. And many people are not aware that the Task manager exists in Chrome.

Re:How I doubled the battery life on my Mac by closing one t... by mikeash on Wednesday February 17, 2016 @09:52AM (#11118184)
I'd hope it would be quite clear to this audience. Intensive tasks can eat far more than half your battery life. My MacBook Pro goes from 8+ hours of battery life to less than 2 if I run certain (not particularly fancy-looking) games, for example. The difference between idle consumption and maximum consumption is gigantic, which in turn implies that your battery life can be massively impacted by consistently going beyond idle.

Again, all true, but I don't understand why it's here.

Re:How I doubled the battery life on my Mac by closing one t... by primozcigler on Wednesday February 17, 2016 @10:24AM (#11118405)
Yes. But sometimes you will open up a website in a new tab. It won't be happening nothing special there, as least not visually. So you will assume it doesn't hurt performance/battery of your laptop.

But if the developer of that site left somewhere in JS something like while(true) {...} that page will drain your battery, even if you're not looking at that specific tab. And even if you are in other app than Chrome.

Re:How I doubled the battery life on my Mac by closing one t... by mikeash on Wednesday February 17, 2016 @10:59AM (#11118688)
Again, true. But why is that worth posting here? This is Computer Use 101 material. That doesn't mean it's not valuable to some people, but for this particular audience it's about as obvious as "water your plants if you want them to grow" would be on Farmer News.
Re:How I doubled the battery life on my Mac by closing one t... by heinrich5991 on Wednesday February 17, 2016 @11:09AM (#11118779)
I haven't connected battery life to opened tabs before. There, this link was worth something to me.
Re:How I doubled the battery life on my Mac by closing one t... by knodi123 on Wednesday February 17, 2016 @10:40AM (#11118522)
> if I run certain (not particularly fancy-looking) games, for example

I like to play FTL, and it makes my laptop sound like a vacuum cleaner, with a 1.5 hr battery life. And that's a freaking turn-based roguelike. But I can run an old SNES emulator for an hour and barely touch my battery.

Go figure.

Re:How I doubled the battery life on my Mac by closing one t... by logicrook on Wednesday February 17, 2016 @11:30AM (#11118963)
Although this is not great information, there are way worse submissions that make it to the front page.

The useful thing with this article is that it tell one cannot really estimate the battery usage of a user, even knowing much of his habits.

I think the reason is that HN readers (most people?) are great gobblers of "fun fact" information. Just look at how many random mostly useless trivia makes it to the front page...

Re:How I doubled the battery life on my Mac by closing one t... by ksk on Wednesday February 17, 2016 @11:11AM (#11118800)
>So... great? All true, but why is this on HN? This is the sort of tip which belongs in a "...For Dummies" book.

Because apparently the kind of people who spend the most amount of time idling/voting on tech websites and are newbies.

Re:How I doubled the battery life on my Mac by closing one t... by xlayn on Wednesday February 17, 2016 @10:19AM (#11118368)
Why the Mac reference? last time I check anything from my ipaq to my nokia maemo to my ROG laptop to my thinkpad to my arduino behave the same way: they drain more power the more work they do.

Which is all again related to summatory of work over time = power consumed, same for humans, for ICE and electric motors...

I'm starting to think there is some troll creating entries with apple products just for the sake of almost divine apple status.

Edit: yay downvotes because I don't respect Mac cult. Get over it; it's a Pc!

Re:How I doubled the battery life on my Mac by closing one t... by teh_klev on Wednesday February 17, 2016 @11:24AM (#11118905)
From the guidelines:

"Please resist commenting about being downvoted. It never does any good, and it makes boring reading."

https://news.ycombinator.com/newsguidelines.html

there's also a FAQ if you haven't read that either: https://news.ycombinator.com/newsfaq.html

That aside, I'm unclear why so you're riled up about mentioning their Mac in the title. If I were to write such an article I'd probably have written "How I doubled the battery life on my Dell XPS by literally closing one tab in Chrome".

Re:How I doubled the battery life on my Mac by closing one t... by xlayn on Wednesday February 17, 2016 @12:20PM (#11119409)
Hey thanks for the links. I'll stick to rules and avoid this situation on the future.
Re:How I doubled the battery life on my Mac by closing one t... by mikeash on Wednesday February 17, 2016 @10:23AM (#11118394)
Er, they mentioned the Mac because that's what they were using? It's a personal story of discovery. It's just weird here, because it's discovering something so basic.
Re:How I doubled the battery life on my Mac by closing one t... by xlayn on Wednesday February 17, 2016 @10:28AM (#11118441)
It doesn't add anything, a Mac is a pc, there is nothing special on it, it's related to something happening inside the browser, so for discovery sake he can post

I 100x increase my Mac battery by putting it to sleep.

This post is newbie in all senses. He could get a console over the webpage, check the javascript or offending logic and create a post like this:

Increase your users happiness (and battery life) by improving XYZ (e.g. polling behaviour) on your webpage. -Improving responsive design with battery life in mind

which identifies a problem and propose a solution.

Re:How I doubled the battery life on my Mac by closing one t... by primozcigler on Wednesday February 17, 2016 @11:33AM (#11118999)
I will do that probably within a day or two.
Re:How I doubled the battery life on my Mac by closing one t... by S_A_P on Wednesday February 17, 2016 @08:46AM (#11117770)
To add to the TLDR, its not Chrome's fault, but rather, a badly coded page that is using too much CPU.
Re:How I doubled the battery life on my Mac by closing one t... by Houshalter on Wednesday February 17, 2016 @09:41AM (#11118097)
I would say it is somewhat Chrome's fault, since tabs in the background should use less CPU. They also don't give users any control over resource usage, or notify them which tabs are using resources (except in that task manager thing which is hidden away, and not very reliable in my experience.)

Actually Chrome does slow down tabs in the background. On my computer whenever I put a CPU heavy tab in the background, it crawls to a snail's pace. And if you don't touch it in a long time, it is suspended and saved to the hard drive.

Which is why this story is weird. This shouldn't even be an issue.

Re:How I doubled the battery life on my Mac by closing one t... by Mithaldu on Wednesday February 17, 2016 @11:48AM (#11119142)
> tabs in the background should use less CPU

That is a naive view on it. Javascript can be doing a LOT of things. It could be rotating a product carousel; or it could be running a browser game. In both cases that's something that can use a LOT of CPU, but in the latter case the user might want it to continue processing in the background. How is the browser supposed to differentiate this on its own?

Re:How I doubled the battery life on my Mac by closing one t... by tluyben2 on Wednesday February 17, 2016 @10:39PM (#11123549)
But why can you not choose to either keep tabs you are not currently in focus with (so you are looking at another tab than the 50 others you have open) fully running, running at some max % or freeze completely? The latter just freezing the process which will require unfreeze but as it is a user choice it depends on their browser behavior.
Re:How I doubled the battery life on my Mac by closing one t... by Mithaldu on Wednesday February 17, 2016 @11:15PM (#11123683)
I was commenting on doing such automatically. (Hard to implement.)

Doing it manually would be great, but then you run into Chrome's obsession with remaining simple and "slim", regardless of whether this happens to the detriment of users.

Re:How I doubled the battery life on my Mac by closing one t... by Houshalter on Wednesday February 17, 2016 @06:50PM (#11122548)
Well that's how it works on my computer currently. If you put a browser game in the background it will slow down massively. If you want it to keep working, you need to move it to it's own window. Tabs that are in their own window keep running at full speed.
Re:How I doubled the battery life on my Mac by closing one t... by Mithaldu on Wednesday February 17, 2016 @11:16PM (#11123688)
Yep, it doesn't stop though. And it doesn't handle things differently for different use patterns. Since that would be hard to implement automatically.
Re:How I doubled the battery life on my Mac by closing one t... by agentgt on Wednesday February 17, 2016 @09:23AM (#11117982)
The article is pretty simple and not even really helpful for technical folks (since I'm sure most on HN are aware of the chrome task manager)

It does remind me of the serious issue with horrible Ad heavy sites and opens broader questions like are there other plugins/apps to ban cpu intensive sites? Even google getting involved with a ranking of how cpu intensive a site is might be interesting. In fact I was expecting the article to go down that path and was rather disappointed it was so simple.

I recently had to disable javascript on Wikia because the site had useful information but the Ad javascript code was horrific performance wise.

Re:How I doubled the battery life on my Mac by closing one t... by jjp on Wednesday February 17, 2016 @08:42AM (#11117736)
TLDR - shutdown tabs in Chrome that are consuming CPU. Write-up explains how to use Activity Monitor to diagnose and identify tabs causing problem.
Re:How I doubled the battery life on my Mac by closing one t... by greggman on Thursday February 18, 2016 @01:03AM (#11123990)
On my dual GPU MBP the biggest thing I do to get battery is use gfxCardStatus to force the MBP to use the integrated GPU only. Of course I do graphics and game related stuff but for example having Unity3D open but idle will keep the MBP in discrete GPU mode using lots more energy. Similarly having a google maps tab open in Chrome will also put the GPU in discrete GPU mode. gfxCardStatus lets me force it to integrated only when I don't need the speed.

Another minor thing I do is if I'm working on a game/visualization, at least in debug mode I make then pause if not the focus. Otherwise as I flip between my editor and my app/page the app/page is eating battery as it continously renders

Re:How I doubled the battery life on my Mac by closing one t... by discardorama on Wednesday February 17, 2016 @09:43AM (#11118109)
AKA, ".... with one simple trick!"

I wish Firefox had an ability to see which tab was hogging resources.

Re:How I doubled the battery life on my Mac by closing one t... by jimmaswell on Thursday February 18, 2016 @11:02AM (#11126665)
There's an experimental offshoot somewhere with per-tab processes or threads, does that one do that?
Re:How I doubled the battery life on my Mac by closing one t... by realusername on Wednesday February 17, 2016 @10:35AM (#11118491)
There is about:memory but it's not exactly as good as this indeed.
Re:How I doubled the battery life on my Mac by closing one t... by lsiunsuex on Wednesday February 17, 2016 @10:12AM (#11118308)
Interestingly enough - when I opened the Task Manager of Chrome, it was this article that was consuming the most memory / cpu of my open tabs.
Re:How I doubled the battery life on my Mac by closing one t... by chinathrow on Wednesday February 17, 2016 @09:00AM (#11117859)
Maybe the linked page is not badly coded at all - maybe that is done on purpose. Has anyone debugged why the mentioned page [1] is consuming so much CPU time?

[1]

http://www.xe.com/currencycharts/?from=EUR&to=USD&view=1M

Re:How I doubled the battery life on my Mac by closing one t... by rtkwe on Wednesday February 17, 2016 @09:45AM (#11118130)
It wasn't for me. I've let it sit for a couple minutes too. I can get it up to about 20% if I'm sitting there mousing over the chart with 2 years of data but other wise it doesn't seem to do too much.

I've noticed some site's scripts really don't like coming back from a long sleep so maybe it was some edge case like that causing it to eat so much CPU.

Re:How I doubled the battery life on my Mac by closing one t... by godshatter on Wednesday February 17, 2016 @12:05PM (#11119291)
When running Chrome, the CPU goes into the 15% to 20% range when running the mouse in circles over the chart on my Windows 7 box at work. When running Pale Moon, I get about 10% to 15%, even after allowing all javascript domains in NoScript. Of course, I'm still running an ad blocker and don't see the top and right-hand column ads which makes me wonder if the author happened to catch an ad that was coded badly.
Re:How I doubled the battery life on my Mac by closing one t... by rtkwe on Wednesday February 17, 2016 @03:52PM (#11121275)
That's pretty much my setup but with Windows 10 and uBlock and matches what I saw.
Re:How I doubled the battery life on my Mac by closing one t... by primozcigler on Wednesday February 17, 2016 @10:16AM (#11118341)
Well, I can confirm this happens for me on laptop. When I came to work after writing this post, I checked the page mentioned in the article again on my ubuntu at work (desktop machine) and the metrics were nothing special.
Re:How I doubled the battery life on my Mac by closing one t... by primozcigler on Wednesday February 17, 2016 @11:43AM (#11119088)
It is indeed the page for me. I profiled the page, even found the function. It seems like the events are fired again and again, multiple times per MILIsecond. Here is the screenshot http://awesomescreenshot.com/0375n2a4c4

And the CPU profile if anyone will analyse it further: https://dl.dropboxusercontent.com/u/47486136/CPU-20160217T17...

Re:How I doubled the battery life on my Mac by closing one t... by mcv on Wednesday February 17, 2016 @08:57AM (#11117842)
I also use Chrome's Task Manager a lot to figure out why my laptop's fan is suddenly trying to take off. Lately, though, the worst culprits seem to have been eliminated, and Chrome runs reasonably well even with the insane number of tabs I still have open.

Today it is Node that's draining my battery.

Re:How I doubled the battery life on my Mac by closing one t... by justinsb on Wednesday February 17, 2016 @08:50AM (#11117795)
I do spend too much of my day with Activity Monitor open (though I am a tabuser that is seemingly incapable of closing tabs). I hope we'll see smarter behavior from browsers with throttling or paging out of least-recently-used tabs; this isn't something people should have to do.
Re:How I doubled the battery life on my Mac by closing one t... by agumonkey on Wednesday February 17, 2016 @09:56AM (#11118207)
Anyone had the same CPU usage on the currency page ? it stays at 9% on my old machine.

ps: also check extensions, a few can leak GB of memory.

Re:How I doubled the battery life on my Mac by closing one t... by jkot on Wednesday February 17, 2016 @10:08AM (#11118282)
My CPU spins at 60% almost constantly due to type of work I do. I quadrupled my battery life by swapping batteries.
Re:How I doubled the battery life on my Mac by closing one t... by brudgers on Wednesday February 17, 2016 @09:12AM (#11117928)
Not really Mac specific since it's a feature of Chromium and by inheritance Chrome.
Re:How I doubled the battery life on my Mac by closing one t... by primozcigler on Wednesday February 17, 2016 @10:15AM (#11118331)
Agreed. It will work in win/linux as well, as the Chrome Task manager is available everywhere you can install Chrome.
Re:How I doubled the battery life on my Mac by closing one t... by sandGorgon on Wednesday February 17, 2016 @08:57AM (#11117836)
Anybody know if powertop can give this data on Linux?
Re:How I doubled the battery life on my Mac by closing one t... by creshal on Wednesday February 17, 2016 @09:01AM (#11117862)
Yes.
Re:How I doubled the battery life on my Mac by closing one t... by paride5745 on Wednesday February 17, 2016 @09:11AM (#11117914)
TIL if I close an app, my battery last longer.

Seriously, you should always close what you do not need. It is not only for energy efficiency, but for security as well.

Re:How I doubled the battery life on my Mac by closing one t... by ska on Wednesday February 17, 2016 @10:41AM (#11118529)
TYMHLSIFARTA (Today you might have learned something if you actually read the article).

It's not a great write-up, but it isn't about closing an app.

It is about the potentially surprising impact of individual tabs that keep code running, and a way to identify them.