Skip to content

report phases/units via xsbti.compile.CompileProgress.startUnit #13082 #13084

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

Closed
wants to merge 3 commits into from

Conversation

unkarjedy
Copy link
Contributor

  • revive scala3-sbt-bridge-tests

Copy link
Contributor Author

@unkarjedy unkarjedy left a comment

Choose a reason for hiding this comment

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

xsbti.compile.CompileProgress.advance is still not called

First, it's not obvious where exactly to calculate current / total

Second, there are some issues with the binary compatibility:
scala3-compiler depends on compiler-interface version 1.3.5
scala3-sbt-bridge depends on version 1.4.3
These two versions have different signature of advance.
1.3.5:

boolean advance(int current, int total);

1.4.x and 1.5.x:

default boolean advance(int current, int total, String prevPhase, String nextPhase) {  
    return true;
}

this will lead to runtime error NoSuchMethodError

As I understand form the code, the only reason scala3-compiler uses old interface is to avoid deprecation warnings:

Dependencies.oldCompilerInterface, // we stick to the old version to avoid deprecation warnings

I tried to update it to the new version and suppress deprecated methods usages with @nowarn.
But it doesn't work ATM (see #8908 and #12857)

("Test-0-0.scala", "postInlining"),
("Test-0-0.scala", "staging"),
("Test-0-0.scala", "pickleQuotes"),
("Test-0-0.scala", "MegaPhase{firstTransform, checkReentrant, elimPackagePrefixes, cookComments, checkStatic, betaReduce, inlineVals, expandSAMs}"),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These "MegaPhase" phase names are not ideal, but I don't know how to better report them ATM, taking into account that all subphases are reported for each file

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe just the first name, e.g. "miniphases following firstTransform"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, not sure if there should be information loss.
This could probably be done on the client-side, by parsing.
It has quite a simple structure for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, maybe we could create meaningful names for each MegaPhase, and report it?
I just do not have enough expertise in the compiler to give proper names to them.

Copy link
Member

Choose a reason for hiding this comment

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

Also, maybe we could create meaningful names for each MegaPhase, and report it?

If we could, we would just put all mini-phases in a single MegaPhase (since that would result in a single pass over the AST), but because of implementation details that's not possible, so we split them into the minimum number of MegaPhases we can, but these MegaPhases are not meaningful on their own, so there's no useful name we can give them. In fact, I don't think the name of phases in general is useful information for end users, you could just as well use numbers ("Running phase 1/6 ...") or nothing at all ("Compiling ..."), since the number isn't very useful either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do not print the information about the phases as text anywhere.
It's only reported in the Compilation Charts
https://blog.jetbrains.com/scala/2021/04/07/intellij-scala-plugin-2021-1/#phases-and-units-in-compilation-charts

Yes, most of the users are not interested in this, but there were some users (Scala 2), dealing with macro and compiler internals, which reported their interest in this kind of information.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Anyway, until I can call advance method, this method call will tell IDE that the compilation process is not stuck.
(currently, compilation can take minutes without any indication of progress)
Any value will be fine.

@unkarjedy unkarjedy force-pushed the branch-for-pr-13082 branch from 1071d43 to fd960b7 Compare July 16, 2021 08:44
@unkarjedy unkarjedy force-pushed the branch-for-pr-13082 branch 2 times, most recently from 9555513 to 5bf84e3 Compare July 16, 2021 15:11
unkarjedy added a commit to JetBrains/intellij-scala that referenced this pull request Jul 16, 2021
NOTE 1 (reminder): zinc also transitively includes compiler-interface
NOTE 2: scala3-sbt-bridge 3.0.1 depends on compile-interface 1.4.3, scala3-compiler depends on 1.3.5 (which is partially binary compatible with 1.4.3)
scala/scala3#13084 (review)

NOTE 2: if this change breaks anything for some reason, try changing the version to 1.4.4 instead of reverting to 1.4.0-M12.
I tried to compile some example project with Bloop and it at least didn't fail.
Comment on lines +15 to +17
// Beware: scala3-compiler uses compiler-interface 1.3.5 which is binary incompatible
// with the one used un scala3-sbt-bridge (1.4.5)
// it has different signature def advance(current: Int, total: Int): Boolean
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it's best to wait until we've upgraded to the latest interface before proceeding further here (see #10816, it seems this is currently blocked on bloop upgrading zinc /cc @tgodzik)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, trying to get to that, but haven't managed to do it yet. We should also upgrade zinc in Gradle after the Scala 3 support is merged.

@anatoliykmetyuk
Copy link
Contributor

@unkarjedy @smarter @tgodzik What's the status of this PR? Is it blocked on something or is it ready for review?

@smarter
Copy link
Member

smarter commented Sep 23, 2021

See #13084 (comment)

@tgodzik
Copy link
Contributor

tgodzik commented Sep 23, 2021

This is highly blocked on me 😓

@ckipp01
Copy link
Member

ckipp01 commented May 10, 2023

Coming back to this after a long long time. What's the status of this? Is this something we still want to push forward, or should we close?

@smarter
Copy link
Member

smarter commented May 10, 2023

This is blocked on #10816 which @bishabosha is working on right now :).

@bishabosha
Copy link
Member

bishabosha commented Oct 16, 2023

I am working on a different PR to implement CompileProgress, will still reference this one for tests

@bishabosha bishabosha closed this Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants