Live data from Hacker News

How fast does Java compile?

mill-build.org

21–30 of 76 posts

Re: How fast does Java compile?

#21
That's a nice writeup. Given the hot/cold difference you observe, I'd be very curious to see how builds compare when using maven daemon or gradle daemon.

I am not very familiar with those myself, simply aware of them.

[1] https://github.com/apache/maven-mvnd

[2] https://docs.gradle.org/current/userguide/gradle_daemon.html

Re: How fast does Java compile?

#22

That's a nice writeup. Given the hot/cold difference you observe, I'd be very curious to see how builds compare when using maven daemon or gradle daemon. I am not very familiar with those myself, simply aware of them. [1] https://github.com/apache/maven-mvnd [2] https://docs.gradle.org/current/userguide/gradle_daemon.html

The benchmarks in the article do use the Gradle daemon, but not the Maven one, mostly because mvnd isn't the default.

For Gradle, if you turn off the gradle daemon, it gets even slower than the numbers presented going from 4+ seconds to 10+ seconds per compile:

    lihaoyi mockito$ git diff
    diff --git a/gradle.properties b/gradle.properties
    index 377b887db..3336085e7 100644
    --- a/gradle.properties
    +++ b/gradle.properties
    @@ -1,4 +1,4 @@
    -org.gradle.daemon=true
    +org.gradle.daemon=false
     org.gradle.parallel=true
     org.gradle.caching=true
     org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 \

    lihaoyi mockito$ ./gradlew clean; time ./gradlew :classes --no-build-cache
    10.446
    10.230
    10.268

Re: How fast does Java compile?

#23
post #4

How fast does Golang compile? https://www.octobench.com/

How fast does Rust compi..... I better not actually.

Don't worry, I wrote this article about Java but my day-to-day work is Scala. We're lucky if we can crack 4,000 lines-per-second-per-core on my pretty vanilla Scala projects x_x

Re: How fast does Java compile?

#25
post #22

That's a nice writeup. Given the hot/cold difference you observe, I'd be very curious to see how builds compare when using maven daemon or gradle daemon. I am not very familiar with those myself, simply aware of them. [1] https://github.com/apache/maven-mvnd [2] https://docs.gradle.org/current/userguide/gradle_daemon.html

The benchmarks in the article do use the Gradle daemon, but not the Maven one, mostly because mvnd isn't the default. For Gradle, if you turn off the gradle daemon, it gets even slower than the numbers presented going from 4+ seconds to 10+ seconds per compile: lihaoyi mockito$ git diff diff --git a/gradle.properties b/gradle.properties index 377b887db..3336085e7 100644 --- a/gradle.properties +++ b/gradle.properties…

Oh wow. That's... something. :)

Re: How fast does Java compile?

#26
post #8

How fast does Golang compile? https://www.octobench.com/

Huh, so for anyone interested but did not have the time to do the comparison of the two links of OP and parent post: * java (on a cold jvm): 18.000-32.000 line per second on a single core * java (on a hot jvm): 102.000-115.000 line per second on a single core * golang: 28.000 line per second on 12 core

What I love most is how people project.

I was just saying "How fast does Golang compile" because I'm interested in compilation speeds and CPU usage cross compilers (Rust, despite it's "slowness" seems to have the best CPU utilization of the compilers I've checked over the years).

I've been using Java from 1996 on for two decades.

A sidenote: The article is hard to read, it's not clear how much IO there is. It seems to use LOC as "all lines" including empty lines and comments, not "of code" (most tools today mean NCLOC when they say LOC). Also not sure why they chose Netty for the test with 500k lines and then only used a sub project with 50k lines.

"Compiling 116,000 lines of Java per second is very fast. That means we should expect a million-line Java codebase to compile in about 9 seconds, on a single thread."

The get the score from compiling 50k of lines without IO it seems and then extrapolate to 1m of lines - does that also fit into memory? No GC? And no IO? At least one would need to check if a file has been changed on disk? Or would the OS do that with a cache check?

"compile your code, build tools add a frankly absurd amount of overhead ranging from ~4x for Mill to 15-16x for Maven and Gradle!"

IO? Check for changed files?

Re: How fast does Java compile?

#27
Seems easy enough to do a quick fix for. Just add a option to maven that goes straight into compile and does nothing else. Would be good for local dev. However as we all know maven does much more than this and server side ci/cd process is what really slows your other team members down (if its slow)

Re: How fast does Java compile?

#28
post #8

How fast does Golang compile? https://www.octobench.com/

Huh, so for anyone interested but did not have the time to do the comparison of the two links of OP and parent post: * java (on a cold jvm): 18.000-32.000 line per second on a single core * java (on a hot jvm): 102.000-115.000 line per second on a single core * golang: 28.000 line per second on 12 core

Outside a synthetic benchmark:

  * Gradle compiling 100,000 lines of Java at ~5,600 lines/s
  * Maven compiling 500,000 lines of Java at ~5,100 lines/s
  * Mill compiling at ~25,000 lines/s on both the above whole-project benchmarks
Again not to put Java down but have a proper discussion about compiler speeds. I'm not interested in "your" tool is faster than "my" tool, I want to understand compilation speeds of different programming languages and what impacts them. Java and Go have similiar execution speeds + similar simple type systems, no implicits etc, so they should be similar.

Of course beside the obvious, comparing compilation speeds on two totally different CPUs and machines. Do we compare compilers or machines?

Re: How fast does Java compile?

#29
Use Maven profiles:

* compile only

* compile/test only

* compile/install jar only, skip source/javadoc packages

* checkstyle only

* static analysis only

* code coverage only

* Skip PGP (you DO check your artifact signatures, right?)

The beauty of this is you can create a corporate super pom that defines all of these for you and they can be inherited by every project in your org.

Finally, if you have a large multi-module project, run with -T2C to parallel-ize module builds. If your tests are written in a sane/safe manner: -DuseUnlimitedThreads=true -Dparallel=classes -DforkCount=2C will also give you a major boost.

We have a giant code base (500,000 SLOC) with 28 maven modules, and a full compile and install takes less 40 seconds with compile/install only. You often don't need to do a full build, but even with tests thats about 3 mins on a M3 Max.

Re: How fast does Java compile?

#30

Use Maven profiles: * compile only * compile/test only * compile/install jar only, skip source/javadoc packages * checkstyle only * static analysis only * code coverage only * Skip PGP (you DO check your artifact signatures, right?) The beauty of this is you can create a corporate super pom that defines all of these for you and they can be inherited by every project in your org. Finally, if you have a large multi-mod…

Alas, I'm stuck with Gradle. And not a simple example of the species, either.
Post reply on HN