[Webkit-unassigned] [Bug 66765] New: Performance of String.replace(/regex/g, string) is shockingly low

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Aug 23 04:40:14 PDT 2011


https://bugs.webkit.org/show_bug.cgi?id=66765

           Summary: Performance of String.replace(/regex/g,string) is
                    shockingly low
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: All
        OS/Version: All
            Status: UNCONFIRMED
          Severity: Normal
          Priority: P2
         Component: JavaScriptCore
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: victor.grishchenko at gmail.com


Created an attachment (id=104821)
 --> (https://bugs.webkit.org/attachment.cgi?id=104821&action=review)
a very simple testcase for Array.join() and String.replace()

I generally expect that doing a linear pass of a string with a regex should work much-much faster than manual search/replace/iteration. That seems not to be the case with WebKit (I checked Chrome, Safari, Mobile Safari is especially awful). Please check the attached test case. Results for misc WebKit browsers are:

> MacMini Safari
> started 11.686ms
218
> composed 11.904ms
41
> joined 11.945ms
131
> replaced 12.76ms 1000000

> Mac Mini Chrome
> started 14.111ms
81
> composed 14.192ms
223
> joined 14.415ms
186
> replaced 14.601ms 1000000

Linux Chromium
> started 37.316ms
39
> composed 37.355ms
110
> joined 37.465ms
97
> replaced 37.562ms 1000000

Linux node.js
> started 29.946ms
34
> composed 29.980ms
3
> joined 29.983ms
20
> replaced 30.103ms 1000000

As you might see, if ran outside WebKit, node.js/JavaScript/v8 does the same String.replace operation FIVE times faster than JavaScript/v8 inside WebKit (20ms vs 97ms), on the same hardware/OS.
Mobile Safari is just a disaster, it does it in 675ms (on iPad).
I may speculate that there is some problem in XXXStringBuilder, as Array.join() follows a similar pattern: slow in WebKit, fast alone.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list