Slow script using 90% CPU




13 years ago
9 years ago


(Reporter: Ser Gio, Unassigned)



Firefox Tracking Flags

(Not tracked)




(2 attachments)



13 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; rv:1.8) Gecko/20060126 Firefox/1.5
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; rv:1.8) Gecko/20060126 Firefox/1.5

When i go to: firefox starts using 100%cpu and it becomes unusable.

Reproducible: Always

Expected Results:  

Other browsers are fine. I'm using gentoo, and firefox 1.5
WFM Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20060111 Firefox/
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20060203 Firefox/1.6a1 ID:2006020322
In it is nearly 100% and in trunk around 80%. In IE also around 80%.

Comment 3

13 years ago
Opera 8.5 and konqueror 3.5.1 only use 12% on my pc. (centrino 1.4Ghz)
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9a1) Gecko/20060217 Firefox/1.6a1
Works fine for me, with Firefox using only about 11% CPU.

Comment 5

12 years ago
5-10% on Athlon64 3500+
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20060504 Minefield/3.0a1
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9a1) Gecko/20060507 Minefield/3.0a1 - Build ID: 0000000000
Wagh. It's now shot up to ~90% CPU. :-\
I've created a reduced testcase, with only the snow script (which is causing the problem).
Component: General → JavaScript Engine
Ever confirmed: true
Product: Firefox → Core
Summary: This site puts firefox using 100% CPU → Snow script using 90% CPU
Version: unspecified → Trunk
Created attachment 221221 [details]

Attached testcase. I haven't tried to reduce the Javascript, but it's probably the large amount of looping in the code.
Assignee: nobody → general
QA Contact: general → general
No slow script dialog, so I doubt this is a JS engine bug.  (Tip: if you can't reproduce it with just a <script> that doesn't use any DOM object or methods, it's unlikely to be a JS engine bug.)  Moving to DOM, though a profile would let it be assigned more confidently.
Assignee: general → general
Component: JavaScript Engine → DOM
QA Contact: general → ian
Summary: Snow script using 90% CPU → Slow script using 90% CPU

Comment 9

12 years ago
The main loop is this one:

function movesnow() {

        //do stuf (...)

        setTimeout("movesnow()", 50);


1 movesnow iteration takes 6 ms in firefox, and 6 ms in konqueror, however, when you run it in konqueror the movesnow function is called 1000 times (during a 60 second run), and in firefox it's only called 50.

The problem is that, in firefox, setTimeout is doing a 1300ms pause instead of 50ms (and while it's pausing its mysteriously burning CPU).


Comment 10

12 years ago
Created attachment 223725 [details]
setTimeout test

Here's the test i run.

It shows how much milisecs setTimeout takes to call the function (it should be near 50). My results are 1300 for firefox and 60 for konqueror
Is this still a problem?  That last testcase shows numbers around 50 for me in a current trunk build...  Note that movesnow() doesn't do most of the work in that testcase (or at least didn't use to); most of it happens off the event loop when the restyle and reflow happen.  That could explain the observation in comment 9.

Comment 12

9 years ago
No, it's not a problem any more.

Runs fine (or as fine as other browsers) and I also get numbers around 50 in test case from comment #10.

I'm using FF 3.0.8.

I guess we can close this :)
Last Resolved: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.