Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 50559 Details for
Bug 157098
[hotbug_deferred] Repetitive file I/O by TLDCMDocumentManager$IncludeHelper.getContents() , caching solution provided, JSP validator slow due to repetitive parsing of fragments
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch with shared cache for included files
TLDCMDocumentManager.patch (text/plain), 6.10 KB, created by
Raj Mandayam
on 2006-09-20 10:29:21 EDT
(
hide
)
Description:
patch with shared cache for included files
Filename:
MIME Type:
Creator:
Raj Mandayam
Created:
2006-09-20 10:29:21 EDT
Size:
6.10 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jst.jsp.core >Index: src/org/eclipse/jst/jsp/core/internal/contentmodel/tld/TLDCMDocumentManager.java >=================================================================== >RCS file: /cvsroot/webtools/jst/components/jsp/plugins/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/tld/TLDCMDocumentManager.java,v >retrieving revision 1.26 >diff -u -r1.26 TLDCMDocumentManager.java >--- src/org/eclipse/jst/jsp/core/internal/contentmodel/tld/TLDCMDocumentManager.java 3 May 2006 07:48:55 -0000 1.26 >+++ src/org/eclipse/jst/jsp/core/internal/contentmodel/tld/TLDCMDocumentManager.java 20 Sep 2006 14:32:31 -0000 >@@ -22,6 +22,7 @@ > import java.lang.ref.WeakReference; > import java.util.ArrayList; > import java.util.HashMap; >+import java.util.HashSet; > import java.util.Hashtable; > import java.util.Iterator; > import java.util.List; >@@ -563,37 +564,69 @@ > } > > protected String getContents(IPath filePath) { >- StringBuffer s = new StringBuffer(); >+ >+ StringBuffer s = null; > IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFile(filePath); >+ > if (iFile != null && iFile.exists()) { >- String charset = detectCharset(iFile); >- InputStream contents = null; >- try { >- contents = iFile.getContents(); >- Reader reader = new InputStreamReader(contents, charset); >- char[] readBuffer = new char[2048]; >- int n = reader.read(readBuffer); >- while (n > 0) { >- s.append(readBuffer, 0, n); >- n = reader.read(readBuffer); >+ Object o = getIncludedFilesCache().get(filePath); >+ if(o != null){ >+ if(o instanceof IncludedFilesEntry){ >+ IncludedFilesEntry entry = (IncludedFilesEntry) o; >+ if(iFile.getModificationStamp() == entry.modificationStamp){ >+ s = entry.document; >+ entry.referenceCount++; >+ }//else will be taken care of if(s == null) >+ } else if(o instanceof WeakReference){ >+ IncludedFilesEntry entry = (IncludedFilesEntry) ((WeakReference) o).get(); >+ if(entry != null){ >+ if(iFile.getModificationStamp() == entry.modificationStamp){ >+ s = entry.document; >+ entry.referenceCount = 1; >+ getIncludedFilesCache().put(filePath, entry); >+ }//else will be taken care of if(s == null) >+ } > } > } >- catch (Exception e) { >- if (Debug.debugStructuredDocument) >- Logger.log(Logger.WARNING, "An exception occured while scanning " + filePath, e); //$NON-NLS-1$ >- } >- finally { >+ if(s == null){ >+ s = new StringBuffer(); >+ String charset = detectCharset(iFile); >+ InputStream contents = null; > try { >- if (contents != null) { >- contents.close(); >+ contents = iFile.getContents(); >+ Reader reader = new InputStreamReader(contents, charset); >+ char[] readBuffer = new char[2048]; >+ int n = reader.read(readBuffer); >+ while (n > 0) { >+ s.append(readBuffer, 0, n); >+ n = reader.read(readBuffer); > } > } > catch (Exception e) { >- // nothing to do >+ if (Debug.debugStructuredDocument) >+ Logger.log(Logger.WARNING, "An exception occured while scanning " + filePath, e); //$NON-NLS-1$ >+ } >+ finally { >+ try { >+ if (contents != null) { >+ contents.close(); >+ } >+ } >+ catch (Exception e) { >+ // nothing to do >+ } > } >+ IncludedFilesEntry entry = new IncludedFilesEntry(); >+ entry.document = s; >+ entry.referenceCount = 1; >+ entry.modificationStamp = iFile.getModificationStamp(); >+ getIncludedFilesCache().put(filePath, entry); >+ > } >+ getIncludedDocumentsKeys().add(filePath); > } > else { >+ s = new StringBuffer(); > int c = 0; > int length = 0; > int count = 0; >@@ -696,6 +729,12 @@ > CMDocument document; > int referenceCount; > } >+ >+ static class IncludedFilesEntry { >+ StringBuffer document; >+ int referenceCount; >+ long modificationStamp; >+ } > > private static class TLDCMDocumentDescriptor { > Object cacheKey; >@@ -718,6 +757,9 @@ > protected static List bannedPrefixes = null; > > private static Hashtable fCache = null; >+ >+ private static Hashtable fIncludedFilesCache = null; >+ > static final String XMLNS = "xmlns:"; //$NON-NLS-1$ > > static final int XMLNS_LENGTH = XMLNS.length(); >@@ -746,6 +788,19 @@ > return fCache; > } > >+ /** >+ * Gets all of the known included documents. >+ * >+ * @return Returns a Hashtable of either IncludedFileEntrys or WeakReferences >+ * to StringBuffers >+ */ >+ public static Hashtable getIncludedFilesCache() { >+ if (fIncludedFilesCache == null) { >+ fIncludedFilesCache = new Hashtable(); >+ } >+ return fIncludedFilesCache; >+ } >+ > > public static Object getUniqueIdentifier(ITaglibRecord reference) { > Object identifier = null; >@@ -786,6 +841,11 @@ > */ > private Hashtable fDocuments = null; > >+ /** >+ * The locally-know list of included documents keys >+ */ >+ private HashSet fIncludedDocuments = null; >+ > // timestamp cache to prevent excessive reparsing > // of included files > // IPath (filepath) > Long (modification stamp) >@@ -820,6 +880,20 @@ > } > } > } >+ >+ for (Iterator iter = getIncludedDocumentsKeys().iterator(); iter.hasNext();) { >+ Object key = iter.next(); >+ synchronized (getIncludedFilesCache()) { >+ Object o = getIncludedFilesCache().get(key); >+ if (o instanceof IncludedFilesEntry) { >+ IncludedFilesEntry entry = (IncludedFilesEntry) o; >+ entry.referenceCount--; >+ if (entry.referenceCount <= 0) { >+ getIncludedFilesCache().put(key, new WeakReference(entry)); >+ } >+ } >+ } >+ } > } > > /** >@@ -1003,6 +1077,17 @@ > } > > /** >+ * Gets the documents. >+ * >+ * @return Returns a java.util.Hashtable >+ */ >+ public HashSet getIncludedDocumentsKeys() { >+ if (fIncludedDocuments == null) >+ fIncludedDocuments = new HashSet(); >+ return fIncludedDocuments; >+ } >+ >+ /** > * Return the CMDocument at the tagdir (cached) > */ > protected CMDocument getImplicitCMDocument(String tagdir) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 157098
:
49985
|
50559
|
50582
|
50609
|
51835
|
51890
|
51895
|
51898
|
51999