Firefox using 100% of CPU on M1 Mac when large JavaScript sourcefile open in debugger
Categories
(DevTools :: Debugger, defect)
Tracking
(Not tracked)
People
(Reporter: brookerose1312, Unassigned)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
7.55 MB,
application/x-gzip
|
Details |
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:103.0) Gecko/20100101 Firefox/103.0
Steps to reproduce:
Open any website with a large JavaScript source file (or, even a moderately sized one, such as https://addons.mozilla.com/), and open the large source file (for example, addons.mozilla.com > static-frontend > amo-[numbers].js).
Actual results:
Firefox reaches 100% CPU usage and above on M1 Mac.
Expected results:
Firefox should not hang and reach large CPU usage.
Reporter | ||
Comment 1•2 years ago
|
||
https://share.firefox.dev/3atrL2o -- profiler permalink
Reporter | ||
Comment 2•2 years ago
|
||
Possible relevant CodeMirror bug ticket? https://github.com/codemirror/dev/issues/703
Comment 3•2 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'DevTools::Debugger' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Reporter | ||
Comment 4•2 years ago
|
||
From what I can see, the relevant code is a function in CodeMirror that in the minified code is
function W(e, t, n, r, i) {
null == t && -1 == (t = e.search(/[^\s\u00a0]/)) && (t = e.length);
for (var o = r || 0, a = i || 0; ; ) {
var l = e.indexOf("\t", o);
if (l < 0 || l >= t) return a + (t - o);
(a += l - o), (a += n - (a % n)), (o = l + 1);
}
}
Comment 5•2 years ago
|
||
Thanks for filing!
Nicolas, you mentioned a codemirror update, is there any bug filed for it? This performance issue might be a good motivation to do it?
And maybe we could also add a performance test here.
Comment 6•2 years ago
|
||
(In reply to Julian Descottes [:jdescottes] from comment #5)
Nicolas, you mentioned a codemirror update, is there any bug filed for it? This performance issue might be a good motivation to do it?
Yes, this is Bug 1773246 , and it could indeed be a good motivation. The debugger wouldn't be the easiest to migrate, but that would be a good exercise to know how to migrate the different features we have
Comment 7•2 years ago
|
||
I think the issue here is different from the one on GitHub. We seem to be spending most of our time in countColumn:
function countColumn(string, end, tabSize, startIndex, startValue) {
if (end == null) {
end = string.search(/[^\s\u00a0]/);
if (end == -1) { end = string.length; }
}
for (var i = startIndex || 0, n = startValue || 0;;) {
var nextTab = string.indexOf("\t", i);
if (nextTab < 0 || nextTab >= end)
{ return n + (end - i) }
n += nextTab - i;
n += tabSize - (n % tabSize);
i = nextTab + 1;
}
}
Which takes a very long time to complete on the file from the STRs , which has 1.7 million columns.
This method still seems mostly intact in the newest code mirror implementations: https://github.com/codemirror/language/blob/main/src/stringstream.ts.
Updated•2 years ago
|
Description
•