From cb9dde2d6d38caba1ebd317e32a0f95cea1140ae Mon Sep 17 00:00:00 2001 From: danicheg Date: Mon, 13 Nov 2023 21:39:28 +0300 Subject: [PATCH 1/4] Invert the 'no-profiledb' option into 'generate-profiledb' --- .../scala/ch/epfl/scala/PluginConfig.scala | 2 +- .../scala/ch/epfl/scala/ProfilingPlugin.scala | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/plugin/src/main/scala/ch/epfl/scala/PluginConfig.scala b/plugin/src/main/scala/ch/epfl/scala/PluginConfig.scala index 3ad75a5..7902315 100644 --- a/plugin/src/main/scala/ch/epfl/scala/PluginConfig.scala +++ b/plugin/src/main/scala/ch/epfl/scala/PluginConfig.scala @@ -4,7 +4,7 @@ import ch.epfl.scala.profiledb.utils.AbsolutePath case class PluginConfig( showProfiles: Boolean, - noDb: Boolean, + generateDb: Boolean, sourceRoot: Option[AbsolutePath], printSearchIds: Set[Int], generateMacroFlamegraph: Boolean, diff --git a/plugin/src/main/scala/ch/epfl/scala/ProfilingPlugin.scala b/plugin/src/main/scala/ch/epfl/scala/ProfilingPlugin.scala index daa1f2e..0780f01 100644 --- a/plugin/src/main/scala/ch/epfl/scala/ProfilingPlugin.scala +++ b/plugin/src/main/scala/ch/epfl/scala/ProfilingPlugin.scala @@ -35,7 +35,7 @@ class ProfilingPlugin(val global: Global) extends Plugin { private final lazy val PrintSearchResult = "print-search-result" private final lazy val GenerateMacroFlamegraph = "generate-macro-flamegraph" private final lazy val PrintFailedMacroImplicits = "print-failed-implicit-macro-candidates" - private final lazy val NoProfileDb = "no-profiledb" + private final lazy val GenerateProfileDb = "generate-profiledb" private final lazy val ShowConcreteImplicitTparams = "show-concrete-implicit-tparams" private final lazy val PrintSearchRegex = s"$PrintSearchResult:(.*)".r private final lazy val SourceRootRegex = s"$SourceRoot:(.*)".r @@ -55,13 +55,13 @@ class ProfilingPlugin(val global: Global) extends Plugin { } private final lazy val config = PluginConfig( - super.options.contains(ShowProfiles), - super.options.contains(NoProfileDb), - findOption(SourceRoot, SourceRootRegex).map(AbsolutePath.apply), - findSearchIds(findOption(PrintSearchResult, PrintSearchRegex)), - super.options.contains(GenerateMacroFlamegraph), - super.options.contains(PrintFailedMacroImplicits), - super.options.contains(ShowConcreteImplicitTparams) + showProfiles = super.options.contains(ShowProfiles), + generateDb = super.options.contains(GenerateProfileDb), + sourceRoot = findOption(SourceRoot, SourceRootRegex).map(AbsolutePath.apply), + printSearchIds = findSearchIds(findOption(PrintSearchResult, PrintSearchRegex)), + generateMacroFlamegraph = super.options.contains(GenerateMacroFlamegraph), + printFailedMacroImplicits = super.options.contains(PrintFailedMacroImplicits), + concreteTypeParamsInImplicits = super.options.contains(ShowConcreteImplicitTparams) ) private lazy val logger = new Logger(global) @@ -275,7 +275,7 @@ class ProfilingPlugin(val global: Global) extends Plugin { override def apply(unit: global.CompilationUnit): Unit = { if ( SettingsOps.areStatisticsEnabled(global) && - !config.noDb) { + config.generateDb) { val currentSourceFile = unit.source val compilationUnitEntry = profileDbEntryFor(currentSourceFile) dbPathFor(currentSourceFile) match { @@ -298,7 +298,7 @@ class ProfilingPlugin(val global: Global) extends Plugin { val graphsDir = globalOutputDir.resolve(graphsRelativePath) reportStatistics(graphsDir) - if (!config.noDb) { + if (config.generateDb) { val globalDatabase = toGlobalDatabase(global.statistics) val globalRelativePath = ProfileDbPath.GlobalProfileDbRelativePath val globalProfileDbPath = ProfileDbPath(globalOutputDir, globalRelativePath) From 916fc1055dbbab9142699325164b067a84120e82 Mon Sep 17 00:00:00 2001 From: danicheg Date: Mon, 13 Nov 2023 21:41:53 +0300 Subject: [PATCH 2/4] Clean up the BuildPlugin --- project/BuildPlugin.scala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/project/BuildPlugin.scala b/project/BuildPlugin.scala index f995a50..c85feee 100644 --- a/project/BuildPlugin.scala +++ b/project/BuildPlugin.scala @@ -181,9 +181,8 @@ object BuildImplementation { val projectBuild = ref.build val workingDir = Keys.buildStructure.value.units(projectBuild).localBase.getAbsolutePath val sourceRoot = s"-P:scalac-profiling:sourceroot:$workingDir" - val noProfileDb = s"-P:scalac-profiling:no-profiledb" val pluginOpts = (PluginProject / BuildKeys.optionsForSourceCompilerPlugin).value - noProfileDb +: sourceRoot +: pluginOpts + sourceRoot +: pluginOpts } } From c7c5a550710ddbb5b244988df2a49897290fb23a Mon Sep 17 00:00:00 2001 From: danicheg Date: Mon, 13 Nov 2023 21:45:01 +0300 Subject: [PATCH 3/4] Tweak the README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index b429b10..726b46c 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,7 @@ All the compiler plugin options are **prepended by `-P:scalac-profiling:`**. flamegraph for implicit searches is enabled by default. * `print-failed-implicit-macro-candidates`: Print trees of all failed implicit searches that triggered a macro expansion. -* `no-profiledb`: Recommended. Don't generate profiledb (will be on by default - in a future release). +* `generate-profiledb`: Generate profiledb. * `show-concrete-implicit-tparams`: Use more concrete type parameters in the implicit search flamegraph. Note that it may change the shape of the flamegraph. From 4180a0704df035cfc6378dda6c200f5a1ff0c435 Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Mon, 20 Nov 2023 10:20:03 -0800 Subject: [PATCH 4/4] Recommend `-Vstatistics` --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b429b10..f750c6b 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ addCompilerPlugin("ch.epfl.scala" %% "scalac-profiling" % "" cross Cros To learn how to use the plugin, read [Speeding Up Compilation Time with `scalac-profiling`](https://www.scala-lang.org/blog/2018/06/04/scalac-profiling.html) in the scala-lang blog. +Note that in Scala 2.13, the preferred form of the compiler option to enable statistics is `-Vstatistics`. It is part of the family of `-V` flags that enable various "verbose" behaviors. (In 2.12, the flag is called `-Ystatistics`.) + ### Compiler plugin options All the compiler plugin options are **prepended by `-P:scalac-profiling:`**. @@ -46,4 +48,4 @@ All the compiler plugin options are **prepended by `-P:scalac-profiling:`**. ## Historical context -The historical context of this project is quite interesting. For those wondering about the details, see the [dedicated section](HISTORICALCONTEXT.md). \ No newline at end of file +The historical context of this project is quite interesting. For those wondering about the details, see the [dedicated section](HISTORICALCONTEXT.md).