From 5c6c2c243c3ba8d4e54af448ef96ed0d8ced3e42 Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Thu, 16 Dec 2010 15:24:30 +0000 Subject: Added advanceGeneration for memory profiling, a... Added advanceGeneration for memory profiling, and resident-mode profile option. review by extempore. --- src/compiler/scala/tools/nsc/Global.scala | 6 ++++++ src/compiler/scala/tools/nsc/settings/ScalaSettings.scala | 1 + src/compiler/scala/tools/util/Profiling.scala | 7 +++++++ src/yourkit/scala/tools/util/YourkitProfiling.scala | 4 ++++ 4 files changed, 18 insertions(+) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 327de376c0..45fb691904 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -655,6 +655,12 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable /** To be initialized from firstPhase. */ private var terminalPhase: Phase = NoPhase + if (settings.YprofileRes.value) { + System.gc(); + println("Saving snapshot") + profiler.captureSnapshot() + } + /** Whether compilation should stop at or skip the phase with given name. */ protected def stopPhase(name: String) = settings.stop contains name protected def skipPhase(name: String) = settings.skip contains name diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index 1e03de44a0..372c216d7a 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -117,6 +117,7 @@ trait ScalaSettings extends AbsScalaSettings with StandardScalaSettings { // Not actually doing anything, so disabled. // val nopredefs = BooleanSetting ("-Yno-predefs", "Compile without any implicit predefined values.") val Yprofile = PhasesSetting ("-Yprofile", "(Requires jvm -agentpath to contain yjgpagent) Profile") + val YprofileRes = BooleanSetting ("-Yprofile-resident", "Profile memory, get heap snapshot after each compiler run (requires yjpagent, see above).") val YprofileClass = StringSetting ("-Yprofile-class", "class", "Name of profiler class.", "scala.tools.util.YourkitProfiling") val Yrecursion = IntSetting ("-Yrecursion", "Set recursion depth used when locking symbols.", 0, Some(0, Int.MaxValue), (_: String) => None) val selfInAnnots = BooleanSetting ("-Yself-in-annots", "Include a \"self\" identifier inside of annotations.") diff --git a/src/compiler/scala/tools/util/Profiling.scala b/src/compiler/scala/tools/util/Profiling.scala index 3b45762bd8..e0a1a0e2a0 100644 --- a/src/compiler/scala/tools/util/Profiling.scala +++ b/src/compiler/scala/tools/util/Profiling.scala @@ -29,4 +29,11 @@ abstract class Profiling { captureSnapshot() result } + + /** Advance the current object generation. + * + * Each object on the heap is associated to a generation number. Generations + * start at 1, and are automatically advanced on each snapshot capture. + */ + def advanceGeneration(desc: String = ""): Unit } diff --git a/src/yourkit/scala/tools/util/YourkitProfiling.scala b/src/yourkit/scala/tools/util/YourkitProfiling.scala index d66cdc9ee1..9d166d9a03 100644 --- a/src/yourkit/scala/tools/util/YourkitProfiling.scala +++ b/src/yourkit/scala/tools/util/YourkitProfiling.scala @@ -32,5 +32,9 @@ class YourkitProfiling extends Profiling { active = false } + def advanceGeneration(desc: String) { + controller.advanceGeneration(desc) + } + def isActive = active } \ No newline at end of file -- cgit v1.2.3