GithubHelp home page GithubHelp logo

Comments (25)

joinr avatar joinr commented on May 29, 2024 1

No, good writeup (and nugget of opt knowledge). Feel free to close.

from clj-fast.

bsless avatar bsless commented on May 29, 2024

This is weird, I can't recreate the results. Getting the exact same performance for both cases.
Which JVM and Clojure versions were you using?

from clj-fast.

joinr avatar joinr commented on May 29, 2024

Yeah, I'm seeing similar results. This (was) on java 8 on ubuntu's JDK, whatever variant that was. I just ran it on W10 with adopt open jdk, 1.8.0_222, and had like a 1 ns difference. Considering it anomalous for now (or jdk specific...)

from clj-fast.

bsless avatar bsless commented on May 29, 2024

I ran my benchmarks on Ubuntu 20.10 with Java 15.
If this was about the JDK version, 8 is considered EOL and we can happily forget about it.
If you have no objections I'm closing this issue, but do reopen it if you find it crops up again

from clj-fast.

joinr avatar joinr commented on May 29, 2024

, 8 is considered EOL and we can happily forget about it.

Not so. There are many many large orgs still running Java 8 for LTS (part of the reason amazon has their own, among others). Some places (including mine) are still there for the foreseeable future. Just FYI.

from clj-fast.

bsless avatar bsless commented on May 29, 2024

Well then, I'll try to recreate

from clj-fast.

joinr avatar joinr commented on May 29, 2024

I'll re-run on the original machine. an ubuntu machine on ec2.

from clj-fast.

bsless avatar bsless commented on May 29, 2024

Reran with:

;; CIDER 1.1.0snapshot (package: 20210416.1915), nREPL 0.8.3
;; Clojure 1.10.1, Java 1.8.0_282

Ubuntu 20.10
Got same results again, exactly same performance in both cases

from clj-fast.

joinr avatar joinr commented on May 29, 2024

I just re-ran it on the same setup, and reproduced:

Execution time mean : 121.353224 ns
Execution time mean : 36.097984 ns

from clj-fast.

joinr avatar joinr commented on May 29, 2024

openjdk version "1.8.0_282"
OpenJDK Runtime Environment (build 1.8.0_282-8u282-b08-0ubuntu1~16.04-b08)
OpenJDK 64-Bit Server VM (build 25.282-b08, mixed mode)

from clj-fast.

bsless avatar bsless commented on May 29, 2024

Weird, can you print out all the options and flags the JVM ran with?

from clj-fast.

joinr avatar joinr commented on May 29, 2024

running from lein repl with default options (no :jvm-opts entry).

from clj-fast.

joinr avatar joinr commented on May 29, 2024

lein 2.9.1, not that it matters.

from clj-fast.

joinr avatar joinr commented on May 29, 2024

Also running this on an EC2 instance; could be some throttling, but I'd expect that to be amortized over the multiple runs.

from clj-fast.

bsless avatar bsless commented on May 29, 2024

The JVM still has some default configurations, such as GC, server, client or tiered etc. There's a way to print out all of them, something like https://alvinalexander.com/java/how-see-jvm-parameters-arguments-from-running-java-application/

from clj-fast.

joinr avatar joinr commented on May 29, 2024

[:arg -Dfile.encoding=UTF-8]
[:arg -XX:-OmitStackTraceInFastThrow]
[:arg -XX:+TieredCompilation]
[:arg -XX:TieredStopAtLevel=1]
[:arg -Dclojure.compile.path=/home/tom/repos/spork/target/classes]
[:arg -Dspork.version=0.2.1.4-SNAPSHOT]
[:arg -Dclojure.debug=false]

from clj-fast.

joinr avatar joinr commented on May 29, 2024

this particular repo running clojure 1.10.1

from clj-fast.

bsless avatar bsless commented on May 29, 2024

Okay, I managed to recreate. One of these is the culprit:

"-Djdk.attach.allowAttachSelf" "-XX:+UnlockDiagnosticVMOptions" "-XX:+DebugNonSafepoints"

from clj-fast.

bsless avatar bsless commented on May 29, 2024

Printed the options with and without passing JVM opts flag:

;;; no jvm opts
["-Dfile.encoding=UTF-8"
 "-XX:-OmitStackTraceInFastThrow"
 "-XX:+TieredCompilation"
 "-XX:TieredStopAtLevel=1"
 "-Dclj-fast.version=0.0.10-SNAPSHOT"
 "-Dclojure.debug=false"]

;;; jvm opts
["-Dfile.encoding=UTF-8"
 "-Djdk.attach.allowAttachSelf"
 "-XX:+UnlockDiagnosticVMOptions"
 "-XX:+DebugNonSafepoints"
 "-Dclj-fast.version=0.0.10-SNAPSHOT"
 "-Dclojure.debug=false"]

I suspect XX:TieredStopAtLevel

from clj-fast.

joinr avatar joinr commented on May 29, 2024

with :jvm-opts ["-XX:+UnlockDiagnosticVMOptions" "-XX:+DebugNonSafepoints"]

I get 20 ns for both runs now....both in lein repl and from cider.

from clj-fast.

bsless avatar bsless commented on May 29, 2024

Okay, tested with a variety of flags
The culprit is -XX:TieredStopAtLevel
For anything under 4 you'll get the performance difference because C2 doesn't kick in.
It's probably used by lein to reduce start-up time for dev profile. I think lein run uses dev profile.
I tried passing empty jvm-opts vector and got the same results for both, so I'm attributing this to dev profile.

from clj-fast.

joinr avatar joinr commented on May 29, 2024

Alright, yet more jvm corner case magic to understand. If nothing else, the issue is documented for posterity.

from clj-fast.

bsless avatar bsless commented on May 29, 2024

I wouldn't call it a corner case of the JVM, more of leiningen IMO - It's an undocumented flag which is injected when youlein run and messes with performance. It's in Lein's source code
I think I'll open an issue about it.

from clj-fast.

bsless avatar bsless commented on May 29, 2024

I think I'll end up adding a few notes to the readme, nothing more I can do in the meanwhile

from clj-fast.

bsless avatar bsless commented on May 29, 2024

This is the best I could do in the meanwhile
bba3ec0

Edit suggestions?

from clj-fast.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.