Skip to content

Output .tasty files in Pickler phase #4955

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

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Aug 17, 2018

This is an upstream of some changes in #4767 with some additional optimizations.

@smarter
Copy link
Member

smarter commented Aug 17, 2018

I wonder if emitting tasty earlier may mess up zinc's logic for deleting/restoring output files.

@sjrd In Scala.js, is it possible for a .sjsir file to be emitted without a corresponding .class file (because compilation failed before .class file generation) ? If so then I guess we're good

@sjrd
Copy link
Member

sjrd commented Aug 17, 2018

In Scala.js, is it possible for a .sjsir file to be emitted without a corresponding .class file (because compilation failed before .class file generation) ? If so then I guess we're good

In theory, it can happen, if one of the very last phases of scalac reports an error (or crashes). However, AFAIK there is only one compile error that can happen, and it is "JVM bytecode limit exceeded", which are very rare. I have never checked what happened to incremental compilation in that scenario. It may very well be broken. I don't care much for Scala.js because it's rare. If you emit as early as pickler, you should definitely investigate.

@allanrenucci
Copy link
Contributor

This will probably mess up incremental compilation. The TastyFileManager relies on the generated class files to manage the generated TASTY files

@nicolasstucki nicolasstucki force-pushed the output-tasty-in-pikler branch from 6e08d2d to ca97818 Compare August 20, 2018 08:46
@nicolasstucki
Copy link
Contributor Author

@allanrenucci the CI is not kicking in. Is there something wrong with it or is it just this PR?

@nicolasstucki
Copy link
Contributor Author

@allanrenucci, never mind. I had to manually approve in the CI as I modified .drone.yml.

@smarter
Copy link
Member

smarter commented Aug 20, 2018

The same way that we signal to sbt that we're emitting a .class file using a callback (https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/backend/jvm/GenBCode.scala#L274-L280) we might need to signal that we're emitting a .tasty file. This might require adding a new callback to sbt.

@allanrenucci
Copy link
Contributor

We might not have to update the plugin or sbt after all. If we produce some TASTY files and the compilation fails after pickler, we probably just need to delete the files produced. Zinc should be able to restore the overwritten files. Files that may be overwritten are deleted by Zinc before compilation and restored in case of failure.

Out of curiosity, why do we want to output TASTY files in Pickler phase?

@smarter
Copy link
Member

smarter commented Aug 20, 2018

Out of curiosity, why do we want to output TASTY files in Pickler phase?

It's useful for parallel compilation in a project (#4767) and could also be used by the build tool to parallelize across projects (start compilation of dependent projects after tasty has been output instead of waiting for the project to finish compiling). Another usecase is quicker feedback when working on code: instead of doing sbt ~compile you could have sbt ~check that only runs until tasty is output (we can't stop earlier for separate compilation to work).

smarter and others added 4 commits August 28, 2018 09:49
@allanrenucci
Copy link
Contributor

Closing with label revisit. We need to investigate how this interacts with incremental compilation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants