Community
Participate
Working Groups
I discovered that our project API descriptions are unintentionally retaining all members (methods/fields) for all types. We don't persist them to disk, but we also don't need to retain them in memory unless they have an explicit API description (restrictions). There is a bug in ProjectApiDescription.isInsertOnResolve(..) The code is: return elementDescriptor.getElementType() != IElementDescriptor.T_METHOD || elementDescriptor.getElementType() != IElementDescriptor.T_FIELD; And it *should* be: return elementDescriptor.getElementType() != IElementDescriptor.T_METHOD && elementDescriptor.getElementType() != IElementDescriptor.T_FIELD; In its current form it will always return true since an element descriptor cannot be both a field and method.
This should drastically reduce our memory footprint.
Created attachment 101789 [details] patch
Workspace with 33 projects - Clean & Full Build Before fix: Allocated HEAP: 512 After GC (retained): 242 13-14 sec no-op build After Fix: Allocated HEAP: 383 After GC (retained): 149 3 - 5 sec no-op build This seems to reduce the retained heap size by 93MB. As well, the no-op build of inserting a space into DebugPlugin is reduced from 13-14 secsonds to 3-5 seconds.
+1 from me :-)
Definitely +1
++1. Profiling the fix I found that: With the fix not in: the retained size of a clean build of 51 API projects was 33.5MB With the fix: the retained size of the same projects was 8.4MB
applied patch
verified
Two tests are failing with this change. org.eclipse.pde.api.tools.util.tests.ApiProfileManagerTests#testWPUpdateSourceMethodChanged() org.eclipse.pde.api.tools.util.tests.ApiProfileManagerTests#testWPUpdateSourceFieldChanged()
With this change we never insert a node for a method or a field even if the field or the method has restrictions. This is why the two tests are failing. We need to make sure that we persist the node only if it has restrictions, but we know that only once the parent node has been refreshed.
Forget what I said. Method and field restrictions are supposed to be inserted during the refresh of the type.
Created attachment 102146 [details] patch Patch against head. This patch decides to insert elements into the description based on whether the description is being written ("set") or read ("get"). When writing, we always insert nodes. When reading, we only insert nodes/parents that say true for "insertOnResolve". The difference is in the call to "findNode" - we pass in whether the operation is write vs. read (instead of trying to predict if all nodes in the path should be inserted). As well, I updated the "insertOnResolve" method for projects API descriptions to not insert inner types on resolve (we only need inner types with explicit descriptions to be inserted).
Please review everyone... also need to re-verify performance analysis.
+1. All tests are green. Michael, I let you do the profiling of this change.
+1 from me... I ran all tests this time :-) A no-op change in DebugPlugin with debug & jdt plug-ins in the workspace takes 2-3 seconds now (after the first build which takes longer).