Skip to content

Restructuring repo and issues #1636

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

Merged
merged 55 commits into from
Nov 22, 2016

Conversation

felixmulder
Copy link
Contributor

@felixmulder felixmulder commented Oct 28, 2016

Partest was not compiling everything in directories, it was compiling the top-level scala files in the directories.

Which revealed some nasty bugs. Specifically:

  • pos/dotc
  • pos/dotty
  • pos/java-interop
  • pos/repl
  • pos/tools

These previously passed because only the top-level was compiled, but now do not. Stale symbols galore.

Could I get some help on this branch?

cc: @odersky, @DarkDimius

PS - since most of these are contained within one another (dotty is a superset of repl etc) I hope it's just one bug.

";dotty-library/package" +
";dotty-compiler/test:package"
) ++
addCommandAlias(
"partest",
";packageAll" +
Copy link
Member

Choose a reason for hiding this comment

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

I guess that then ;packageAll can be removed from all the command aliases :)

Copy link
Member

Choose a reason for hiding this comment

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

Probably, yes. (Also I tried using a Sequential Task for packageAll but when I ran it, it did nothing, any idea why?)

Copy link
Member

Choose a reason for hiding this comment

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

Don't use Def.sequential unless you know exactly what you are doing.

Def.sequential does not give much guarantee in terms of sequentiality. In particular, if from X you depend on task A which depends on a sequence of B, C; but at the same time X depends on C (via another path of dependencies); then B and C will probably still run in parallel.

@@ -12,7 +12,7 @@ object DottyBuild extends Build {
val baseVersion = "0.1"
val isNightly = sys.env.get("NIGHTLYBUILD") == Some("yes")

val jenkinsMemLimit = List("-Xmx1300m")
val jenkinsMemLimit = List("-Xmx1500m")
Copy link
Contributor

Choose a reason for hiding this comment

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

why is more memory needed after those changes?

Copy link
Member

Choose a reason for hiding this comment

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

I think the commit message explains it.

Copy link
Contributor

@DarkDimius DarkDimius Oct 28, 2016

Choose a reason for hiding this comment

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

Would you mind explaining the bug?
7f4f387
does a lot of changes but I don't see anything particularly related to -deep or something similar.

The biggest tests that we had so far were stdlib and dotty. Stdlib relies on whitelist, and dotty did use -deep flag and they did run fine with previous heap size. If this flag works unreliably, it would be nice to know as other forks depend on it.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

@DarkDimius DarkDimius Oct 29, 2016

Choose a reason for hiding this comment

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

The question still persists. This fix only changes behaviour of partest, the bug wasn't present in jUnit test suite. Why does partest need substantially more memory to run(compared to jUnit tests)?

I'm sure that previous September we were able to compile dotty & stdlib using only 750mb of memory without GC-related issues(i had to work on a very slow machine that had 2GB of memory for a week and I've decreased -Xmx to 750mb). In March, you acf0535 have bumped the upper limit to 1.3Gb. Now we bump it to 1.5GB.

Since last September, tests didn't grow much. Yes, dotty is now 20% bigger, white collection whitelist is negligibly bigger. Tests do not explain why dotty now needs at least twice more memory to pass the test suite, compared to situation 1 year ago.

Copy link
Contributor Author

@felixmulder felixmulder Oct 29, 2016

Choose a reason for hiding this comment

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

Previously dotty was not compiled properly by partest. It was only able to compile top-level files (since the compiler itself was on the class path).

It never recursed obeying -deep.

EDIT: was on my phone, now I have a computer, here's a better explanation: previously what happened was that partest copied files (correctly, with deep) to the partest-generated directory. A flags file was created with the correct flags, then partest would do a set up and call the method sources to get the sources for which to do the compilation with DPDirectCompiler. This did not work as intended. Instead of getting all the sources or just giving the compiler a directory, it would give the compiler the specific sources that were at the top-level of the sources directory - for dotty that would mean DottyPredef.scala (maybe more historically).

The partest suite would in the cases where there was no scala or java files in the top dir actually do ~sources(dir).tail and throw an exception. This exception was entirely swallowed by the suite and didn't show until printlns were added to an absurd extent. Once we uncovered this behavior, we could verify that pos/repl was only compiling the top-level files and not the files contained within the sub dir ammonite.

So, since partest never actually compiled the whole of dotty in parallel with other tests, we probably don't have a very exact baseline for what the suite needs - that is why @smarter increased the heap-size IIUC.

Copy link
Contributor

@DarkDimius DarkDimius Oct 29, 2016

Choose a reason for hiding this comment

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

@felixmulder, I do understand that partest did the wrong thing. What I mean is that the current situation indicates that we use too much memory. Note, that scalac runs the entire test suite in parallel under partest under -Xmx1024m(that's what is used by CI AFAIK).

The baselines, that seem reasonable to me are:

  • normal hello-world like tests shouldn't need more than 100mb of memory.
  • dotty & stdlib tests shouldn't need more than 0.5 gigs of memory.

Assuming our CI runs 4 compiler threads, this means that we would never need more than 1.2 Gb, and we'll only need 1.2 Gb if we're unlucky and dotty & stlib are compiled concurrently. If you'll have a look at the log output of the build failed with GC https://scala-ci.typesafe.com/job/dotty-master-validate-partest/2417/consoleFull, you'll see that these two tests did not run concurrently.

Copy link
Member

@smarter smarter Oct 29, 2016

Choose a reason for hiding this comment

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

Yes, please open an issue so that we can track this.

@smarter
Copy link
Member

smarter commented Oct 28, 2016

Remaining issues:

@felixmulder
Copy link
Contributor Author

Yay, now the unit tests are passing again. Hopefully it's just that pesky stale symbol left now.

@felixmulder felixmulder force-pushed the topic/restructure-attempt2 branch 6 times, most recently from 6797cb5 to 31c1900 Compare November 3, 2016 14:33
@@ -180,6 +181,28 @@ object DottyBuild extends Build {
)
}.evaluated,

// Override run to be able to run compiled classfiles
run := {
Copy link
Member

Choose a reason for hiding this comment

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

I think this is super confusing. In every other sbt project run means run the Main of this project but not here, I'm fine with having a dotr command but run should keep being the actual sbt run

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought you would say that - but waited until you did. I'll patch it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed 👍

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

@felixmulder felixmulder force-pushed the topic/restructure-attempt2 branch 5 times, most recently from 22a093c to c53a5e9 Compare November 4, 2016 14:52
@smarter smarter force-pushed the topic/restructure-attempt2 branch from c53a5e9 to a05bc05 Compare November 14, 2016 16:37
@smarter
Copy link
Member

smarter commented Nov 14, 2016

Rebased (more commits to come).

@smarter smarter force-pushed the topic/restructure-attempt2 branch 3 times, most recently from f5da246 to 691aa97 Compare November 18, 2016 01:16
@smarter
Copy link
Member

smarter commented Nov 18, 2016

@felixmulder: Remaining known issues:

  • The directory structure is inconsistent (some projects have main/scala/, some don't), would be nice to fix this in this PR
  • Bootstrapping is broken (again!) ./compiler/dotty.jar and ./compiler/dotty-lib.jar are empty. This could be fixed in a separate PR once this one is green.

@odersky : Commits you may want to review:

@smarter
Copy link
Member

smarter commented Nov 18, 2016

@felixmulder Also it would be really nice if sbt run was an alias for sbt dotc to not break existing workflows.

smarter and others added 22 commits November 22, 2016 01:35
This might cause a stale symbol exception and make it harder to find the
source of the problem.
Previously Outer2#Inner#foo failed to compile with:
```
    non-private method foo refers to private value x in its type signature
```

This should compile because the boundary of `foo` is `class Outer2`
and the boundary of `x` is `object Outer2`. This commit fixes this by
also considering the linked boundary in `checkNoPrivateLeaks`.
The access boundary of a def in a local class is the owner of that
class, previously it was set to the access boundary of the owner of the
class instead.
This could be abstracted better but we'll end up replacing
checkNoPrivateLeaks soon anyway due to scala#1723
We run checkNoPrivateLeaks in the unpickler since last commit and this
is causing an issue related to privacy leaks. Give up and workaround
it since we're going to redesign how we handle privacy leaks because
of scala#1723 anyway.
This lead to stale symbol errors in `tasty_tools` because the symbol
forcing was bringing forward symbols from the previous run before the
corresponding symbols for the current run were created.

We fix this by adding Annotations#deferredSymAndTree which behaves
similarly to Annotations#deferred but take a by-name symbol.

We also remove TreeUnpickler#LazyAnnotationReader which was apparently
never used.
This fix the test "Extracted source dependencies from public members"
which previously failed with:
  Set('G, 'E) is not equal to Set('B, 'E) (DependencySpecification.scala:34)

`H` extends `G.T[Int]` which is an alias of `B`, so the
`topLevelInheritanceDepndencies` of `H` should contain `B`, this was not
the case before because we didn't dealias before looking for the
top-level class of the dependency, so we ended up with `G`, the
top-level class in which the alias `T` is contained.
Some tests are run with "-Ytest-pickler" which uses a huge amount of
memory. By running these tests one by one when no other test is running,
we avoid running out of memory.
These commands already work without defining aliases
Otherwise this would get picked up by eclipse plugin as a project named
`bin`
Depending on order, scripts might choose the wrong jar (i.e. test
instead of non test). This commit addresses that by sedding away
results which have `javadoc` or `tests` in the jar name
Otherwise, they may end up with a qualifier, this manifested itself as a
pickling difference in `tasty_tools`.
Special-casing like this is ugly, we should decide whether we want to
avoid simplifications on all TypTrees and whether we want to do this
just in unpickler or always. But I want to merge this PR first.
@smarter smarter force-pushed the topic/restructure-attempt2 branch 3 times, most recently from ca447e0 to 9222af0 Compare November 22, 2016 00:54
@smarter
Copy link
Member

smarter commented Nov 22, 2016

Alright, rebasing on top of master with #1725 merged seems to have helped with the remaining memory issues, now partest consistently runs in ~15 minutes. Merging now before something else breaks! :)

@smarter smarter merged commit c488e01 into scala:master Nov 22, 2016
smarter added a commit to scala/scala3-example-project that referenced this pull request Nov 22, 2016
@allanrenucci allanrenucci deleted the topic/restructure-attempt2 branch December 14, 2017 19:25
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.

8 participants