Closed
Bug 92617
Opened 23 years ago
Closed 23 years ago
front-end cache for element factories in XML content sink
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
People
(Reporter: waterson, Unassigned)
Details
dp proposed doing a front-end cache in the XML content sink to avoid traffic to the component manager: r=waterson Suresh Duddi wrote: This patch eliminates 1500 calls to ContractID->CID and about 3000 string copies. About 1/2 sec savings our of 22secs startup. nsXMLContentSink: When a elementfactory is required from the namespace, instead of going from id->string->string->servicemanager, maintaining a map locally would save all the translation and hash table lookup. Patch maintains a weak ref to a service. I think that is ok but if this needs to be super super clean, then maybe those refs can be made owning and cleaned up on say shutdown-listener. dp ------------------------------------------------------------------------ Index: nsXMLContentSink.cpp =================================================================== RCS file: /cvsroot/mozilla/content/xml/document/src/nsXMLContentSink.cpp,v retrieving revision 1.166 diff -c -r1.166 nsXMLContentSink.cpp *** nsXMLContentSink.cpp 2001/07/25 07:50:57 1.166 --- nsXMLContentSink.cpp 2001/07/26 09:41:37 *************** *** 94,99 **** --- 94,102 ---- nsINameSpaceManager* nsXMLContentSink::gNameSpaceManager = nsnull; PRUint32 nsXMLContentSink::gRefCnt = 0; + nsXMLContentSink::ElementFactoryMap nsXMLContentSink::gElementFactoryMap[nsXMLContentSink::MAX_ELEMENTFACTORY_MAP]; + int nsXMLContentSink::gNElementFactoryMap = 0; + // XXX Open Issues: // 1) what's not allowed - We need to figure out which HTML tags // (prefixed with a HTML namespace qualifier) are explicitly not *************** *** 1849,1855 **** void nsXMLContentSink::GetElementFactory(PRInt32 aNameSpaceID, nsIElementFactory** aResult) { ! nsresult rv; nsAutoString nameSpace; gNameSpaceManager->GetNameSpaceURI(aNameSpaceID, nameSpace); --- 1852,1867 ---- void nsXMLContentSink::GetElementFactory(PRInt32 aNameSpaceID, nsIElementFactory** aResult) { ! // Check out mapping table. If it exists return. ! int i; ! for (i=0; i<gNElementFactoryMap; i++) { ! if (gElementFactoryMap[i].nameSpaceID == aNameSpaceID) { ! *aResult = gElementFactoryMap[i].factory; ! NS_IF_ADDREF(*aResult); ! return; ! } ! } ! nsAutoString nameSpace; gNameSpaceManager->GetNameSpaceURI(aNameSpaceID, nameSpace); *************** *** 1857,1864 **** contractID.AppendWithConversion(nameSpace); // Retrieve the appropriate factory. ! nsCOMPtr<nsIElementFactory> elementFactory(do_GetService(contractID, &rv)); *aResult = elementFactory; NS_IF_ADDREF(*aResult); } --- 1869,1887 ---- contractID.AppendWithConversion(nameSpace); // Retrieve the appropriate factory. ! nsCOMPtr<nsIElementFactory> elementFactory(do_GetService(contractID)); *aResult = elementFactory; NS_IF_ADDREF(*aResult); + + // Update our element factory mapping + if (gNElementFactoryMap < MAX_ELEMENTFACTORY_MAP) { + gElementFactoryMap[gNElementFactoryMap].nameSpaceID = aNameSpaceID; + // WEAK + // These are services and we are trusting these will be around + // upto the point of shutdown. Beyond that creation of XMLContentSink + // will fail or even getservice will fail. + gElementFactoryMap[gNElementFactoryMap].factory = elementFactory; + gNElementFactoryMap++; + } } Index: nsXMLContentSink.h =================================================================== RCS file: /cvsroot/mozilla/content/xml/document/src/nsXMLContentSink.h,v retrieving revision 1.47 diff -c -r1.47 nsXMLContentSink.h *** nsXMLContentSink.h 2001/07/04 19:35:23 1.47 --- nsXMLContentSink.h 2001/07/26 09:41:38 *************** *** 169,174 **** --- 169,182 ---- static nsINameSpaceManager* gNameSpaceManager; static PRUint32 gRefCnt; + static const int MAX_ELEMENTFACTORY_MAP = 8; + typedef struct { + PRInt32 nameSpaceID; + nsIElementFactory *factory; // WEAK + } ElementFactoryMap; + static ElementFactoryMap gElementFactoryMap[MAX_ELEMENTFACTORY_MAP]; + static int gNElementFactoryMap; + nsIDocument* mDocument; nsIURI* mDocumentURL; nsIURI* mDocumentBaseURL; // can be set via HTTP headers namespace-patch.txt Content-Type: text/plain Content-Encoding: 7bit
This is a dupe, and jst says he also has a fix... *** This bug has been marked as a duplicate of 91241 ***
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → DUPLICATE
verified dup.
Status: RESOLVED → VERIFIED
Updated•14 years ago
|
Assignee: waterson → nobody
Component: DOM: Abstract Schemas → DOM
OS: Windows NT → All
QA Contact: lchiang → general
Hardware: x86 → All
Assignee | ||
Updated•5 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•