Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Poor Performance of Rename Refactoring (e.g. in bigger projects) #320

Closed
cdietrich opened this issue Aug 2, 2017 · 5 comments
Closed

Poor Performance of Rename Refactoring (e.g. in bigger projects) #320

cdietrich opened this issue Aug 2, 2017 · 5 comments

Comments

@cdietrich
Copy link
Member

cdietrich commented Aug 2, 2017

Rename refactoring performance is very poor, specially in big projects.

I had a look at the code and found basically two bottlenecks

(1) RefactoringCrossReferenceSerializer.getCrossRefText(EObject, CrossReference, EObject, RefTextEvaluator, ITextRegion, StatusWrapper) calls IScope.getElements(EObject)
(2) this basically maps to DirtyStateAwareResourceDescriptions.getExportedObjectsByType(EClass) and from there to AbstractCompoundSelectable.getExportedObjectsByType(EClass) with ResourceDescriptionsData as instance which then calls EObjectDescriptionLookUp.getExportedObjectsByType(EClass) which iterates over allDescriptions
=> we do a LOT of iterating
(3) during that iterating EObjectDescriptionImpl.getEObjectURI() is called a lot so we are affected by the appendFragment.trimfragment calculation in uri. i wonder if we could introduce there a cache like

	private URI normalizedURI;
	@Override
	protected void eBasicSetContainer(InternalEObject newContainer) {
		normalizedURI = null;
		super.eBasicSetContainer(newContainer);
	}

	@Override
	public URI getEObjectURI() {
		if (normalizedURI != null) {
			return normalizedURI;
		}
		EObject container = eContainer();
		if (container instanceof IResourceDescription) {
			URI result = ((IResourceDescription) container).getURI().appendFragment(getFragment());
			normalizedURI = result;
			return result;
		}
		return null;
	}
...
	public void setFragment(String newFragment) {
		normalizedURI = null;

(+ adaption of setFragment)

@cdietrich
Copy link
Member Author

reproducing example. problems occurs e.g. when renaming xtest2.mydsl to xtest2b.mydsl (F2)
refactoring-example.zip

@cdietrich
Copy link
Member Author

created #337 for the EObjectDescriptionImpl part since other parts like resourcestoragefacade are affected by this as well

@rytina
Copy link

rytina commented Apr 21, 2021

@cdietrich do you have an "rough" idea where the poor performance is coming from? I assume it is somehow related to the recording of changes within org.eclipse.xtext.ide.serializer.impl.ChangeSerializer.beginRecordChanges(Resource). What is again the reason for recoding the entire AST with node models?

@cdietrich
Copy link
Member Author

cdietrich commented Apr 21, 2021

No it's about the scope getElements call
Your question is not related this. have no idea what you observed

@cdietrich
Copy link
Member Author

Closed as wont-fix. Feel free to reopen at github.com/eclipse/xtext

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants