Open Bug 529661 Opened 15 years ago Updated 2 years ago

Beachballing when loading this page

Categories

(Core :: Layout: Block and Inline, defect)

x86
macOS
defect

Tracking

()

People

(Reporter: bzbarsky, Unassigned)

References

(Depends on 1 open bug, )

Details

(Keywords: perf)

BUILD: 2009-11-10 nightly

STEPS TO REPRODUCE:
1)  Load the url in the url field
2)  Observe the beachballing at the end of the pageload as the text goes from
    black-on-white to white-on-black.

DETAILS:

Profile shows that most of the time is taken by restyle processing, and in particular by nsBlockInFlowLineIterator::nsBlockInFlowLineIterator called from nsBlockFrame::ChildIsDirty, called from FrameNeedsReflow.  Under that constructor, it's mostly FindValidLine and nsLineBox::IndexOf.

I'm not quite sure why we have all these restyle events yet.  I'm also not sure what we can do about this, exactly; can we somehow cache the line we found the previous restyle on?  Might not help much, if the restyles are coming out of the hashtable in random order....
OK, I can reproduce this reliably by switching between the "Twilight" and "Clean (Pastie)" themes using the Theme dropdown at the top right of the paste area.  What seems to happen is that lots and lots of spans change their padding from 0 to nonzero on that theme change, and we have to locate all the corresponding line boxes so as to mark them dirty...
And I'm guessing we have no way of getting from the span to the line box without searching all the block's children so this starts looking like O(N^2)?

Do we have a bit free that we can use to mark a frame as being the first frame in a line box? There's several optimizations we can do there: walking backwards to the nearest first-frame let's us search the line box list O(#line boxes) instead of O(#children). Also, if we decide that the first child being dirty means the line box is dirty, then we don't even need to find the line box in this case; we'll just hit it up when we scan for dirty lines during reflow
> starts looking like O(N^2)?

At the moment, correct.

> Do we have a bit free

I believe the answer is "no" last I checked... maybe something's changed since?
Keywords: perf
> Do we have a bit free that we can use to mark a frame 

Yes, we have 64 bits now.  Does that help?
(In reply to comment #4)
> > Do we have a bit free that we can use to mark a frame 
> 
> Yes, we have 64 bits now.  Does that help?

Judging from the comments here, it should.  Question is, is anyone up for knocking up a patch and see how it works?
Depends on: 682052
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.