Closed
Bug 74906
Opened 24 years ago
Closed 23 years ago
CSSStyleRuleIMP::GetWeight/FindEndOfWeight called too much?
Categories
(Core :: CSS Parsing and Computation, defect, P3)
Core
CSS Parsing and Computation
Tracking
()
mozilla0.9.7
People
(Reporter: law, Assigned: pierre)
Details
This bug was generated from Quantify analysis I did a while back. Below is the
posting I made to netscape.public.mozilla.performance on 2/22/2001.
At issue is the apparently inordinate number of calls to the functions
CSSStyleRuleImpl::GetWeight and FindEndOfWeight (a static function in
nsCSSStyleRuleImpl.cpp). The latter is passed via a function pointer to
nsSupportsArray::EnumerateForwards. The static function simply converts the
call to an invocation of the GetWeight method.
While the functions in question are small and efficient, in total 4+% of the
time to open a new Navigator window is spent in these two functions (plus
nsSupportsArray::EnumerateForwards, called the vast majority of time in order
to call FindEndOfWeight).
I don't know exactly how these functions are being used but there might be an
opportunity to optimize this by using a cache of some sort, or some other
technique.
----------------netscape.public.mozilla.performance post-------------------
I did Quantify runs to gather stats on window opening. I measured opening a
new Navigator window and also opening an "empty" XUL window (stripped out
*everything*).
I sorted the two function lists by Function time to see how much of the former
was basic overhead of opening a window (as measured by the latter).
The most interesting thing was in regard to the functions FindEndOfWeight,
nsSupportsArray::EnumerateForwards, and CSSStyleRuleImpl::GetWeight.
In both cases, those 3 functions show up in the top 16 in total Function Time.
Here's the data:
function Nav Empty
rank Calls Ftime F% rank Calls Ftime F%
-----------------------------------------------------------
FindEndOfWeight 6 409350 18.10 2.11 2 35244 1.56 7.22
EnumerateForwards 7 5101 11.94 1.39 7 579 1.02 4.75
GetWeight 16 412241 7.47 0.87 9 35789 0.65 3.01
I thought this seemed like a relatively large amount of time to be spent in
these functions. The biggest issue seems to be the number of calls to the
FindEndOfWeight/GetWeight functions (the former is a static function passed by
pointer to nsSupportsArray::EnumerateForwards; it calls GetWeight.
In the case of the empty window, we also see the static function
InsertRuleByWeight (rank=~30,calls=555,Ftime=.05,F%=0.24%) but that doesn't
show up at all near the top in the case of the Navigator window.
It appears (to my untrained eye) that there might be an opportunity to do some
performance optimization in the style sheet rule setup/lookup code so that it
doesn't have to call these functions so many times.
This is even more surprising in the case of the empty window, because in that
case we're only using the "built-in" style sheets (none of the XUL/chrome ones).
It seems odd that nsSupportsArray::EnumerateForwards shows up here because it
is called only about 1/80th as often as those other two functions. That
function is pretty simple:
PRInt32 aIndex = -1;
PRBool running = PR_TRUE;
while (running && (++aIndex < (PRInt32)mCount)) {
running = (*aFunc)(mArray[aIndex], aData);
}
return running;
What is it about that code that puts this function's Ftime out of proportion to
the number of times it is called? Is "mArray[aIndex]" inlined?
Bill
Assignee | ||
Updated•23 years ago
|
Status: NEW → ASSIGNED
Priority: -- → P3
Target Milestone: --- → mozilla0.9.7
Assignee | ||
Comment 1•23 years ago
|
||
Fixed by dbaron in nsCSSStyleSheet.cpp v3.161 on Apr 27 for bug 77066.
The rules are now hashed by weight.
*** This bug has been marked as a duplicate of 77066 ***
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•