Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit the warning if the -Vstatistics option isn't set #47

Merged
merged 4 commits into from
Nov 23, 2023

Conversation

danicheg
Copy link
Collaborator

@danicheg danicheg commented Nov 2, 2023

Resolves #45.
The following warning will be emitted if the Ystatistics option isn't set:

[warn] `scalac-profiling` compiler plugin requires the option `-Ystatistics` to be enabled

By enabling the -Xfatal-warnings option, it will be an error:

[error] `scalac-profiling` compiler plugin requires the option `-Ystatistics` to be enabled

It's convenient to manage fatal behaviour with -Xfatal-warnings, but the output contains excessive debug information, causing that warning may go unnoticed.
UPD: if users don't enable the -P:scalac-profiling:show-profiles option, the output is much consier.
WDYT @lolgab @sjrd @SethTisue?

@@ -294,6 +295,16 @@ class ProfilingPlugin(val global: Global) extends Plugin {
override def run(): Unit = {
super.run()

if (!SettingsOps.areStatisticsEnabled(global)) {
val flagName = global.settings.Ystatistics.name.replace("-V", "-Y")
Copy link
Collaborator

@SethTisue SethTisue Nov 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

normally if -V is supported, it is canonical, and normally if a -Y form exists as well, it is only a deprecated alias. So unless you want to argue otherwise, I should we be documenting and recommending the -V form?

cc @som-snytt

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

normally if -V is supported, it is canonical, and normally if a -Y form exists as well, it is only a deprecated alias.

Thanks! Is this Scala-version-specific logic?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scala> settings.Ystatistics.name
val res1: String = -Vstatistics

scala> settings.Ystatistics.abbreviations
val res2: List[String] = List(-Ystatistics)

Copy link
Collaborator

@SethTisue SethTisue Nov 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But in 2.12,

scala 2.12.18> :power

scala 2.12.18> settings.Ystatistics.name
res0: String = -Ystatistics

scala 2.12.18> settings.Ystatistics.abbreviations
res1: List[String] = List()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So just removing .replace("-V", "-Y") should give the right flag on all versions

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, perhaps this difference between -Y and -V is too subtle for the end users so we can show -V for 2.13 and -Y for 2.12. Any objections?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

Copy link
Collaborator

@SethTisue SethTisue Nov 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've submitted #52 to update the readme accordingly.

It would be good to have a more permanent home for the doc; I opened #53 on that.

@SethTisue SethTisue changed the title Emit the warning if the 'Ystatistics' option isn't set Emit the warning if the -Vstatistics option isn't set Nov 20, 2023
@SethTisue
Copy link
Collaborator

SethTisue commented Nov 22, 2023

@danicheg needs rebase, though

@danicheg
Copy link
Collaborator Author

@SethTisue here we go

@SethTisue SethTisue merged commit af02e05 into scalacenter:main Nov 23, 2023
2 checks passed
@danicheg danicheg deleted the fix-#45 branch November 23, 2023 20:16
@danicheg danicheg added the scalac-profiling Relates to the compiler plugin label Dec 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scalac-profiling Relates to the compiler plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flamegraphs are empty without the -Ystatistics option
4 participants