-
Notifications
You must be signed in to change notification settings - Fork 21
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
2.12.9 in phase jvm takes ~200 secs, up from ~1.4 sec #11667
Comments
@lrytz any idea what the next investigation steps here ought to be? |
@yoohaemin thanks for the report. Did GC show up in the profiler / could you give it a try with a larger |
Looking at the git history of the backend, I don't see an obvious candidate that could be the cause of the regression. Maybe scala/scala#7780. |
I just ran with -Xmx4g, but heap size doesn't seem to go over 1.5G at all, and GC kicks in during compilation multiple times but it is really short and quick. |
@yoohaemin have you tried to attach async-profiler and plot flame graphs? possible it will help to spot some new details... |
OK, thanks. Do you have the optimizer enabled (with I just realized that DCE doesn't bail out on large methods (https://github.com/scala/scala/blob/v2.12.8/src/compiler/scala/tools/nsc/backend/jvm/opt/LocalOpt.scala#L294), it should check I'm not sure how to diagnose this from the outside. I could most likely identify the issue quickly if I had access to the soruce code. @yoohaemin would it be possible for you to share it (privately)? |
(I'm working with @yoohaemin) @lrytz We didn't have the optimizer enabled. I just tried with
Unfortunately we can't share our code, and this project is pretty big so it's not easy to isolate the problem into a smaller build. We haven't tried the async profiler yet, just VisualVM sampling that shows it is stuck on
|
With
|
That's interesting. It really could be due to the ASM upgrade. I suspect that there is a specific bytecode shape that trips up the ASM analyzer. You could add https://scala-ci.typesafe.com/artifactory/scala-integration as a resolver and test with Scala versions You also could try to:
|
Interesting, it is fast with both snapshots. We'll try to find the commit that introduces the problem. |
Here's a git bisect script that you could adapt and use: https://gist.github.com/lrytz/f92e5db08c6bad14aaf0b890ec5d3b4d You'd have to measure the time somehow since the build doesn't fail, just takes a long time. |
It seems to be caused by scala/scala#8061 |
attn @retronym |
I brought a minimal reproduction after we investigated this issue following advice from @lrytz. Thanks everyone for the help. |
believed fixed by scala/scala#8327 @yoohaemin @ghostdogpr would appreciate if you could test 2.12.10-bin-de413b9 and verify |
I tried it with https://github.com/yoohaemin/scala-bug-11667-reproduction just now and this looks good:
|
@SethTisue we will be able to test on our project on Monday. But based on the repro project it looks good! |
@ghostdogpr it looks that in runtime your http-handler burns a lot of CPU cycles in the routing match expression too... will you consider to use some kind of prefix tree which supports wildcard for path elements instead? |
Indeed... the generated code is likely too large to be JIT compiled by the JVM, so you have the overhead of interpretation on top of any issues with cascading if/else to get down the matching handler. |
Splitting the routes was indeed on our todo list (for both compile-time and runtime performance), but was a low priority since performance was not exactly our biggest concern at the moment. In any case, that big pattern match did help spot a compiler regression ;) |
@SethTisue 2.12.10-bin-de413b9 works well 👍 |
cool, thanks for confirming |
We have a sbt build with 10 subprojects, and one of them started taking a lot more time to compile after bumping to 2.12.9. We do not have a small reproducible build, but only a thread dump of scalac and output from -Ystatistics at this point (of 2.12.9 and 2.12.8 for comparison). You can find them here.
In the file, you can notice that phase
jvm
took1411.476ms (3.1%)
with 2.12.8, but197014.957ms (83.9%)
with 2.12.9. Using a profiler shows that scalac is stuck inscala.tools.asm.tree.analysis.Frame.merge
during the whole time.Tried on GraalVM EE (macos) and openjdk11 with jvmci on (nixos), with consistent results.
The text was updated successfully, but these errors were encountered: