Closed Bug 1156886 Opened 9 years ago Closed 9 years ago

Optimize ToLowerCase and ToUpperCase in vm/Unicode.h

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla40
Tracking Status
firefox40 --- fixed

People

(Reporter: jandem, Assigned: jandem)

Details

Attachments

(1 file)

I was just comparing our Dromaeo object-string numbers with V8 (see also bug 1088293), and noticed we're like 8x slower on the toLowerCase/toUpperCase tests.

There are a few things we should do:

(1) Optimize the ch < 128 case in ToLowerCase(char16_t ch) and ToLowerCase(char16_t ch), similar to what we do for IsSpace, IsIdentifierPart and others.

(2) V8 has an even more optimal algorithm for Latin1 strings that can compare/convert multiple characters at once.

Just doing (1) should help a good deal, (2) might be nice as well.
Attached patch PatchSplinter Review
This is (1) in comment 0. For the microbenchmark below I get:

js before: 561 ms
js after:  197 ms
d8:        118 ms

Still a bit slower than V8 but 2.8x faster than before and probably good enough for now.

function f() {
    var s = "abcdefg0123456789";
    for (var i=0; i<4; i++)
        s += s;
    var t = new Date;
    for (var i=0; i<1000000; i++)
        s = s.toLowerCase();
    print(new Date - t);
    return s;
}
f();
Attachment #8595542 - Flags: review?(luke)
Comment on attachment 8595542 [details] [diff] [review]
Patch

Nice
Attachment #8595542 - Flags: review?(luke) → review+
Unfortunately, on AWFY at least, this patch made no difference.
https://hg.mozilla.org/mozilla-central/rev/8d4f212cc9b8
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla40
You need to log in before you can comment on or make changes to this bug.