[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [Dltk-dev] profiling stuff..
|
Johan,
Could you please profile with the attached code?
Regards,
Alex
Johan Compagner wrote:
no didnt help
The hotspot just moved to a different location:
LocalEnvironmentProvider.getProjectEnvironment(IProject project)
do we really need to do exists() there? because project.isAccessible()
already says that it has a resource and that exists
or do you really have to know that it is a file?
if i make from this:
if (project.isAccessible()) {
IPath location = project.getLocation();
if (location != null) {
File file = new
File(location.makeAbsolute().toOSString());
if (file.exists()) {
return LocalEnvironment.getInstance();
}
}
}
return null;
this:
if (project.isAccessible()) {
return LocalEnvironment.getInstance();
}
return null;
it is about 10 times faster, the hotspot of 3.2 seconds i gone.
I guess this is the wrong fix. But somehow we need to cache that or
dont call that code that often.
johan
On Thu, May 29, 2008 at 4:49 PM, Andrei Sobolev
<andrei.sobolev@xxxxxxxxx <mailto:andrei.sobolev@xxxxxxxxx>> wrote:
Hi Johan,
I've updated this stuff today.
It should work without slowdown now.
I've committed this code to HEAD in about 3 hours ago. So please
update.
Best regards,
Andrei Sobolev.
----- Original Message -----
From: "Johan Compagner" <jcompagner@xxxxxxxxx
<mailto:jcompagner@xxxxxxxxx>>
To: "DLTK Developer list" <dltk-dev@xxxxxxxxxxx
<mailto:dltk-dev@xxxxxxxxxxx>>
Sent: Thursday, May 29, 2008 9:30:25 PM GMT +06:00 Almaty, Novosibirsk
Subject: [Dltk-dev] profiling stuff..
Hi,
I am profiling some stuff because saving bit javascript files are
really slow for us
Now i am seeing for example this as a hotspot:
LocalEnvironment:
public boolean hasProject(IProject project) {
if (project.isAccessible()) {
IPath location = project.getLocation();
if (location != null) {
File file = new File(location.makeAbsolute().toOSString());
if (file.exists()) {
return true;
}
}
}
return false;
}
and then the file.exists() call.
This is by itself not really slow of course
But by parsing the JS files many ModelElements (subclasses) are
created
and that has an equal method:
public boolean equals(Object o) {
if (this == o)
return true;
IEnvironment environment = EnvironmentManager.getEnvironment(this);
if (o instanceof IModelElement && environment != null) {
IEnvironment environmento = EnvironmentManager
.getEnvironment((IModelElement) o);
if (!environment.equals(environmento)) {
return false;
}
}
that is called a lot.. so that getEnviroment() is hit many many times.
If for example i quickly do in hasProject() just return true..
Then i gain 3 seconds! for 1 save of a js file.
But i dont know where to do stuff. Where can we cache stuff or do
we really need that exists() call
johan
_______________________________________________
dltk-dev mailing list
dltk-dev@xxxxxxxxxxx <mailto:dltk-dev@xxxxxxxxxxx>
https://dev.eclipse.org/mailman/listinfo/dltk-dev
_______________________________________________
dltk-dev mailing list
dltk-dev@xxxxxxxxxxx <mailto:dltk-dev@xxxxxxxxxxx>
https://dev.eclipse.org/mailman/listinfo/dltk-dev
------------------------------------------------------------------------
_______________________________________________
dltk-dev mailing list
dltk-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dltk-dev
### Eclipse Workspace Patch 1.0
#P org.eclipse.dltk.core
Index: model/org/eclipse/dltk/internal/core/ModelElement.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.dltk/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ModelElement.java,v
retrieving revision 1.9
diff -u -r1.9 ModelElement.java
--- model/org/eclipse/dltk/internal/core/ModelElement.java 6 May 2008 06:25:43 -0000 1.9
+++ model/org/eclipse/dltk/internal/core/ModelElement.java 29 May 2008 16:04:07 -0000
@@ -12,6 +12,7 @@
import java.util.ArrayList;
import java.util.HashMap;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -262,14 +263,8 @@
if (this == o)
return true;
-
- IEnvironment environment = EnvironmentManager.getEnvironment(this);
- if (o instanceof IModelElement && environment != null) {
- IEnvironment environmento = EnvironmentManager
- .getEnvironment((IModelElement) o);
- if (!environment.equals(environmento)) {
- return false;
- }
+ if (!compareEnvironment(this, (IModelElement)o)) {
+ return false;
}
// model parent is null
@@ -281,6 +276,40 @@
return getElementName().equals(other.getElementName())
&& this.parent.equals(other.parent);
}
+
+ private static boolean compareEnvironment(IModelElement a, IModelElement b) {
+ final IScriptProject spA = a.getScriptProject();
+ if (spA == null) {
+ return false;
+ }
+ final IScriptProject spB = b.getScriptProject();
+ if (spB == null) {
+ return false;
+ }
+ if (spA == spB) {
+ return true;
+ }
+ final IProject pA = spA.getProject();
+ if (pA == null) {
+ return false;
+ }
+ final IProject pB = spB.getProject();
+ if (pB == null) {
+ return false;
+ }
+ if (pA == pB) {
+ return true;
+ }
+ final IEnvironment eA = EnvironmentManager.getEnvironment(pA);
+ if (eA == null) {
+ return false;
+ }
+ final IEnvironment eB = EnvironmentManager.getEnvironment(pB);
+ if (eB == null) {
+ return false;
+ }
+ return eA.equals(eB);
+ }
/**
* Returns the hash code for this model element. By default, the hash code