Bug 19368 - Extremely slow parsing of deeply nested divs
Summary: Extremely slow parsing of deeply nested divs
Status: RESOLVED CONFIGURATION CHANGED
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: 2022-08-11 11:51 PDT (History)
7 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?
Comment 4 Ahmad Saleem 2022-08-11 10:16:22 PDT
I think browsers in general are well-optimised and CPU architectures have evolved to an extent where these div cases does not lead to any crash or parsing time consumption.

In all browsers (Chrome Canary 106, Firefox Nightly 105 and Safari 15.6 on macOS 12.5 using M1 Pro), this test case load instantly and in Console using - document.getElementsByTagName("div").length, it shows 15840 for everyone.

rniwa@webkit.org & ap@webkit.org - Is there something needed here, or we can mark it as "RESOLVED CONFIGURATION CHANGED" or "RESOLVED WONTFIX"?
Comment 5 Ryosuke Niwa 2022-08-11 11:51:27 PDT
This doesn't seem that slow to me now.