Closed Bug 166450 Opened 22 years ago Closed 3 years ago

Lots of Clone()ing in nsMappedAttributes

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED INACTIVE

People

(Reporter: bzbarsky, Assigned: sicking)

References

Details

(Keywords: memory-footprint, perf)

Attachments

(1 file, 1 obsolete file)

nsHTMLAttributes::EnsureSingleMappedFor ensures uniqueness by calling Clone() on
the mMapped object.  In the case when mMapped is already unique (has an
mUseCount of "1"), this is a waste of cycles and memory (memory because it
bloats the ruletree, see bug 117316).

It's simple enough to fix things not to clone unless needed here, but I need to
investigate whether we then need to clear out style data the way inline style
rules do.....
Blocks: 117316
Keywords: footprint, perf
Attached patch something to play with (obsolete) — Splinter Review
Comment on attachment 97683 [details] [diff] [review]
something to play with

Well, this makes us crash in the nsHTMLStyleSheet destructor when leaving
pages.. so something is amiss.	;)
Attachment #97683 - Attachment is obsolete: true
This no longer crashes because now we take ourselves out of the hash before
changing out hashkey.  But the code in question is disabled because, as the
comments say, we have to massage the ruletree if we do this.  I'm starting to
think that this change may not be worth it...
With the move toward nsIStyleRule immutability, we really do need the cloning, I
think.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → WONTFIX
We can at least avoid Clone()-ing the maps during parsing since they won't be
used as nsIStyleRules until the element is fully parsed.

Reopening this to investigate that possiblity. My plan is to not give the
attribute-map a stylesheet until after the element is fully parsed. I'm not sure
how to do that yet though.

Another thing that would be good to do is to try to get an existing map with the
correct values if one already exists. Especially the senario of having a large
number of elements with only one mapped attribute might be common (say 100 <font
size="1"> elements). In that case we should be able to just grab the existing
map right away rather then creating our own and then throw it away.

Status: RESOLVED → REOPENED
Depends on: attrs
Resolution: WONTFIX → ---
Ooh.  That last idea is a good one.

sicking, wanna take this one?
sure
Assignee: bz-vacation → bugmail
Status: REOPENED → NEW
Ideally i would like to use the fact that mDocument is not set as a qualifier to
when we don't need to worry about cloning the attribute-map. However that
doesn't work during parsing since mDocument is in fact set even though the
element isn't in the document yet.

So my idea was to use the fact that mParent isn't set during parsing as
qualifier. I.e. test for (!mDocument || !mParent). However that will fubar the
root element since that never gets it's parent set.

However we could possibly make an exception for the root element by testing
(!mDocument || (!mParent && mDocument->GetRootContent() != this)). This would
circumvent the optimization entierly on the root element during parsing.


Hmm.. i think.. or isn't the root content set while we parse the root contents
attributes? If so we could maybe change that.
Are we trying to do this in the very near term, or should I try to resurrect my
BindToTree() patch so mDocument will _not_ be set on an element that's still
being parsed?
This isn't very near term. Don't let this bug affect the BindToTree() patch, I'm
pretty sure that i can work with the currect state of affiars, but if i could
rely on mDocument then that'd be even better.
nsHTMLAttributes is gone.
Summary: Lots of Clone()ing in nsHTMLAttributes → Lots of Clone()ing in nsMappedAttributes
The same code now lives in nsMappedAttributes/nsAttrAndChildArray
Component: DOM: Core → DOM: Core & HTML
QA Contact: stummala → general
Status: NEW → RESOLVED
Closed: 21 years ago3 years ago
Resolution: --- → INACTIVE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: