Last Comment Bug 672064 - twitter-text.js is slow to load in Firefox
: twitter-text.js is slow to load in Firefox
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: 8 Branch
: x86 Mac OS X
: -- normal with 1 vote (vote)
: mozilla10
Assigned To: general
:
Mentors:
Depends on: 673188
Blocks: WebJSPerf
  Show dependency treegraph
 
Reported: 2011-07-16 11:55 PDT by Robert Sayre
Modified: 2011-10-18 21:35 PDT (History)
12 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
jquery dependency (160.01 KB, application/x-javascript)
2011-07-16 11:57 PDT, Robert Sayre
no flags Details
twitter-text.js (28.21 KB, application/x-javascript)
2011-07-16 11:58 PDT, Robert Sayre
no flags Details
Test case (521 bytes, text/html)
2011-07-16 12:00 PDT, Robert Sayre
no flags Details

Description Robert Sayre 2011-07-16 11:55:09 PDT
I was playing around with this file this morning and noticed that the latency was really bad in Firefox 5 and 8. I narrowed it down to the time need to create a bunch of regular expressions. Will attach a testcase. Here are the times:

Firefox 8:      1450ms
WebKit Nightly: 150ms
Chrome 12:      20ms

Since we're sharing a regex implementation with WebKit, I am puzzled by the disparity here. Perhaps we are eagerly compiling each regex and they are doing so lazily. I ruled out network traffic by placing timers directly in the source (attached test is different, so as not to perturb the original file).
Comment 1 Robert Sayre 2011-07-16 11:57:30 PDT
Created attachment 546343 [details]
jquery dependency
Comment 2 Robert Sayre 2011-07-16 11:58:27 PDT
Created attachment 546344 [details]
twitter-text.js
Comment 3 Robert Sayre 2011-07-16 12:00:50 PDT
Created attachment 546345 [details]
Test case
Comment 4 Robert Sayre 2011-07-16 12:05:52 PDT
Source repo is here:

https://github.com/twitter/twitter-text-js

Poking around twitter.com, I see that this file does get used, albeit an earlier version with fewer regexes to run. 

(Also CCing oliver@apple in case he wants to file a bug on JSC being an order of magnitude slower than V8 here)
Comment 5 Oliver Hunt 2011-07-16 12:11:44 PDT
https://bugs.webkit.org/show_bug.cgi?id=64652
Comment 6 Robert Sayre 2011-07-16 12:20:17 PDT
https://gist.github.com/1086653

Here's a patch that speeds up the load in all browsers, in the WebKit bug Oliver points out that I didn't Shark it yet so it could be something else.
Comment 7 Robert Sayre 2011-07-16 16:44:26 PDT
The issue was a really long regex. They fixed it on another branch by using character ranges instead.

https://github.com/twitter/twitter-text-js/commit/672cf1b17069712cb3a674c73f8a92b21669ac1b
Comment 9 Timothy Nikkel (:tnikkel) 2011-07-21 15:56:51 PDT
673274
Comment 10 Chris Leary [:cdleary] (not checking bugmail) 2011-10-07 15:47:37 PDT
Making the dependency more specific. Note the reduction in bug 673188 comment 35.
Comment 11 Chris Leary [:cdleary] (not checking bugmail) 2011-10-18 21:35:58 PDT
HTML test case shows 9ms in nightlies for me.

Note You need to log in before you can comment on or make changes to this bug.