Comments (25)
No, good writeup (and nugget of opt knowledge). Feel free to close.
from clj-fast.
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.
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.
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.
, 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.
Well then, I'll try to recreate
from clj-fast.
I'll re-run on the original machine. an ubuntu machine on ec2.
from clj-fast.
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.
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.
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.
Weird, can you print out all the options and flags the JVM ran with?
from clj-fast.
running from lein repl with default options (no :jvm-opts entry).
from clj-fast.
lein 2.9.1, not that it matters.
from clj-fast.
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.
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.
[: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.
this particular repo running clojure 1.10.1
from clj-fast.
Okay, I managed to recreate. One of these is the culprit:
"-Djdk.attach.allowAttachSelf" "-XX:+UnlockDiagnosticVMOptions" "-XX:+DebugNonSafepoints"
from clj-fast.
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.
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.
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.
Alright, yet more jvm corner case magic to understand. If nothing else, the issue is documented for posterity.
from clj-fast.
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.
I think I'll end up adding a few notes to the readme, nothing more I can do in the meanwhile
from clj-fast.
This is the best I could do in the meanwhile
bba3ec0
Edit suggestions?
from clj-fast.
Related Issues (20)
- Faster fast-merge HOT 47
- Clojurescript support? HOT 2
- make sure inlining is wrapped in a function that can be jit'd HOT 4
- Operations on ordered collections (probing) can be faster HOT 6
- better memoize example HOT 13
- faster mapv and others (reference) using iterators HOT 2
- FileNotFoundException when try to use clj-fast HOT 2
- Extend assoc-in to take multiple k-v pairs? HOT 4
- not-found arities of get and get-in HOT 2
- General inliner HOT 11
- Better get-in behavior (maybe already implemented) HOT 6
- JMH
- Improve documentation and guidance
- faster aset HOT 2
- Bug in update-many
- May not be in scope, but fast detection of set intersection
- static-merge HOT 2
- fast-case HOT 8
- fastrecord HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clj-fast.