Last Comment Bug 766333 - Adblock Plus causes significant pageload slowdown on a page with tens of thousands of images
: Adblock Plus causes significant pageload slowdown on a page with tens of thou...
Status: NEW
[Snappy:p2][sps]
:
Product: Core
Classification: Components
Component: General (show other bugs)
: Trunk
: x86 Mac OS X
: -- normal with 4 votes (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-06-19 14:50 PDT by Benoit Girard (:BenWa)
Modified: 2012-08-07 05:59 PDT (History)
7 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments

Description Benoit Girard (:BenWa) 2012-06-19 14:50:17 PDT
Test case:
http://forums.mtbr.com/29er-bikes/chinese-carbon-29er-640919.html

Make sure 'Display Modes' has 'Hybrid Mode' selected.

Profile:
http://people.mozilla.com/~bgirard/cleopatra/?report=AMIfv963tUZMHuqJVOWNM2sgKmq-ljpZe1KD2kFbwxEpMHOAeaSdVe3r8eT8uDS4I-vZd1O2vzYl_gm98-YPNmj-EGLk6_nkpuca3shj6sWD3xB35wxzQixC8r6bantt5Ga8oFYC8ATz6a42OGDA37PWXiyrBCzKPQ

Now that adblock is blocking loading by over 3 seconds by doing document.write().
Comment 1 (dormant account) 2012-06-19 15:05:23 PDT
14:36 < BenWa> taras: Ok so I spoke to joe & ehsan. The profiles seems to indicate the AdBlock is invoking Document.write which is very inneficient and the dreaded
               'synchronous' type of calls
14:37 < BenWa> It apparently stops parsing, processes the document the write, throwing away the parsing up to date and restarts

14:37 < ehsan> to make it more inefficient, you can call document.open before .write ;)
14:37 < BenWa> ok
14:37 < ehsan> and then you can do it in a loop
14:37 < ehsan> and bingo!
Comment 2 Boris Zbarsky [:bz] 2012-06-19 19:20:19 PDT
Is this Adblock, or Adblock Plus?
Comment 3 Benoit Girard (:BenWa) 2012-06-19 19:50:52 PDT
Adblock Plus 2.0.3
Comment 4 Wladimir Palant 2012-06-19 23:26:08 PDT
(In reply to Taras Glek (:taras) from comment #1)
> 14:36 < BenWa> taras: Ok so I spoke to joe & ehsan. The profiles seems to
> indicate the AdBlock is invoking Document.write

Adblock Plus doesn't use document.write(), the web page is doing it itself. JavaScript Deobfuscator indicates that http://forums.mtbr.com/clientscript/vbulletin_thrdpostlist.js?v=387 is the culprit, function writeLink() is invoked 2705 times and performs a bunch of document.write() calls each time (average execution time displayed as 18 ms on my machine). The page source contains a huge script block with writeLink() calls starting at line 1980, there are indeed that many calls there. And that it completely independent of Adblock Plus, not sure why you see a difference with Adblock Plus off.

Note that the Facebook widgets also cause a significant slowdown on this page, these insert a node into the document 10 times per second. They aren't the biggest issue however, the page is still terribly slow even after I blocked them.
Comment 5 (dormant account) 2012-06-20 08:47:59 PDT
Wlad, do you have an idea of why ABP is causing  (~10x on my machine) slowdown in pageloading?
Comment 6 Wladimir Palant 2012-06-20 11:33:18 PDT
After looking at this with Diagnostics for Adblock Plus - yes, I do. The "hybrid mode" produces 22000 content policy calls, as opposed to 400 content policy calls in the regular case. That's a whole lot of requests for these addresses:

http://forums.mtbr.com/images/misc/paperclip.gif
http://forums.mtbr.com/images/misc/tree_t.gif
http://forums.mtbr.com/images/statusicon/post_old.gif
http://forums.mtbr.com/images/misc/tree_i.gif
http://forums.mtbr.com/29er-bikes/clear.gif

If you check, these images are really there - in the tree view produced via document.write(). That's a lot of content policy calls to process, despite the caching. According to Diagnostics, Adblock Plus needs on average 0.4ms for each call on my machine, plus XPCOM overhead. I want to look into making our shouldLoad implementation faster but I don't think that it can be magnitudes faster than it currently is.
Comment 7 Boris Zbarsky [:bz] 2012-06-20 11:36:17 PDT
If we did the loads async (which we want to anyway), we could at least do them form a separate event queue and throttle them or something....
Comment 8 (dormant account) 2012-07-19 10:24:12 PDT
(In reply to Boris Zbarsky (:bz) from comment #7)
> If we did the loads async (which we want to anyway), we could at least do
> them form a separate event queue and throttle them or something....

Is there a bug/API-proposal for this?
Comment 9 Boris Zbarsky [:bz] 2012-07-19 11:06:48 PDT
I don't know offhand.
Comment 10 Benoit Girard (:BenWa) 2012-07-26 17:50:51 PDT
Gathered a new profile with the enhanced JS support:
http://people.mozilla.com/~bgirard/cleopatra/?report=9e82fde39f6d6b839df41fa367d26b704f3810d0

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