I don't have lot of memory (4Go), but it's enough to daily code in
java with several projects,... But it's hell when I work on scala
projects (including or.scala-ide.sdt.core), to be able to spawn/debug
eclipse plugin I limit my eclipse IDE to 1024m.
But I raise limit quick limit, I've got lot freeze,... so I started to
"profile" and search :
* from mat (MemoryAnalyzer) the 2 main leak are
ScalaPresentationCompiler and EclipseBuildManager
* with visualvm rapid analyse, I saw that freeze are due to lot of GC
activity - can 40% - 80% CPU.
I try to investigate into code. I replace the
ScalaPresenrtationCompiler cache
(mutable.HashMap[ScalaCompilationUnit, CachedCompilerResult]) (in some
analyze there is 128 entries) by I simplist tuple, and now my IDE play
yo-yo with memory (with high amplitude I win ~ 100 Mo) but currently I
no longer have high GC activity.
I don't know if it's the right solution, but I would like to add a
PreferencePage "plugin tuning" where we could store configuration
about some strategies, experimental solutions. In my case, I'll start
with something like a check box for "cache AST" that allow to use
HashMap or my simple store (code bellow) after restart. I also think
it will be the good place for other/future customization (like
statistics generation, ...).
WDYT ?
/davidB
-----8<-----------------------------------------------------------------------
private val results = new Object{
private var _kv : (ScalaCompilationUnit,CachedCompilerResult) = null
def apply(k : ScalaCompilationUnit) = {
val kv = _kv
if (kv == null || kv._1 != k) {
val v = new CachedCompilerResult(k)
_kv = (k, v)
v
} else {
kv._2
}
}
def get(k : ScalaCompilationUnit) = {
val kv = _kv
if (kv == null || kv._1 != k) {
None
} else {
Some(kv._2)
}
}
def remove(k : ScalaCompilationUnit) {
val kv = _kv
if (kv != null && kv._1 == k) {
_kv = null
}
}
def keysIterator = _kv match {
case null => Nil
case kv => List(kv._1)
}
def valuesIterator = _kv match {
case null => Nil
case kv => List(kv._2)
}
}
-----8<-----------------------------------------------------------------------
Currently , from my user experience point of view, performance are
better (less freeze), but it's probably because I have less and
shorter GC activity.
I have done a SoftReferenceCacheMap (SoftReference for value) in scala
2 years ago. I'll try to combine it with the cache for only the latest
entry (should not be removable, to avoid eviction and
recomputation,...) In fact I would like to use something like ehcache
to replace all those cache (and adjust strategy , size,... of thoses
cache).
@Martin, Michel
Thanks for feedbacks.
/davidB
PS: As I'm a newbee in Eclipse developement (and Scala-ide), have a
soft desktop ;-) (I bought a SSD HD to improve, not yet installed). I
need lot of time to investigate, try, experiment so more time to have
public effect.
I welcome every attempt at improving performance; I've now worked several
months with the Scala IDE and before that many years with Eclipse - and I
never had to restart Eclipse so much as now with the Scala plugin..
On Tuesday 13 July 2010 16:07:53 David Bernard wrote:
> -----8<--------------------------------------------------------------------
> --- private val results = new Object{
What type does results have now? Won't this lead to the same problems -- that
a structural type is created -- mentioned here: http://www.scala-
notes.org/2010/06/avoid-structural-types-when-pimping-libraries/ ? I'm not
sure how much it actually matters, but when we're already optimizing...
Cheers
Mirko
--
Mirko Stocker | m...@misto.ch
Work: http://ifs.hsr.ch | http://infoq.com
Personal: http://misto.ch | http://twitter.com/m_st
Eg when my eclipse start to freeze
1. I start a visualvm (could be download alone or use the one provide
in jdk 1.6.0_21)
2. I open the monitor of the eclipse process
3. I wait few second, take a screenshot (see attachment)
for gc and memory issue I also do a Heap dump (and save it for
postmordem analyze with VisualVM or Mat).
@Mirko
In my local wip_tuning branch I replace new Object{...} by named classe.
the link you provide seems to be invalid.
/davidB
or just the plugin jar
http://alchim31.net/scala-ide/update-wip_tuning/plugins/org.scala-ide.sdt.core_1.0.0.201007150057.jar
/davidB
updates includes :
* re-sync with last works on tycho-reorg branch
* replace home made SoftHashMap by a WeakSoftHashMap build with
google-collections MapMaker to cache/memoize result of Presentation
compilation
* (start) integrate StopWatch (form alex Boisvert) to count/mesure
some compilations (from builder and presentation)
by exemple on test project, writing : def foo() = "hhhh"[enter]
generate 10 compilation (I tried to call to code completion), with the
default configuration (If I understand right, JDT call completion
engine every 200ms if there is typing)
In this version, stopwatch are always enabled, to disable or to see
data collected open your browser (or eclipse internal browser) to
http://localhost:9999/
Note that as I require 2 additional plugins (stopwatch who is provide
by same update-site as scala-ide and google-collections provide by
orbit update (I hope you don't need to declare it)). tell me if you
have issue to install this version.
/davidB
I have Xmx set to 1g (my full eclipse.ini below, may be I've got some
misconfiguration). When I work on org.scala-ide.sdt.core my used
memory (is ~ 750MB from The eclipse indicator (enabled via Prefences >
General)).
If i go into an other scala enabled project then when eclipse "build
workspace" I've got more freeze And If I display visualvm I can see
increase of GC Activy (see screenshot) until full freeze (like Martin
Gamwell Dawids).
I also note some freeze due with usage of SyncVar, but as I explain,
they could be reduced (in quantity) by reducing call to
ScalaCompletionEngine (call too frequencly and generate unsuable AST
for code completion suggestion, eg : (in sample pipe char is use to
mark caret position)
"bablbla".| <-- some code suggestion proposed
"bablbla".to| <-- no code suggestion
"bablbla".|to <-- no code suggestion (I expect to have as first case)
)
On the WIP_Tuning page I start listing proposal, idea to improve,...
I thinks we (developpers and users) could start a page on User
Documentation part about some "eclipse tuning suggestion" about
performance, usage,... (with preferences configuration or usefull
complementary plugins to install)
DISCLAIMER : I'm not a optimization and profiling expert
~~~~~~
-startup
plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.0.200.v20090519
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
384m
-vmargs
-server
-XX:PermSize=256m
-XX:MaxPermSize=384m
-Xss2m
-Xms512m
-Xmx1g
-XX:MaxGCPauseMillis=10
-XX:+ScavengeBeforeFullGC
-XX:-UseParallelOldGC
-Duser.name=david.bernard
-Dosgi.requireJavaVersion=1.5
-XX:+HeapDumpOnOutOfMemoryError
-XX:+CMSClassUnloadingEnabled
#-Xms256m
#-Xmx1024m
#-Xss1m
#-server
#-XX:+UseConcMarkSweepGC
~~~~~
This looks promising, but could you confirm that the map is completed
for *all* the source file passed in, if there is an error in one of
them?
If there aren't any problems, then please go ahead and push this to
the tycho-reorg branch.
Many thanks :-)
Cheers,
Miles
--
Miles Sabin
tel: +44 7813 944 528
gtalk: mi...@milessabin.com
skype: milessabin
http://www.chuusai.com/
http://twitter.com/milessabin
Right, this is why the files are parsed individually currently ... we
don't want to require continuous cleaning.
If you can come up with some mechanism for batching the files which
accommodates failures (ie. retrying with the failing file excluded)
and that mechanism still shows a significant speedup then that would
be well worth having :-)
> @all: I've noticed that the presentation compiler is destroyed and
> completely reinitialized *every* time a scala source file is saved
> (call chain below)
> ScalaSourceFileEditor.doSave ->
> ScalaProject.scheduleResetPresentationCompiler -> etc.
>
> I think that this pessimistic treatment of the PresentationCompiler
> (i.e. a complete reinitialization for each file save) is a possible
> source for the performance bottleneck.
Unfortunately it's necessary as a workaround for bugs in the
presentation compiler ... it's unable to cope with changes in the set
of top-level types. See,
http://scala-ide.assembla.com/spaces/scala-ide/tickets/2689
for example ... there are other related bugs which the presentation
compiler reset addresses.
> Furthermore, in this area might occur also some memory leaks (e.g.
> objects of CompilerResultHolder that continue to hang around after the
> presentation compiler is destroyed).
Those should be invalidated fairly promptly ... can you point me at a
case where that doesn't happen?
Cheers,
Miles
--
Miles Sabin
tel: +44 7813 944 528
gtalk: mi...@milessabin.com