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 104305 Details for
Bug 135906
CompilationUnitStructureRequestor.resolveDuplicates has bad performance
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix and performance test
135906.txt (text/plain), 4.72 KB, created by
Jerome Lanneluc
on 2008-06-10 09:11:11 EDT
(
hide
)
Description:
Proposed fix and performance test
Filename:
MIME Type:
Creator:
Jerome Lanneluc
Created:
2008-06-10 09:11:11 EDT
Size:
4.72 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.performance >Index: src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java,v >retrieving revision 1.39 >diff -u -r1.39 FullSourceWorkspaceModelTests.java >--- src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java 28 May 2008 00:00:21 -0000 1.39 >+++ src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java 10 Jun 2008 13:10:18 -0000 >@@ -760,6 +760,56 @@ > } > } > >+/* >+ * Ensures that the performance of reconcile on a CU with lots of duplicates is acceptable. >+ * (regression test for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=135906 ) >+ */ >+public void testReconcileDuplicates() throws JavaModelException { >+ tagAsSummary("Reconcile editor change on file with lots of duplicates", false); // do NOT put in fingerprint >+ >+ // build big file contents >+ StringBuffer contents = new StringBuffer(); >+ contents.append("public class CUWithDuplicates {\n"); >+ int fooIndex = 0; >+ while (fooIndex < 2000) { // add 2000 duplicate methods >+ contents.append(" void foo() {}\n"); >+ contents.append(fooIndex++); >+ } >+ contents.append("} //"); // ensure it ends with a line comment that is edited below >+ >+ ICompilationUnit workingCopy = null; >+ try { >+ // Setup >+ workingCopy = (ICompilationUnit) JavaCore.create(ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/BigProject/src/CUWithDuplicates.java"))); >+ workingCopy.becomeWorkingCopy(null); >+ >+ // Warm up >+ int warmup = WARMUP_COUNT / 10; >+ for (int i=0; i<warmup; i++) { >+ workingCopy.getBuffer().setContents(contents.append('a').toString()); >+ workingCopy.reconcile(AST.JLS3, false/*no pb detection*/, null/*no owner*/, null/*no progress*/); >+ } >+ >+ // Measures >+ resetCounters(); >+ for (int i=0; i<MEASURES_COUNT; i++) { >+ workingCopy.getBuffer().setContents(contents.append('a').toString()); >+ runGc(); >+ startMeasuring(); >+ workingCopy.reconcile(AST.JLS3, false/*no pb detection*/, null/*no owner*/, null/*no progress*/); >+ stopMeasuring(); >+ } >+ >+ // Commit >+ commitMeasurements(); >+ assertPerformance(); >+ >+ } finally { >+ if (workingCopy != null) >+ workingCopy.discardWorkingCopy(); >+ } >+} >+ > /** > * Ensures that the reconciler does nothing when the source > * to reconcile with is the same as the current contents. >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java,v >retrieving revision 1.80 >diff -u -r1.80 CompilationUnitStructureRequestor.java >--- model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java 27 May 2008 23:40:18 -0000 1.80 >+++ model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java 10 Jun 2008 13:10:21 -0000 >@@ -33,6 +33,7 @@ > import org.eclipse.jdt.internal.compiler.parser.Parser; > import org.eclipse.jdt.internal.compiler.parser.RecoveryScanner; > import org.eclipse.jdt.internal.compiler.util.HashtableOfObject; >+import org.eclipse.jdt.internal.compiler.util.HashtableOfObjectToInt; > import org.eclipse.jdt.internal.core.util.ReferenceInfoAdapter; > import org.eclipse.jdt.internal.core.util.Util; > >@@ -63,6 +64,11 @@ > * info objects. > */ > protected Map newElements; >+ >+ /* >+ * A table from a handle (with occurenceCount == 1) to the current occurence count for this handle >+ */ >+ private HashtableOfObjectToInt occurenceCounts; > > /** > * Stack of parent scope info objects. The info on the >@@ -115,6 +121,7 @@ > this.unit = unit; > this.unitInfo = unitInfo; > this.newElements = newElements; >+ this.occurenceCounts = new HashtableOfObjectToInt(); > } > /** > * @see ISourceElementRequestor >@@ -618,11 +625,15 @@ > } > /** > * Resolves duplicate handles by incrementing the occurrence count >- * of the handle being created until there is no conflict. >+ * of the handle being created. > */ > protected void resolveDuplicates(SourceRefElement handle) { >- while (this.newElements.containsKey(handle)) { >- handle.occurrenceCount++; >+ int occurenceCount = this.occurenceCounts.get(handle); >+ if (occurenceCount == -1) >+ this.occurenceCounts.put(handle, 1); >+ else { >+ this.occurenceCounts.put(handle, ++occurenceCount); >+ handle.occurrenceCount = occurenceCount; > } > } > protected IMemberValuePair getMemberValuePair(MemberValuePair memberValuePair) {
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 135906
: 104305