The default bug view has changed. See this FAQ.

twitter-text.js is slow to load in Firefox

RESOLVED FIXED in mozilla10

Status

()

Core
JavaScript Engine
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: Robert Sayre, Unassigned)

Tracking

(Blocks: 1 bug)

8 Branch
mozilla10
x86
Mac OS X
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(3 attachments)

160.01 KB, application/x-javascript
Details
28.21 KB, application/x-javascript
Details
521 bytes, text/html
Details
(Reporter)

Description

6 years ago
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).
(Reporter)

Comment 1

6 years ago
Created attachment 546343 [details]
jquery dependency
(Reporter)

Comment 2

6 years ago
Created attachment 546344 [details]
twitter-text.js
(Reporter)

Updated

6 years ago
Attachment #546343 - Attachment mime type: text/plain → application/x-javascript
(Reporter)

Comment 3

6 years ago
Created attachment 546345 [details]
Test case
(Reporter)

Comment 4

6 years ago
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

6 years ago
https://bugs.webkit.org/show_bug.cgi?id=64652
(Reporter)

Comment 6

6 years ago
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.
(Reporter)

Comment 7

6 years ago
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
(Reporter)

Comment 8

6 years ago
er, that should be

https://github.com/twitter/twitter-text-js/commit/e7a123d8da2e8efbf808d672acf43835fb356736#diff-1
Blocks: 579390
673274
Depends on: 673274
Making the dependency more specific. Note the reduction in bug 673188 comment 35.
Depends on: 673188
No longer depends on: 673274
HTML test case shows 9ms in nightlies for me.
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla10
You need to log in before you can comment on or make changes to this bug.