Bug 89281 - [performance] Editors keeping huge amount of resolved DOM ASTs
Summary: [performance] Editors keeping huge amount of resolved DOM ASTs
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: 3.1 M7   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2005-03-28 15:48 EST by Philipe Mulet CLA
Modified: 2005-04-13 10:53 EDT (History)
3 users (show)

See Also:


Attachments
Apply on HEAD (5.12 KB, patch)
2005-04-07 09:29 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Philipe Mulet CLA 2005-03-28 15:48:48 EST
Build 20050328

Looking at memory allocation under profiling tool, I got intrigued in seeing 107
live instances of compiler CompilationUnitDeclaration.
Checking incoming references, I realized these were kept by DOM AST instances,
which in turn were held by 107 open editors.

This is a huge waste of space, considering I only have a few active editors.
My inclination would be to kill all DOM ASTs as soon as an editor loses focus.
Comment 1 Dani Megert CLA 2005-03-29 03:17:11 EST
Can you provide the profiler output which shows who holds the references? We
only cache one AST over all windows. It would be interesting to see who holds on
to them.
Comment 2 Philipe Mulet CLA 2005-03-29 10:17:12 EST
Reassigning. After investigation, it seems the leak occurs DOM AST conversion
mechanism.

Investigating a fix. Basically, the conversion process keeps in cache all
alternate compiler AST&bindings requested during converted units.

Addressing this should avoid the leak in single DOM unit creation, and avoid
resolving alternate units in batch DOM unit creation case.
Comment 3 Philipe Mulet CLA 2005-04-05 04:38:08 EDT
Released support for the pipeline scenario in M6.
Left untouched the scenario for single unit resolution (used during
reconciliation) since forcing faulting the types in for all requested units (so
can cleanup afterwards) is inducing perf slow down.
Also, there are still references to cleaned units through the scope map of the
resolver.
Comment 4 Olivier Thomann CLA 2005-04-05 10:39:24 EDT
The only way to get rid of all scopes after the conversion is to resolve all
qualified type reference, qualified name reference and import references
immediately. Right now some binding resolution is done lazily, but this requires
the scopes to be available.
Comment 5 Olivier Thomann CLA 2005-04-05 23:43:50 EDT
For the reconciler, the cleanup needs to be done for the compilation unit
problem finder. The requested cus are not stored right now and this makes it
impossible to clean them up.
I suggest to store them and to iterate the collection at the end of the process
to resolve all bindings with failInTypes() and then clean them up.
Comment 6 Olivier Thomann CLA 2005-04-07 09:29:26 EDT
Created attachment 19646 [details]
Apply on HEAD

Using this patch, I can clean up requested units. I had to change the
registration of the units, because it is possible to find a path where the
collection was null.
Philippe, could you please have a look at the patch?
Comment 7 Olivier Thomann CLA 2005-04-12 15:14:56 EDT
Daniel, can the visitor used on the reconcile dom tree not visit each name?
Resolving each name is expensive and I don't believe this is useful for all names.
For example, if you have something like this:

import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;

import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.operation.IRunnableContext;

import org.eclipse.ui.PlatformUI;

import org.eclipse.jdt.core.search.IJavaSearchScope;

import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.JavaPlugin;
...

Each subpart of each import reference ends up being resolved. I don't think that
this is useful. This might require its own PR.
Comment 8 Dani Megert CLA 2005-04-13 04:38:19 EDT
Olivier, I do not understand your question. There are many clients of this
shared AST. Many different visitors are used to traverse it, there's not a
single "reconcile" AST visitor.
Comment 9 Olivier Thomann CLA 2005-04-13 09:29:01 EDT
Then I don't plan to change anything for the reconciling case.
Philippe, ok to close as WONTFIX?
Comment 10 Philipe Mulet CLA 2005-04-13 10:51:33 EDT
+1
Comment 11 Olivier Thomann CLA 2005-04-13 10:53:55 EDT
Close as WONTFIX.
There is no optimization that can be done in the reconcile case. The usage of
this DOM tree is dependant of the user's settings. Therefore we cannot force the
resolution of requested units in all cases.