Bug 233731 - Project API descriptions retain all members
Summary: Project API descriptions retain all members
Status: VERIFIED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: API Tools (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.4 RC3   Edit
Assignee: PDE API Tools Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2008-05-23 14:15 EDT by Darin Wright CLA
Modified: 2008-05-27 11:44 EDT (History)
3 users (show)

See Also:
darin.eclipse: review+
Michael_Rennie: review+
Olivier_Thomann: review+


Attachments
patch (1.08 KB, patch)
2008-05-23 14:16 EDT, Darin Wright CLA
no flags Details | Diff
patch (4.15 KB, patch)
2008-05-27 09:48 EDT, Darin Wright CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Wright CLA 2008-05-23 14:15:33 EDT
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.
Comment 1 Darin Wright CLA 2008-05-23 14:16:03 EDT
This should drastically reduce our memory footprint.
Comment 2 Darin Wright CLA 2008-05-23 14:16:54 EDT
Created attachment 101789 [details]
patch
Comment 3 Darin Wright CLA 2008-05-23 14:45:19 EDT
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.
Comment 4 Darin Wright CLA 2008-05-23 14:46:24 EDT
+1 from me :-)
Comment 5 Olivier Thomann CLA 2008-05-23 17:26:52 EDT
Definitely +1
Comment 6 Michael Rennie CLA 2008-05-26 11:28:41 EDT
++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
Comment 7 Michael Rennie CLA 2008-05-26 11:35:42 EDT
applied patch
Comment 8 Michael Rennie CLA 2008-05-26 11:36:18 EDT
verified
Comment 9 Olivier Thomann CLA 2008-05-26 23:01:40 EDT
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()
Comment 10 Olivier Thomann CLA 2008-05-26 23:37:28 EDT
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.
Comment 11 Olivier Thomann CLA 2008-05-26 23:56:32 EDT
Forget what I said. Method and field restrictions are supposed to be inserted during the refresh of the type.
Comment 12 Darin Wright CLA 2008-05-27 09:48:59 EDT
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).
Comment 13 Darin Wright CLA 2008-05-27 09:49:45 EDT
Please review everyone... also need to re-verify performance analysis.
Comment 14 Olivier Thomann CLA 2008-05-27 10:58:19 EDT
+1. All tests are green.
Michael, I let you do the profiling of this change.
Comment 15 Darin Wright CLA 2008-05-27 11:01:42 EDT
+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).
Comment 16 Michael Rennie CLA 2008-05-27 11:44:19 EDT
applied patch
Comment 17 Michael Rennie CLA 2008-05-27 11:44:44 EDT
verified