Bug 19368 - Extremely slow parsing of deeply nested divs
Summary: Extremely slow parsing of deeply nested divs
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Windows XP
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-03 04:22 PDT by Michael A. Puls II
Modified: 2008-06-03 14:06 PDT (History)
2 users (show)

See Also:


Attachments
Example (170.16 KB, text/html)
2008-06-03 04:23 PDT, Michael A. Puls II
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael A. Puls II 2008-06-03 04:22:50 PDT
WebKit-SVN-r34278 with Safari Win32 3.1.1(525.17)

Parsing ~15840 divs deep takes a long time in Webkit.

On a PIII 733MHz, Opera 9.5 (latest snapshot) and FF3 (latest trunk) take around 1.5 to 2 seconds to parse.  Webkit takes ~66 seconds.

Seems like there's room for optimization.

Will attach example.
Comment 1 Michael A. Puls II 2008-06-03 04:23:27 PDT
Created attachment 21474 [details]
Example
Comment 2 mitz 2008-06-03 09:26:20 PDT
(In reply to comment #0)
> On a PIII 733MHz, Opera 9.5 (latest snapshot) and FF3 (latest trunk) take
> around 1.5 to 2 seconds to parse.  Webkit takes ~66 seconds.

Opera 9.50 beta constructs a DOM tree only about 500 levels deep; Firefox 3.0b4 caps at around 200.
Comment 3 Michael A. Puls II 2008-06-03 14:06:09 PDT
(In reply to comment #2)
> (In reply to comment #0)
> > On a PIII 733MHz, Opera 9.5 (latest snapshot) and FF3 (latest trunk) take
> > around 1.5 to 2 seconds to parse.  Webkit takes ~66 seconds.
> 
> Opera 9.50 beta constructs a DOM tree only about 500 levels deep; Firefox 3.0b4
> caps at around 200.

Confirmed and it seems Webkit caps at around 1024.

What's actually happening here? document.getElementsByTagName("div").length reports all 15840 divs.  Are they somehow flattened during parsing so they don't run so deep?