This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # aleph (7)
- # announcements (11)
- # beginners (186)
- # calva (17)
- # cider (26)
- # clj-kondo (4)
- # cljdoc (12)
- # cljs-dev (3)
- # clojars (1)
- # clojure (105)
- # clojure-berlin (1)
- # clojure-chicago (1)
- # clojure-dev (34)
- # clojure-europe (3)
- # clojure-italy (4)
- # clojure-nl (27)
- # clojure-russia (19)
- # clojure-uk (25)
- # clojuredesign-podcast (4)
- # clojurescript (54)
- # cursive (6)
- # data-science (1)
- # datascript (11)
- # datomic (5)
- # emacs (3)
- # events (2)
- # fulcro (13)
- # graalvm (5)
- # jobs (15)
- # leiningen (7)
- # luminus (3)
- # melbourne (1)
- # nrepl (1)
- # nyc (2)
- # onyx (4)
- # pathom (6)
- # pedestal (18)
- # re-frame (19)
- # reagent (10)
- # shadow-cljs (27)
- # spacemacs (32)
- # sql (11)
- # tools-deps (35)
- # vim (50)
Wow, I don't have enough evidence collected to confirm this hypothesis, but I might be seeing a case of JVM's JIT optimizing the method clojure.lang.Util.hasheq differently in two scenarios: (scenario 1) 99.9% of the calls to that method were with type Long (scenario 2) large fraction of calls were with type long, but also a large fraction with type PersistentHashSet. In scenario 2, the clojure.lang.Util.hasheq calls on type long are much much slower.
If that hypothesis is true, then I am awestruck with the extra levels of complexity of predicting the performance of code running on the JVM.
without knowing more that sounds like could be difference between monomorphic and bimorphic inlining
These measurements are with OpenJDK 11.0.3 installed via apt-get on Ubuntu 18.04 Linux. I don't have clj-async-profiler measurements on macOS running Oracle/Apple JDK 1.8.0_192 but am seeing similar overall elapsed times of the two scenarios there.
If you're really interested, check out Aleksey Shipilev's blogs like https://shipilev.net/jvm/anatomy-quarks/16-megamorphic-virtual-calls/
you can pass jvm options to see what the jvm is doing around a lot of these kinds of things
Thanks for the link. I will at least start down the rabbit hole, but not sure how far I want to go just yet.
it's normal for bimorphic or megamorphic things to not inline as well so what you said above does not seem surprising to me
Clojure protocol call-site caches have the same kind of potential issue - last choice is cached, so monomorphic case will perform much better
Over the years I've worked with Clojure, I've often found that I've wanted to work with data -- hash maps -- but also work with Java objects that have setters. An example I'm working with right now is HikariCP and there's a Clojure wrapper that supports Clojure hash maps and turns them into
.setFooBar calls for
:foo-bar members. I want to do this in general and it feels like this ought to be part of core. Do we already have something that I'm just missing? Is this something that might be considered for core?
I've written macros in limited domains to do this kind of thing in the past, as always depends how generic and/or customizable you want to make it
@hiredman It's close.
:fooBar is needed instead of
:foo-bar but it's close enough that I can use it for what I'm trying to do. Thanks.
well, that's the customizability - can overload the multimethod to fix
Turns out that
org.clojure/java.data does exactly what I need for
next.jdbc to use c3p0 and HikariCP so I can bake that into the library with minimal effort.
My performance problem sanity is restored -- I should have been looking for a simpler explanation, which was that clojure.lang.Util/hasheq was being called so many more times in my 10x worse performance scenario, about 10x more times, in fact. Duh. Application code that was the cause found and fixed.
It was not the cause of any problems for me, but was curious if you thought there may be any interest in a CLJ JIRA performance-related ticket on the equiv() methods I found that lack an identical fast path?
sure, if you happened to find a path where that's not used and makes a demonstrable difference
I can add a scenario to the ticket where it can show up -- using maps or sets as keys in array-map's, and the maps/sets you look up or assoc on are identical to the ones added earlier.
also, the equiv() methods that lack those identical fast paths are probably over typical inlining code size limits, I would guess, but can investigate that further, later.
playing with NaN
(= ##NaN ##NaN) => false (not= ##NaN ##NaN) => false (apply = [##NaN ##NaN]) => false (apply not= [##NaN ##NaN]) => true
on the long case - with
array-map, I see the all the action being in the
Regarding method/function call counts on the JVM, I know that JVMs often make decisions on which methods to JIT based upon call counts, at least as one of the deciding factors. Do Flight Recorder and/or other perf tools make those call counts visible, without having to modify the code?