string optimization in HTMLContentSink::AddAttributes

RESOLVED FIXED

Status

()

Core
Layout
RESOLVED FIXED
14 years ago
14 years ago

People

(Reporter: Brian Ryner (not reading), Assigned: Brian Ryner (not reading))

Tracking

({perf})

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

14 years ago
Because of the way shared string buffers work, HTMLContentSink::AddAttributes
isn't quite optimal in the way it does an atom lookup for attribute names.  In
particular, calling ToLowerCase on the shared buffer heap-allocates a new
(mutable) buffer, then lowercases the string in-place, then the string is copied
again (while being converted to UTF-8) into a stack buffer when do_GetAtom is
called.  In addition to this, dealing with the shared buffer incurs overhead
from doing an atomic increment on the buffer reference count (which is silly
since we know we'll need a mutable buffer).

I have a patch which does the UTF-8 conversion (into a mutable buffer) up-front,
which gets rid of the heap allocation, extra string copy, and atomic increment
overhead.  It seems to give a Tp win of about 1%.
(Assignee)

Comment 1

14 years ago
Created attachment 149181 [details] [diff] [review]
patch
(Assignee)

Updated

14 years ago
Attachment #149181 - Flags: superreview?(bzbarsky)
Attachment #149181 - Flags: review?(bzbarsky)
Comment on attachment 149181 [details] [diff] [review]
patch

r+sr=bzbarsky; fix nsHTMLFragmentContentSink too, though?
Attachment #149181 - Flags: superreview?(bzbarsky)
Attachment #149181 - Flags: superreview+
Attachment #149181 - Flags: review?(bzbarsky)
Attachment #149181 - Flags: review+
(Assignee)

Comment 3

14 years ago
checked in.
Status: NEW → RESOLVED
Last Resolved: 14 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.