Slow compilation

I have some related questions, issues and thoughts regarding compilation times. They are based on my Play Framework 2.6 project (which evolved from older versions, so there’s a chance I might have skipped updating something along the way), which I develop on 4 core Windows machine. In general my problem is that it takes a long time to compile it.

  1. Project contains about 150 Java and 150 Scala files. It takes on average 88 seconds to compile. I know it depends, but can you share how your compilation times look like?

  2. Disabling Play Enhancer cuts compilation times by almost 40 seconds. Funny thing that even when I limit which classes should be enhanced, it does not affect compilation times. In my opinion this enhancing approach is so discouraging that it should be dropped (or maybe it already has been and I am stuck with some legacy solution).

  3. The documentation page doesn’t mention you could cut so much by disabling enhancing. Also I think its bit outdated and mentions things I as Java programmer can’t understand (annotate return types?) or doubt can give significant improvements (avoid inheritance).

  4. Even without enhancer, 50 seconds compilation time for such project seems a lot. Do you have some advice how to decrease it?

  5. Are there plans (or more like things happening in ecosystem) to improve compilation times?

1 Like

I’ve struggled with this as well. Especially if I make a change to the routes file.

I am in the process of switching over from twirl templates to reactjs (Next.js) and using sangria graphql api on the play server side instead of rest to minimize the amount of play changes.

It is important to try to turn off antivirus. I discovered some time ago that Malwarebytes was doubling my compile time from 25s to 50s.

Not officially, but yeah, we don’t recommend it anymore. You may want to see these two other threads:

  1. Slow reloads in 2.6
  2. Very slow startup after upgrade to Play 2.6.11

They have a lot of information about how to debug this problem.


The Play Enhancer plugin does increase overall compilation time. I recall coming across a post written by someone explaining why that is so, unfortunately I can’t find it anymore, but the net conclusion as I recall, was to not use it if possible.

I assume the compile time you are seeing is from a clean compilation and not incremental? In my experience, as long as I do not do something that would trigger and complete rebuild, such as changing the routes file, overall compilation is not too bad. Speaking of which, @marcospereira is there any way to not trigger a complete rebuild when changing the routes file?

With my new projects, I am doing what @Adam said, not using any twirl templates, and decompose my applications/services relatively small. With that, I am getting acceptable (in my experience and opinion) compile time.

So I was talking about mostly “clean” compilation. That way I have reliable time of compilation. I know full compilation doesn’t happen in normal development flow, but I assume it is still related with slow incremental compilation and also, as other mention, it happens from time to time in normal development. So I still think it’s worth discussing.

@Adam - thanks for advice regarding antivirus. I don’t have any (apart from Windows Defender which has my project folder ignored). But it made me think I should disable windows indexing for project directory, unfortunately it did not give noticeable improvement.

@marcospereira - thanks for the links, I’ll look into them and see if anything helps.

@chrono_b - thanks for advice. As I mentioned I was talking about clean compilation because it can be easily measured and it’s clear what takes time. But actually my personal feeling is that development using incremental compilation is quite “heavy”. But I have not investigated if the fact it takes few seconds to refresh a page after simple changes comes from long compilation time or some runtime reinitialization so I didn’t want to discuss it (yet).

It is a long shot but just wanted to call out that exclusion list isn’t always enough. Try stopping it completely for a test. (Malwarebytes folder exclusion didn’t work in my case.)

@Adam - so I stopped it completely (at least that’s what I thought I did) and did not notice improvement.

In the meantime, I’ve installed Ubuntu on the same hardware. My environment probably slightly changed (newer sbt, newer JDK build). Regarding compilation times on Ubuntu, 90 seconds compilation time went down to 20 seconds, disabling enhancer decreased it further to 15 seconds. So my personal conclusion is that developing Play applications (or maybe using sbt?) on Windows (in my case Windows 10) is huge waste of time. I wish I had been warned about it.