Layout performanance on large text files.

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Layout performanance on large text files.

jonsmirl@gmail.com
I accidentally opened the Linux
file:///usr/share/mime-info/gnome-vfs.keys with Firefox 1.5. Opening
this file put Firefox in a loop for over ten minutes.

I suspect the loop is caused by trying to measure the length of 50K
lines of Unicode text in order to compute the width of the display.
You need the line width to set the horizontal scrollbar correctly. An
observation can be made that setting the horizontal scrollbar range
accurately is not a really high priority item compared to having the
browser UI continue to function.

I see that there is on-going work being done to the increment layout
algorithms. Does it make sense to lazy evaluate the true horizontal
width of the document? For example only compute the width when various
parts of the document first get displayed on the screen.

Of course if you hit a layout element that requires knowledge of the
true width you would be forced to compute the width for the whole
document. But the layout of lines of plain text does not require
knowledge of the width.

As comparison vi can open this file and jump to the last line
(displaying a line count) in under one second. All unicode fonts are
properly rendered (using Gnome Terminal).

Even if the width can't be lazy evaluated, it would be nice to do
layout on a lower priority thread that would leave the UI responsive
to requests to abort the layout.

--
Jon Smirl
[hidden email]

_______________________________________________
mozilla-layout mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-layout
Reply | Threaded
Open this post in threaded view
|

Re: Layout performanance on large text files.

Boris Zbarsky
Jon Smirl wrote:
> I suspect the loop is caused by trying to measure the length

Don't suspect.  Profile.  If you can attach the file in question, I can probably
profile it when I get back in about 3 weeks (if you haven't done it yourself by
then).

> in order to compute the width of the display.

Unlikely that this is the primary purpose.  More likely, the "problem" is that
plain text s just treated like HTML with a single <pre> block and the layout is
done via CSS, and with CSS you MUST lay out the whole document at once
(something I'm sure vi does not ever do).

> Even if the width can't be lazy evaluated, it would be nice to do
> layout on a lower priority thread that would leave the UI responsive
> to requests to abort the layout.

Layout and the UI are on the same thread.

-Boris
_______________________________________________
mozilla-layout mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-layout
Reply | Threaded
Open this post in threaded view
|

Re: Layout performanance on large text files.

jonsmirl@gmail.com
On 12/12/05, Boris Zbarsky <[hidden email]> wrote:
> Jon Smirl wrote:
> > I suspect the loop is caused by trying to measure the length
>
> Don't suspect.  Profile.  If you can attach the file in question, I can probably
> profile it when I get back in about 3 weeks (if you haven't done it yourself by
> then).

Do you have link to profiling instructions for Linux that work with Mozilla?

The file is 2MB, it is a standard part of every gnome distribution. It
is in the gnome-mime-data-2.4.2-1.rpm.
/usr/share/mime-info/gnome-vfs.keys
I can mail it to you.

I know that Mozilla is not an editor and I don't expect it to act like
one. But on the other hand a user shouldn't be able to click around
the files on their disk and lock moz up.

Is this a DOS vulnerability, can a remote site convince Moz to load a
file even if the site can't read it?

>
> > in order to compute the width of the display.
>
> Unlikely that this is the primary purpose.  More likely, the "problem" is that
> plain text s just treated like HTML with a single <pre> block and the layout is
> done via CSS, and with CSS you MUST lay out the whole document at once
> (something I'm sure vi does not ever do).
>
> > Even if the width can't be lazy evaluated, it would be nice to do
> > layout on a lower priority thread that would leave the UI responsive
> > to requests to abort the layout.
>
> Layout and the UI are on the same thread.
>
> -Boris
> _______________________________________________
> mozilla-layout mailing list
> [hidden email]
> http://mail.mozilla.org/listinfo/mozilla-layout
>


--
Jon Smirl
[hidden email]

_______________________________________________
mozilla-layout mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-layout
Reply | Threaded
Open this post in threaded view
|

Re: Layout performanance on large text files.

Boris Zbarsky
In reply to this post by Boris Zbarsky
Jon Smirl wrote:
> Do you have link to profiling instructions for Linux that work with Mozilla?

http://www.mozilla.org/performance/tools.html#profiling

jprof works quite well; you just have to compile it in.

> The file is 2MB, it is a standard part of every gnome distribution. It
> is in the gnome-mime-data-2.4.2-1.rpm.
> /usr/share/mime-info/gnome-vfs.keys

Mine's about 400KB, for what it's worth.

> I can mail it to you.

Please.  I'll look at it when I get back into town.

> I know that Mozilla is not an editor and I don't expect it to act like
> one. But on the other hand a user shouldn't be able to click around
> the files on their disk and lock moz up.

If you click around into /dev, you sure will lock up in some cases, and you
deserve it... ;)

But yeah, we have known issues with large text files (see bugzilla).

> Is this a DOS vulnerability, can a remote site convince Moz to load a
> file even if the site can't read it?

http: sites cannot link to file:, no.

-Boris
_______________________________________________
mozilla-layout mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-layout
Reply | Threaded
Open this post in threaded view
|

Re: Layout performanance on large text files.

jonsmirl@gmail.com
Good news, CVS head renders this file in 2 minutes compared to over
10+ minutes with Firefox 1.5. I believe this is because dbaron's
rendering rewrite is checked into the trunk now.

I attached the full profile but here's the highlights, 80% of the two
minutes is spent in
nsBlockFrame::DoRemoveFrame().

Total hit count: 13595
Count %Total  Function Name
10617   78.1     nsBlockFrame::DoRemoveFrame(nsIFrame*, int)

It all comes from this call stack

             11344 nsBlockFrame::RemoveFrame(nsIAtom*, nsIFrame*)
 28975 10617    11344 nsBlockFrame::DoRemoveFrame(nsIFrame*, int)
               323 nsContinuingTextFrame::Destroy(nsPresContext*)
               290 nsBlockFrame::TryAllLines(nsLineList_iterator*,
nsLineList_iterator*, int*)
               100 nsIFrame::Invalidate(nsRect const&, int) const
                 4 nsViewManager::UpdateView(nsIView*, nsRect const&,
unsigned int)
                 2 nsFrame::Destroy(nsPresContext*)
                 2 nsFrame::GetOffsetFromView(nsPoint&, nsIView**) const
                 2 nsBlockFrame::ClearLineCursor()
                 1 nsTableOuterFrame::Destroy(nsPresContext*)
                 1 nsLineBox::Destroy(nsIPresShell*)
                 1 nsLineBox::~nsLineBox()
                 1 PresShell::IsPaintingSuppressed(int*)

--
Jon Smirl
[hidden email]

jprof.html.bz2 (28K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Layout performanance on large text files.

Christian Biesinger
In reply to this post by Boris Zbarsky
Jon Smirl wrote:
> I believe this is because dbaron's
> rendering rewrite is checked into the trunk now.

It's not, though...
_______________________________________________
mozilla-layout mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-layout
Reply | Threaded
Open this post in threaded view
|

Re: Layout performanance on large text files.

Christian Biesinger
In reply to this post by Boris Zbarsky
Boris Zbarsky wrote:
> Layout and the UI are on the same thread.

Well, they are also the same thing really...
_______________________________________________
mozilla-layout mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-layout
Reply | Threaded
Open this post in threaded view
|

Re: Layout performanance on large text files.

Boris Zbarsky
In reply to this post by Boris Zbarsky
Jon filed bug 319930 [1] on this, in case people want to follow it.

-Boris

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=319930
_______________________________________________
mozilla-layout mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-layout