Hacker News new | ask | show | jobs
by __david__ 4252 days ago
Yeah, Firefox really needs some sort of "top". Right now, idling, my Firefox is taking between 20% and 40% of my CPU. I'm sure it's some tab running some dumb javascript, but there's no way for me to figure out which one. Sad, because spidermonkey must know which window a javascript context is associated with, so it could feasibly keep track of run time.
2 comments

SpiderMonkey itself actually has no concept of windows at all. So it doesn't know what window anything has to do with.

The browser itself does, though. Some sort of "top"-like utility is in fact being worked on, for both websites and extensions.

Yeah, but it knows the global "window" object. That's enough for it to keep track of stuff. Let the browser correlate that global object with an actual UI window/tab.
If a script hangs, Firefox has a little popup on that tab that asks if you want to kill it or let it keep running. So something in the browser knows which tabs are JS-intensive.
Sure. That particular setup has pretty low overhead and hence also low granularity; it's not measuring intensive or not but just how long a script has been running when a timer on a background thread fires. So your script could be eating up all the CPU but just returning to the event loop every few seconds and the hung script dialog would never notice.
In my experience, with vanilla firefox on a desktop (linux, i7), 1 tab with twitter open takes about that much processor power.