Closed Bug 263581 Opened 21 years ago Closed 20 years ago

[FIX]Improve WrappedLinesAreDirty() code

Categories

(Core :: Layout, defect, P2)

x86
Linux
defect

Tracking

()

RESOLVED FIXED
mozilla1.8alpha6

People

(Reporter: bzbarsky, Assigned: bzbarsky)

Details

(Keywords: perf)

Attachments

(1 file, 1 obsolete file)

I had a patch to improve this in my tree based on some profile I did sometime, and I just remembered it today (CVS conflicts can be useful, sometimes). Then I noticed we had an XXX comment about this code, even.
Attached patch Patch (obsolete) — Splinter Review
Comment on attachment 161546 [details] [diff] [review] Patch The basic idea is to replace the "If this line is not dirty and has a dirty continuation, dirty it" algorithm (which is indeed O(N^2)), with an "If this line is not dirty and has a dirty continuation, dirty all the lines from here to the continuation". This should be O(N), since only two passes will be made on the lines involved, instead of one pass per line up to the dirty continuation. I'm not completely happy with DirtyLineIfWrappedLinesAreDirty as a function name, but couldn't think of a better one.
Attachment #161546 - Flags: superreview?(dbaron)
Attachment #161546 - Flags: review?(dbaron)
Keywords: perf
Priority: -- → P2
Summary: Improve WrappedLinesAreDirty() code → [FIX]Improve WrappedLinesAreDirty() code
Target Milestone: --- → mozilla1.8alpha5
Might this have an impact on bug 142969 ?
No idea. That bug has a lot of discussion about not much, with no profile data to back it up.
Comment on attachment 161546 [details] [diff] [review] Patch r+sr=dbaron, although I'm not sure the logic here makes sense (why only the continuations before what's currently marked dirty?) -- but it's equivalent to the old code. It might be worth a comment at the call site of the new function with a one line description of what that call does.
Attachment #161546 - Flags: superreview?(dbaron)
Attachment #161546 - Flags: superreview+
Attachment #161546 - Flags: review?(dbaron)
Attachment #161546 - Flags: review+
> why only the continuations before what's currently marked dirty? I suppose we could look forward to the _last_ dirty continuation we have and dirty everything in between... I wasn't quite sure where in reflow to hook that up, to be truthful. The current code will still fail for the case when all lines following the line in question are clean (so it'll be O(N^2) in the number of lines between the last dirty line and the end of the block). Would it be OK to pre-dirty all lines with dirty continuations before we enter the reflow loop? Or can continuations become dirty while we're in the loop? I'd be happy to do a followup patch to make this better yet, if someone can answer those questions...
Target Milestone: mozilla1.8alpha5 → mozilla1.8alpha6
> Would it be OK to pre-dirty all lines with dirty continuations before we enter > the reflow loop? Or can continuations become dirty while we're in the loop? The current line can become dirty inside the loop, but future lines cannot, so it wouldn't affect the behaviour of your function. I think it would be safe to handle this situation by traversing the lines backwards in a single pass before entering the loop.
Attachment #161546 - Attachment is obsolete: true
Comment on attachment 166996 [details] [diff] [review] Do it all outside the loop So like so?
Attachment #166996 - Flags: superreview?(roc)
Attachment #166996 - Flags: review?(roc)
Comment on attachment 166996 [details] [diff] [review] Do it all outside the loop Yeah, except that you need to process the first line too
Comment on attachment 166996 [details] [diff] [review] Do it all outside the loop oops, you do
Attachment #166996 - Flags: superreview?(roc)
Attachment #166996 - Flags: superreview+
Attachment #166996 - Flags: review?(roc)
Attachment #166996 - Flags: review+
Checked in followup patch too. It seemed to help Tp on btek some...
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Product: Core → Core Graveyard
Component: Layout: Misc Code → Layout
Product: Core Graveyard → Core
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: