Closed
Bug 48855
Opened 24 years ago
Closed 24 years ago
nsAVLTree is a loser way to lookup static names
Categories
(Core :: DOM: HTML Parser, defect, P3)
Core
DOM: HTML Parser
Tracking
()
VERIFIED
FIXED
People
(Reporter: jband_mozilla, Assigned: jband_mozilla)
Details
(Keywords: memory-footprint, perf, Whiteboard: [nsbeta3+])
Attachments
(2 files)
58.11 KB,
patch
|
Details | Diff | Splinter Review | |
16.19 KB,
patch
|
Details | Diff | Splinter Review |
nsAVLTree is used in:
/gfx/src/nsColorNames.cpp
/htmlparser/src/nsHTMLEntities.cpp
/htmlparser/src/nsHTMLTags.cpp
/layout/html/style/src/nsCSSKeywords.cpp
/layout/html/style/src/nsCSSProps.cpp
/layout/mathml/content/src/nsMathMLOperators.cpp
The comparitors do 43,000 case insensitive string compares before the browser
window shows! Because of bug 48853 this included 43,000 calls to strlen too -
even though both strings being compared where in nsCStrings.
Of those 43,000 calls about 20,000 were in nsCSSKeywords and represented *only*
2,000 lookups. Clearly a hashtable is a better way to do these lookups.
I have a nsHashtable wrapper class to fix this problem. It makes the compares
case insensitive by requiring (and asserting) that the static table contain only
lowercase and then does *one* call to lowercase a copy of the string being
looked up - rather than deal with the possible case mismatch in each of multipe
compares like the nsAVLTree scheme.
I also have a change to the nsCStringKey code to allow for keys added to the
table that don't own the string buffer. This will allow us to not make a copy of
the strings in the static table. This saves about 25k for nsCSSKeywords alone.
This is a bigger win than it would have been since these classes where using
nsCAutoString in their heap allocated structs and thue wasting even more space.
I'll finish making this general and fix the various uses and attach a patch for
review before checking it in.
Assignee | ||
Updated•24 years ago
|
Updated•24 years ago
|
Whiteboard: [nsbeta3+]
I was having some misgivings about this stuff due these duplicated strings.
What about using PLHashTable. I seem to have read somewhere that nsHashtable has
a certain drawback, and that PLHashTable should be preferred over nsHashTable.
Assignee | ||
Comment 3•24 years ago
|
||
nsHashtable is built on PLHashtable. The string key scheme in nsHashtable was
suboptimal. warren improved it.
Assignee | ||
Comment 4•24 years ago
|
||
Assignee | ||
Comment 5•24 years ago
|
||
Attached patch to use nsStaticNameTable instead of nsAVLTree.
This gives about 10% speed up in CSSParserImpl::Parse as mesured in Quantify on
NT.
The patch looks big because I had to add a field to some tables so that string
sharing would work.
I decided to not mess with nsHTMLEntities.cpp because it different enough from
the other cases to require more customized code. And I left
nsMathMLOperators.cpp alone too.
I'll try to round up reviewers.
Comment 6•24 years ago
|
||
I think nsHashtables are very comparable to PLHashtables now.
Assignee | ||
Comment 7•24 years ago
|
||
Assignee | ||
Comment 8•24 years ago
|
||
My fixes are in.
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Comment 10•24 years ago
|
||
I recently re-worked nsMathMLOperators as outlined here.
http://groups.google.com/groups?hl=en&lr=&group=netscape.public.mozilla.mathml&s
afe=off&ic=1&th=3a8c2e24a034123b&seekd=935108173#935108173
As a part of that work, I switched to a hashtable too.
Comment 11•23 years ago
|
||
Marking verified as per above developer comments.
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•