[Webkit-unassigned] [Bug 12648] New: 9A241: JavaScript RegExp 25-30x slower than on 10.4.7

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Feb 6 23:21:25 PST 2007


           Summary: 9A241: JavaScript RegExp 25-30x slower than on 10.4.7
           Product: WebKit
           Version: 420+ (nightly)
          Platform: Macintosh
        OS/Version: Mac OS X 10.4
            Status: NEW
          Keywords: InRadar
          Severity: Normal
          Priority: P1
         Component: JavaScriptCore
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: mjs at apple.com

2006-08-18 03:31:49 Keisuke Hara:
JavaScript RegExp in Leopard9A241 seems to be slower than Chardonnay8G1165 on
my machine (PowerMac G5 2.5GHz dual).

Attached Xcode project to test this problem. When running it and pressing "Load
HTML via JavaScript" button, it loads HTML via XMLHttpRequest(), modifies link
URLs using RegExp, and logs elapsed time for modifying text as "process text
time = XX ms" to debugger console. (WikipediaSupport.js)

When I ran this application on Chardonnay8G1165, elapsed time is 3 ms, but the
same task took about 70 ms on Leopard9A241.

2006-08-21 11:35:21 Alice Liu:
Hi Keisuke,  I can build your project on Leopard 9A241 but not 10.4.7 8J135. 
if your test case just involved XMLHTTPRequest(), you should be able to create
a standalone HTML file with javascript to test your bug, right?  Also, where is
the elapsed time logged to? I'm looking in various logs in Console.app and I
don't see any output.  The best way to proceed with this bug is to write a
standalone test file that we can open with a browser.  If you want to log to
the JS console in Safari, use window.console.log("output").  

2006-08-22 18:20:33 Keisuke Hara:
The attached project is made for my another investigation task, so should not
be most suitable for reproducing this issue, sorry. The log from JavaScript is
redirected to NSLog() in the test application, so it should be written to
Console.app (or Run Log /Debugger Console if running in Xcode, of course).

Anyway, I'll make a standalone HTML file to be loaded into Safari.

2006-08-22 19:04:15 Keisuke Hara:
Created and attached HTML and JavaScript file (TestFiles.zip). Please load
Test.html file into Safari. I used both window.console.log() and alert() to
show the result. The result on my machine, 9A241/8G1165 = 60/2.

2006-08-23 12:51:40 Alice Liu:
Thanks for the test file!

2006-08-25 15:58:01 Stephanie Lewis:
Using his test file I got ~8 seconds in Tiger vs ~89 seconds in Leopard 9A250

2006-08-29 10:26:40 Alice Liu:
Safari BRB Reviewed 

2006-10-11 09:54:51 Matt Drance:
I'm seeing ~20x slower testing one of my Dashboard widgets in nightly WebKit on
Tiger; I'll reduce the case and attach it here.

2006-10-11 10:25:35 Matt Drance:
Attached... takes 23ms in Safari 2.0.4 (419.3); 1867ms in WebKit-SVN-16968.

2006-12-15 19:26:02 Stephanie Lewis:
Still occurs in Leopard 9A325

2006-12-20 16:09:51 Darin Adler:
The reason this happened is because we turned on NO_RECURSE, because otherwise
regular expressions can overflow the stack.

In the NO_RECURSE code path there are many uses of longjmp, and according to my
profiling longjmp is quite slow.

Perhaps to fix this we can figure out a way to make NO_RECURSE work without
using longjmp.

2006-12-20 16:13:34 Darin Adler:
The change that turned NO_RECURSE on was revision 14435 , done to fix an
incompatibility with Yahoo <http://bugs.webkit.org/show_bug.cgi?id=8870>.

2006-12-21 12:26:10 Darin Adler:
I think we might be able to replace the longjmp with a switch statement and

2006-12-21 12:29:10 Darin Adler:
There seem to be 53 different uses of the RMATCH macro (oof).

2007-01-03 22:22:17 Geoff Garen:
I looked at using Mozilla's jsregexp.c today. It doesn't look terribly
complicated to port. However, they're still 3-5X slower than 10.4.7 (in
Firefox). That finding was also confirmed in <rdar://problem/4519589>.

2007-02-06 08:35:24 Darin Adler:
I found a great solution! We can use gcc's computed goto. I have it coded
already, but I haven't done performance testing yet.

2007-02-06 09:37:49 Darin Adler:
I've got it now 6% slower instead of 2000% slower. Still working on it.

2007-02-06 09:58:39 Darin Adler:
Test case is now 15% faster instead of 2000% slower. But other regular
expression tests might end up slower.


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

More information about the webkit-unassigned mailing list