Closed Bug 109129 Opened 23 years ago Closed 18 years ago

NS_NewAtom shouldn't flatten string to hash it

Categories

(Core :: XPCOM, defect, P2)

defect

Tracking

()

RESOLVED WORKSFORME
Future

People

(Reporter: dbaron, Assigned: dbaron)

Details

(Keywords: perf)

NS_NewAtom currently flattens a string to hash it. We need a hash function that takes an nsAString& so we don't need to allocate. (This seems to be responsible for about 2000 allocations on startup.)
Status: NEW → ASSIGNED
Priority: -- → P2
Target Milestone: --- → mozilla0.9.7
FWIW, the allocation sites are: 2033 operator new(unsigned long, const std::nothrow_t&) operator new(unsigned long) NS_AllocateContiguousHandleWithData ... nsSharableString::assign(const nsAString&) nsPromiseFlatString::nsPromiseFlatString(const nsAString&) PromiseFlatString(const nsAString&) GetAtomHashEntry(const nsAString&) NS_NewAtom(const nsAString&) nsXMLContentSink::SplitXMLName(const nsAString&, nsIAtom**, ... nsXMLContentSink::AddAttributes(const nsIParserNode&, ... nsXMLContentSink::OpenContainer(const nsIParserNode&) 648 operator new(unsigned long, const std::nothrow_t&) operator new(unsigned long) NS_AllocateContiguousHandleWithData ... nsSharableString::assign(const nsAString&) nsPromiseFlatString::nsPromiseFlatString(const nsAString&) PromiseFlatString(const nsAString&) GetAtomHashEntry(const nsAString&) NS_NewAtom(const nsAString&) nsXMLContentSink::SplitXMLName(const nsAString&, nsIAtom**, ... nsXMLContentSink::OpenContainer(const nsIParserNode&) 276 operator new(unsigned long, const std::nothrow_t&) operator new(unsigned long) NS_AllocateContiguousHandleWithData ... nsSharableString::assign(const nsAString&) nsPromiseFlatString::nsPromiseFlatString(const nsAString&) PromiseFlatString(const nsAString&) GetAtomHashEntry(const nsAString&) NS_NewAtom(const nsAString&) nsXMLContentSink::SplitXMLName(const nsAString&, nsIAtom**, ... nsXMLContentSink::AddAttributes(const nsIParserNode&, ... nsXMLContentSink::OpenContainer(const nsIParserNode&) 194 operator new(unsigned long, const std::nothrow_t&) operator new(unsigned long) NS_AllocateContiguousHandleWithData ... nsSharableString::assign(const nsAString&) nsPromiseFlatString::nsPromiseFlatString(const nsAString&) PromiseFlatString(const nsAString&) GetAtomHashEntry(const nsAString&) NS_NewAtom(const nsAString&) nsXMLContentSink::SplitXMLName(const nsAString&, nsIAtom**, ... nsXMLContentSink::AddAttributes(const nsIParserNode&, ... nsXMLContentSink::OpenContainer(const nsIParserNode&)
Target Milestone: mozilla0.9.7 → mozilla0.9.8
I never managed to think of a good approach to fixing this, given our hashtable interfaces.
Target Milestone: mozilla0.9.8 → Future
Keywords: perf
hrmm, is this still a problem, with the work alecf has been doing with atoms? I have a hashkey that uses nsAString, but it still has to allocate a copy of the string buffer, because we're not using sharable strings.
well, I'll bet its still a problem - I think that everywhere that I changed to permanent atoms had flat strings already.. so those call sites are probably slightly different, but still applicable...
QA Contact: scc → xpcom
No longer relevant with our new string code.
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.