Open Bug 1306705 Opened 10 years ago Updated 3 years ago

[css-grid] Optimize rebuilding grid items array in fragmentation path

Categories

(Core :: Layout: Grid, defect, P3)

defect

Tracking

()

Tracking Status
firefox52 --- affected

People

(Reporter: MatsPalmgren_bugz, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: perf)

Spawned off from bug 1151204 comment 36: > > + for (; !iter->AtEnd(); iter->Next()) { > > + auto child = **iter; > > + for (const auto& info : gridReflowInput.mGridItems) { > > + if (info.mFrame == child) { > > + gridItems->AppendElement(info); > > Could you explain this loop? It looks like it's doing a double nested > iteration over our grid items (For each item, we walk across > gridReflowInput.mGridItems)... Why? Because the child frame list would now be out-of-sync with mGridItems if we pushed an item. So there is no longer a relation between the child list and the mGridItems array, so we're rebuilding a new array here. > Isn't this nested loop going to be > O(n^2) in the number of items, and (if so) can we avoid that? O(n^2) in the number of items *in this fragment*, yes. I don't see any immediate solution to this problem though. It's similar to bug 1252186. Is it OK if I add file a follow-up bug for this performance problem too? (like bug 1252186 it only occurs in fragmentainers)
See Also: → 1252186
> O(n^2) in the number of items *in this fragment*, yes. Also, we currently only do it for at most two fragments, the ones with the first/last tracks in the fragmentation axis. But that might change... It might be possible to avoid it completely when the reflow is COMPLETE? (since no children should've been pushed in that case)
Severity: minor → S4
Component: Layout → Layout: Grid
You need to log in before you can comment on or make changes to this bug.