Pasting small text on https://opentype.js.org/ is 3x slower in Firefox and spends time in things like IonInstanceOfIC::update, map, and js::BaseShape::clasp
Categories
(Core :: JavaScript Engine, task, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox146 | --- | fixed |
People
(Reporter: mayankleoboy1, Assigned: jandem)
References
(Blocks 1 open bug, )
Details
Attachments
(3 files)
Go to https://opentype.js.org/
Copy-paste the attached sample text
Once the text is pasted, you can try to check/uncheck the options, or play with the sliders of the second demo.
firefox pasting: https://share.firefox.dev/4n5Qg4K (3s)
Firefox all operations: https://share.firefox.dev/43dc4UZ
Chrome: https://share.firefox.dev/43avYQu (1s to paste, all the operations)
Updated•11 months ago
|
| Assignee | ||
Comment 1•11 months ago
|
||
Interesting find. The code does action instanceof SubstitutionAction where action is a primitive. Our CacheIR implementation of instanceof requires the RHS (SubstitutionAction) to have a .prototype property, but because the LHS is a primitive, we never resolve this lazy property in the fallback code because the spec only does the lookup for LHS objects.
I checked some other benchmarks and apparently the new-ish prismjs test in JetStream 3 also hit this a number of times (for LHS string values).
| Assignee | ||
Comment 2•11 months ago
|
||
Here's a micro-benchmark that improves from 6863 ms to 284 ms (--spectre-mitigations=off) with a fix for this.
function Foo() {}
function f() {
var res = 0;
var t = Date.now();
for (var i = 0; i < 100_000_000; i++) {
res += (i instanceof Foo);
}
print(Date.now() - t);
return res;
}
f();
| Assignee | ||
Comment 3•11 months ago
|
||
| Assignee | ||
Comment 4•11 months ago
|
||
This fixes a performance cliff when the LHS is a primitive. In that case
the fallback code will not resolve the lazy RHS.prototype property but our
CacheIR code currently requires a prototype object for LoadInstanceOfObjectResult.
We could emit different CacheIR ops for this case involving a primitive LHS with a
not-yet-resolved RHS.prototype, but that seemed more complicated.
Comment 6•11 months ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/4efd82e08919
https://hg.mozilla.org/mozilla-central/rev/dd8501220db1
| Reporter | ||
Comment 7•11 months ago
|
||
Latest Nightly: https://share.firefox.dev/4qkUDf1 (850ms)
So we are 3.5x faster than before and 15% faster than Chrome now.
Updated•10 months ago
|
Description
•