Closed
Bug 1382639
Opened 7 years ago
Closed 2 years ago
String iteration over a rope can be slow
Categories
(Core :: JavaScript Engine: JIT, enhancement, P3)
Core
JavaScript Engine: JIT
Tracking
()
RESOLVED
DUPLICATE
of bug 1784478
People
(Reporter: anba, Unassigned)
Details
(Keywords: triage-deferred)
Attachments
(1 file)
7.46 KB,
patch
|
Details | Diff | Splinter Review |
It can be slow for basically the same reason as in bug 1331136: We won't flatten the rope because of the optimization in JSString::getChar(), which means we always call into the runtime to retrieve char.
Example benchmark:
var q = 0;
var dt = 0;
for (var i = 0; i < 1000000; ++i) {
var s = "a".repeat(15);
s = s.split("").join(""); // flatten
s = s + s; // rope
var t = dateNow();
for (var k of s) ++q;
dt += dateNow() - t;
}
print(dt, q);
This µ-benchmark currently completes in ~525ms for me, adding support to load a char from right-hand side of a rope to MacroAssembler::loadStringChar() (see attached patch) would improve it to ~380ms.
The question is now whether or not it's worth it to handle the rhs of a rope in MacroAssembler::loadStringChar()?
Updated•7 years ago
|
Keywords: triage-deferred
Priority: -- → P3
Comment 1•2 years ago
|
||
The patch in bug 1784478 improves this from ~1130 ms to ~611 ms for me.
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•