Closed Bug 90725 Opened 23 years ago Closed 3 years ago

Don't allocate space managers that won't be used

Categories

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

defect

Tracking

()

RESOLVED WORKSFORME
Future

People

(Reporter: bratell, Unassigned)

References

(Blocks 1 open bug, )

Details

(Keywords: perf, testcase)

In the table stress case, there is 10000 cells and each one of these allocate a nsSpaceManager during reflow. A nsSpaceManager that is never used. Comment from the code in nsBlockFrame::Reflow: 670 // XXXldb If we start storing the space manager in the frame rather 671 // than keeping it around only during reflow then we should create it 672 // only when there are actually floats to manage. Otherwise things 673 // like tables will gain significant bloat. That is about 2% (120ms) of the page load time and 200-300KB of memory space.
Blocks: 54542
Keywords: perf
Taking for now, although I may give it to waterson.
Assignee: karnaze → dbaron
Blocks: 86950
OS: Windows 2000 → All
Hardware: PC → All
Status: NEW → ASSIGNED
Priority: -- → P2
Target Milestone: --- → mozilla0.9.4
Target Milestone: mozilla0.9.4 → mozilla0.9.5
Depends on: 99691
Target Milestone: mozilla0.9.5 → mozilla0.9.6
Target Milestone: mozilla0.9.6 → mozilla0.9.7
Target Milestone: mozilla0.9.7 → mozilla0.9.8
Target Milestone: mozilla0.9.8 → mozilla0.9.9
Target Milestone: mozilla0.9.9 → Future
Keywords: testcase
Keywords: footprint
Keywords: footprint
Component: Layout → Layout: Block & Inline
Flags: blocking1.4?
Flags: blocking1.4? → blocking1.4-
QA Contact: chrispetersen → layout.block-and-inline
What's the progress on this bug? Is it WONTFIX? Should it be reassigned?
where might one find an archived version of http://www.mozilla.org/newlayout/testcases/stress/wbtblclr.html ?
Flags: needinfo?(kohei.yoshino)
Assignee: dbaron → nobody
Status: ASSIGNED → NEW

I don't think there's anything that's obviously worth-doing/worth-tracking here at this point.

The premise here seems to have been that we were wastefully allocating nsSpaceManager instances on this wbtblclr.html testcase and it was taking up a measurable amount of time (and memory). (Note that nsSpaceManager was renamed to nsFloatManager in bug 191448, in the time since this bug was filed.)

I just profiled Firefox continuously-reflowing wbtblclr.html, by running this in the web console:

for (let i = 0; i < 1000; i++) {
  document.documentElement.style.display = "none";
  document.documentElement.offsetTop; // flush layout
  document.documentElement.style.display = "";
  document.documentElement.offsetTop; // flush layout
}

I captured the profile after 130 seconds (while my above-quoted JS loop was still executing). There were 46326 samples with reflow in the backtrace, as shown here: https://share.firefox.dev/2ZpGHZn

Of those, only 98 samples ( 0.2% ) had "FloatManager" in the backtrace at all; they were all in nsFloatManager::GetFlowArea. No samples were captured in CreateFloatManager or in nsFloatManager's constructor/destructor. So, this allocation doesn't seem to be taking any measurable amount of time.

There's perhaps a case to be made that we should still avoid allocating these from a memory-savings perspective; but, given that these objects only exist temporarily during reflow (there's no persistent cost), I'm not especially concerned about memory-usage here, in the abstract at least. We also seem to have invariants in our codethat depend on always having these objects allocated (i.e. BlockReflowInput::FloatManager() is infallible), so it would probably require some nontrivial amount of invariant-reworking, additional checks, etc. if we wanted to become extremely-lazy about allocating these.

So, I think we can call this WORKSFORME at this point, since these allocations aren't occupying any measurable amount of CPU time, and given that there's no persistent memory-usage cost.

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.