nsNthIndexCache::SiblingMatchesElement is slow or it is called too often

RESOLVED INVALID

Status

()

RESOLVED INVALID
3 years ago
4 months ago

People

(Reporter: smaug, Unassigned)

Tracking

36 Branch
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

3 years ago
I was profiling the cleopatra UI a bit, since opening the callstack tree (or what to call it) can effectively hang the whole browser.
In this particular profile 80% of cpu time is spent _in_ nsNthIndexCache::SiblingMatchesElement. Not under it, but inside that method.

Given that the method is very simple and inlined, perhaps the caller should be modified?
or cleopatra UI?
Component: Layout → CSS Parsing and Computation
Cleopatra does start chocking for certain profile size. Usually the default as such that it falls below that threshold but it might not depending on multiple factor. Is the Nth stuff the part that used to color even and odd rows? I'd be open to ways of improving cleopatra for these.
(Reporter)

Comment 2

3 years ago
So we end up going through the loop
http://mxr.mozilla.org/mozilla-central/source/layout/style/nsNthIndexCache.cpp?rev=ac426472ceec&mark=128-136#128
lots of times.
I _guess_ we clear some cache, then go through the loop, then something is added to the tree-view which
cleopatra uses and then we clear the cache again and start from the beginning... something like that.
I see the loop going through thousands of iterations (==siblings)


removing the following in tree.css seems to drop this case from the profiles.
.treeViewTreeInnerContainer>:nth-child(2n+1) {
  background-color: white;
}
.treeViewTreeInnerContainer>:nth-child(2n) {
  background-color: #f0f5ff;
}
The UI is still slow, but bottleneck is now more in reflow side.
(cleopatra should probably use some different kind of tree-view component. Something which works also with lots of rows - meaning that the data model would be kept separately and there would be only dom elements for as many entries as what can be visible in the view port at a time)
nsNthIndexCache is now dead.
Status: NEW → RESOLVED
Last Resolved: 4 months ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.