Setting the value of a textarea is very slow
Categories
(Core :: Spelling checker, defect)
Tracking
()
People
(Reporter: sfraser_bugs, Unassigned)
References
(Depends on 2 open bugs, Blocks 4 open bugs, )
Details
(Keywords: perf, testcase)
Attachments
(3 files, 1 obsolete file)
Reporter | ||
Comment 1•22 years ago
|
||
Reporter | ||
Comment 2•22 years ago
|
||
Comment 3•22 years ago
|
||
Reporter | ||
Comment 4•22 years ago
|
||
Reporter | ||
Comment 5•22 years ago
|
||
Reporter | ||
Comment 6•22 years ago
|
||
Comment 7•21 years ago
|
||
Comment 10•21 years ago
|
||
Updated•21 years ago
|
Reporter | ||
Comment 11•21 years ago
|
||
Comment 12•21 years ago
|
||
Comment 13•20 years ago
|
||
Comment 14•20 years ago
|
||
Comment 15•19 years ago
|
||
Comment 16•19 years ago
|
||
Comment 17•19 years ago
|
||
Comment 18•19 years ago
|
||
Comment 19•17 years ago
|
||
Updated•15 years ago
|
Comment 21•15 years ago
|
||
Comment 22•14 years ago
|
||
Comment 23•14 years ago
|
||
Comment 24•14 years ago
|
||
Comment 25•14 years ago
|
||
Comment 26•14 years ago
|
||
Comment 27•14 years ago
|
||
Comment 28•14 years ago
|
||
Comment 29•14 years ago
|
||
Comment 30•14 years ago
|
||
Comment 31•14 years ago
|
||
Comment 32•14 years ago
|
||
Comment 33•14 years ago
|
||
Comment 34•14 years ago
|
||
Comment 35•14 years ago
|
||
Comment 36•14 years ago
|
||
Comment 37•14 years ago
|
||
Comment 38•14 years ago
|
||
Comment 39•14 years ago
|
||
Comment 40•14 years ago
|
||
Comment 41•14 years ago
|
||
Comment 42•14 years ago
|
||
Comment 43•14 years ago
|
||
Comment 44•14 years ago
|
||
Comment 45•14 years ago
|
||
Comment 46•14 years ago
|
||
Comment 47•14 years ago
|
||
Comment 48•14 years ago
|
||
Comment 49•14 years ago
|
||
Comment 50•14 years ago
|
||
Comment 51•14 years ago
|
||
Comment 52•14 years ago
|
||
Comment 53•14 years ago
|
||
Comment 54•14 years ago
|
||
Comment 55•14 years ago
|
||
Comment 56•5 years ago
|
||
Firefox: 8450 ms to add 100 textareas, 367 characters each
Chrome: 140 ms seconds
<body>
<p id=p>...</p>
<script>
const props = {
value: document.body.textContent.trim(),
spellcheck: false,
};
const makeText = () => Object.assign(document.createElement('textarea'), props);
const t0 = performance.now();
document.body.append(...Array(100).fill(0).map(makeText));
setTimeout(() => {
p.textContent = (performance.now() - t0 | 0) + ' ms';
});
</script>
</body>
Comment 57•5 years ago
|
||
Typo above: "ms seconds" should be "ms"
Comment 58•5 years ago
|
||
On my machine both Nightly and Chrome take ~100ms.
Comment 59•5 years ago
|
||
I've tried in Windows 10.
On my machine both Nightly and Chrome take ~100ms.
Linux, I guess, as it's also fast for me in FF.
With both iterations and text lines 1000, Firefox takes about 150 milliseconds while Chrome takes about 40 milliseconds. Quite a difference but I guess it's negligible in common cases.
Comment 61•5 years ago
|
||
Kagami, do you think you could capture a performance profile for this?
Tried a quick profiling with both values 10,000: https://perfht.ml/2yRwDv6
Comment 63•5 years ago
|
||
FWIW using the test case in comment #c56 recorded a profile at https://perfht.ml/2zutPnI which shows that most of those ~9 seconds is spent in nsNativeThemeWin::ThemeSupportsWidget because I have WindowBlinds (even though Firefox.exe is excluded from styling). Evidently, mine is quite an edge case and you can disregard it, but since Chrome and other apps (even styled ones) are unaffected, maybe you could simply cache the theme info at least for the duration of the layout/rendering op...
which shows that most of those ~9 seconds is spent in nsNativeThemeWin::ThemeSupportsWidget
The profile says it took only 1.76% (88ms) of the whole running time, no?
Comment 65•5 years ago
|
||
The profile says it took only 1.76% (88ms) of the whole running time, no?
No, AFAICT: if you switch to the flame graph you will see a more obvious rendition of its usage.
I'm looking at that graph and it never exceeds 2% of the running time.
Comment 67•5 years ago
|
||
I'm looking at that graph and it never exceeds 2% of the running time.
Sounds like you're looking at a single node in the flame graph or at the pure numbers in call stack mode, which seem to be omitting the overhead of loading and calling an extra dll. If you look at the whole graph you will see the gray areas (dll loader) are occupying most of each pink (native Firefox) block's length. Naturally, none of this is happening in an OS without WindowBlinds.
Ah, now I see, sorry!
I tried the same repro from #c56 on my machine and definitely can see the difference: https://perfht.ml/3aJQucw
Comment 69•5 years ago
|
||
Based on the profiler result, a workaround for test case in https://bugzilla.mozilla.org/show_bug.cgi?id=190147#c56 is to set widget.disable-native-theme-for-content
to true
in about:config. This will prevent Firefox from querying WindowBlinds dll and the test case will take just ~100ms to complete on my machine, same as Chrome.
The code seems that it should be cached, though: https://searchfox.org/mozilla-central/rev/158bac3df3a1890da55bdb6ffdaf9a7ffc0bfb0a/widget/windows/nsUXThemeData.cpp#55
I guess somehow OpenThemeData
returns null every time in your case and thus saves no cache.
to set widget.disable-native-theme-for-content to true in about:config.
Doing so will call nsNativeBasicTheme::ThemeSupportsWidget
instead of nsNativeThemeWin::ThemeSupportsWidget
(by EnsureTheme()
which reads that option). Thanks for the info.
Comment 72•5 years ago
|
||
Tested comment 56 today's nightly on linux, and now Nightly is constantly faster than Chrome. 60 vs 100ms or so
If I change that the count in test from 100 to 10000, Nightly is ~3500, chrome ~8500.
This is on Linux.
We should aim for similar on Windows :)
Updated•5 years ago
|
I guess the Windows theme thing is a separate issue as it's still slower on Windows without it. :woxxom, do you mind opening a new issue?
Comment 75•5 years ago
|
||
ok, and the number I get are different to what Kagami sees because we've been running different test cases. I've been using the one from comment 56 and Kagami textarea_speed.html
Comment 76•3 years ago
|
||
Changing component since this has been narrowed down to the spellchecker.
Comment 77•3 years ago
|
||
Hi Kagami, is there still something to investigate under windows here?
IIUC, the original scope "very slow" of this bug has been addressed a long time ago and the special case from bug 1633718 is fixed, too. To me it seems, that if there is still something to do we should have a new bug for it.
With both iterations and text lines 1000, Firefox takes about 150 milliseconds while Chrome takes about 40 milliseconds. Quite a difference but I guess it's negligible in common cases.
It's better now, Firefox takes only 2x times more than Chrome does. Still significant, but I have no proof that this can affect actual use cases. I'm closing this, but should I file another one for that perf difference?
Comment 79•3 years ago
|
||
I assume we have enough performance monitoring in place, the difference seems not to bad.
Comment 80•3 years ago
|
||
Testing textarea_speed.html:
Locally I see Firefox being faster than Chrome when using 10000 iterations and 100 lines. 19ms vs 43ms.
And 1000 iterations with 1000 lines they have the same performance. (16-18ms).
That is on Linux.
On Windows 11, 10000 iteration, 100 lines, Firefox 14ms, Edge 24ms
1000/1000, Firefox 8ms, Edge 8ms
Kagami, I'm still puzzled how you get so bad numbers on Windows.
Could you perhaps create a new performance profile?
testare_speed is okay, I mean comment #56.
Description
•