Community
Participate
Working Groups
ResourceStateFactory uses string concatenation which results in unneeded memory allocation. During a refresh of a big workspace with ~ 100_000 file this showed up as a memory allocation hot spot. No measurement in time units could be done since it is only affects garbage collection time. However JDK Mission Control stated that this single line allocated (i.e. wasted) ~ 500 MB. Proposed improvement would eliminate that memory allocation at all: https://git.eclipse.org/r/c/egit/egit/+/175831 I found no other places in the egit source where the same optimisation could be applied too.
Created attachment 285455 [details] Screenshot of JDK Mission Control showing Stacktrace
callstack of top byte[] allocations by JDK MC was: byte[] java.util.Arrays.copyOfRange(byte[], int, int) 159 String java.lang.StringLatin1.newString(byte[], int, int) 159 String java.lang.StringBuilder.toString() 98 boolean org.eclipse.egit.ui.internal.resources.ResourceStateFactory.containsPrefixPath(Set, String) 71 IResourceState org.eclipse.egit.ui.internal.resources.ResourceStateFactory.extractContainerProperties(IndexDiffData, String, ResourceStateFactory$FileSystemItem) 71 IPath org.eclipse.core.internal.watson.ElementTreeIterator.requestPath() 19 String java.util.regex.Matcher.replaceAll(String) 4 PDEClasspathContainer$Rule org.eclipse.pde.internal.core.RequiredPluginsClasspathContainer.getRule(StateHelper, BundleDescription, ExportPackageDescription) 2 String org.eclipse.jface.viewers.StyledString.getString() 1 String org.eclipse.osgi.util.NLS.internalBind(String, Object[], String, String) 1 String java.lang.String.substring(int, int) 61 void java.lang.AbstractStringBuilder.<init>(int) 92 void java.lang.StringBuilder.<init>(String) 64 boolean org.eclipse.egit.ui.internal.resources.ResourceStateFactory.containsPrefixPath(Set, String) 62 IResourceState org.eclipse.egit.ui.internal.resources.ResourceStateFactory.extractContainerProperties(IndexDiffData, String, ResourceStateFactory$FileSystemItem) 61 IResourceState org.eclipse.egit.ui.internal.resources.ResourceStateFactory.get(IndexDiffData, ResourceStateFactory$FileSystemItem) 61 IResourceState org.eclipse.egit.ui.internal.resources.ResourceStateFactory.get(IndexDiffData, IResource) 61 void org.eclipse.egit.ui.internal.decorators.DecoratableResourceAdapter.<init>(IndexDiffData, IResource) 61 void org.eclipse.egit.ui.internal.decorators.GitLightweightDecorator.decorateResource(IResource, IDecoration) 61 void org.eclipse.egit.ui.internal.decorators.GitLightweightDecorator.decorate(Object, IDecoration) 61
Gerrit change https://git.eclipse.org/r/c/egit/egit/+/175831 was merged to [master]. Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=fad06ba629a781d3d049044ce2c9c4df1b4a12e0
Thanks, Jörg!