Skip to content

Commit

Permalink
Merge branch 'main' into fix-#43
Browse files Browse the repository at this point in the history
  • Loading branch information
danicheg committed Nov 23, 2023
2 parents 241c7a3 + 75b1a43 commit 1f4801c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ addCompilerPlugin("ch.epfl.scala" %% "scalac-profiling" % "<version>" 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:`**.
Expand All @@ -38,12 +40,11 @@ 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.

## Historical context

The historical context of this project is quite interesting. For those wondering about the details, see the [dedicated section](HISTORICALCONTEXT.md).
The historical context of this project is quite interesting. For those wondering about the details, see the [dedicated section](HISTORICALCONTEXT.md).
2 changes: 1 addition & 1 deletion plugin/src/main/scala/ch/epfl/scala/PluginConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ch.epfl.scala.profiledb.utils.AbsolutePath

final case class PluginConfig(
showProfiles: Boolean,
noDb: Boolean,
generateDb: Boolean,
sourceRoot: AbsolutePath,
printSearchIds: Set[Int],
generateMacroFlamegraph: Boolean,
Expand Down
8 changes: 4 additions & 4 deletions plugin/src/main/scala/ch/epfl/scala/ProfilingPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ProfilingPlugin(val global: Global) extends Plugin {
private final lazy val GenerateMacroFlamegraph = "generate-macro-flamegraph"
private final lazy val GenerateGlobalFlamegraph = "generate-global-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
Expand All @@ -56,7 +56,7 @@ class ProfilingPlugin(val global: Global) extends Plugin {

private final lazy val config = PluginConfig(
showProfiles = super.options.contains(ShowProfiles),
noDb = super.options.contains(NoProfileDb),
generateDb = super.options.contains(GenerateProfileDb),
sourceRoot =
findOption(SourceRoot, SourceRootRegex)
.map(AbsolutePath.apply)
Expand Down Expand Up @@ -302,7 +302,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 {
Expand All @@ -325,7 +325,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)
Expand Down
3 changes: 1 addition & 2 deletions project/BuildPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down

0 comments on commit 1f4801c

Please sign in to comment.