This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-31
Channels
- # announcements (1)
- # aws (4)
- # babashka (40)
- # beginners (89)
- # calva (13)
- # cider (3)
- # clj-kondo (36)
- # cljdoc (16)
- # clojure (74)
- # clojure-boston (1)
- # clojure-dev (7)
- # clojure-europe (30)
- # clojure-new-zealand (1)
- # clojure-nl (17)
- # clojure-uk (5)
- # clojurescript (16)
- # core-async (9)
- # cursive (16)
- # datahike (3)
- # datalog (6)
- # datascript (7)
- # datomic (15)
- # emacs (38)
- # events (2)
- # figwheel-main (3)
- # fulcro (6)
- # google-cloud (18)
- # graalvm (6)
- # gratitude (1)
- # honeysql (1)
- # introduce-yourself (1)
- # jobs (1)
- # leiningen (5)
- # lsp (6)
- # malli (11)
- # meander (2)
- # off-topic (4)
- # re-frame (6)
- # reitit (8)
- # releases (2)
- # remote-jobs (3)
- # reveal (4)
- # shadow-cljs (200)
- # sql (8)
- # tools-deps (16)
Is there an EDN parser that can output a full AST including line and column numbers?
EDN is a subset of Clojure syntax, right? If so, when it comes to parsing Clojure code while getting info on line/column numbers people always mention rewrite-clj.
perfect, thanks!
I am trying to optimize a clojure function. When I use Java VisualVM to look at the running process. I see low CPU utilization, however, about 1000 classes are created per call. The function in question is recursive (non-tail), is that the likely culprit? Or is there another known reason why crap tons of classes would be created? Thanks in advance for any advice!
Classes
graph coming…
I can share that but not the data (without obfuscating it). one sec. thanks!
Green circles are func in question, when run from repl
(defn- process-message
[hl7 parsed segment-defs func]
(let [_ nil]
(loop [parsed (remove-unknown parsed (all-known-segments segment-defs))
remaining segment-defs
result {}
lines-read 0]
(if-let [seg-def (first remaining)]
(if-let [seg (first parsed)]
(cond
(some? (seg-def :pea.hl7/id)) (let [seg-def-id (seg-def :pea.hl7/id)
seg-details (get-in hl7 [:pea.hl7/segments seg-def-id])
;_ (println (str "seg-details: " seg-details))
title-key (keyword (.replace (.toLowerCase (seg-details :pea.hl7/desc)) " " "-"))
seg-id (select-first [0 0 0 0] seg)
not-repeating (= :pea.hl7/none (seg-def :pea.hl7/repeatability))
_ nil]
(if (= seg-def-id seg-id)
(if not-repeating
(recur (rest parsed) (rest remaining) (assoc result title-key (func seg seg-def)) (+ lines-read 1))
(let [previous (or (result title-key) [])
value (func seg seg-def)
values (conj previous value)]
(recur (rest parsed) remaining (assoc result title-key values) (+ lines-read 1))))
(recur parsed (rest remaining) result lines-read)))
(some? (seg-def :pea.hl7/segments)) (let [title-key (keyword (.replace (.toLowerCase (seg-def :pea.hl7/segment-group)) " " "-"))
segments (seg-def :pea.hl7/segments)
not-repeating (= :pea.hl7/none (seg-def :pea.hl7/repeatability))
sub-proc (process-message hl7 parsed segments func)
sub-group (sub-proc 0)
lines-to-drop (sub-proc 1)
_ nil]
(if not-repeating
(recur (drop lines-to-drop parsed) (rest remaining) (assoc result title-key sub-group) (+ lines-read lines-to-drop))
(let [previous (or (result title-key) [])
values (conj previous sub-group)
the-remaining (if (= 0 lines-to-drop) (rest remaining) remaining)]
(recur (drop lines-to-drop parsed) the-remaining (assoc result title-key values) (+ lines-read lines-to-drop)))))
:default (throw (Exception. (str "Don't really know how we got here: " remaining))))
[result lines-read])
[result lines-read]))))
How so?
Thats what I thought 🙂
dynamic classes I guess?
clojure.lang.DynamicClassLoader.defineClass() is using the majority of time when “sampleing” the process in Java VisualVM… screenshot coming
If the profile is since JVM startup and the function was not AOT compiled, is it possible?
no defrecords, just maps. Ill look for calls to eval I might not be remembering.
I am on java8 (macOS) is that a hnt?
well darn
jvm failed to start with that
thanks, trying that
So thats interesting…. the verbose
gives me lines like this:
[Loaded pnx.hl7.discharge_window$eval22184 from JVM_DefineClass__] [Loaded pnx.hl7.discharge_window$eval22188$fn__22189 from JVM_DefineClass__]
‘discharge_window’ is the namespace I am using in repl to explore this
is the slowness just from running in a repl?
when I use this: (set! warn-on-reflection true)
I get this: Reflection warning, /Users/lucasjordan/pea/workspaces/pnx-api/siderail/pnx/hl7/discharge_window.clj:47:1 - call to method replace can’t be resolved (target class is unknown).
A similar number of times
If you're running with Leiningen you might have a flag which disables JIT which will make things slower
Reflection is also expensive, try type hinting .replace
with ^String
I'm not sure how Clojure's reflector works, does it define classes?
It was a deeply buried eval I thought was being called before my testing, but was lazyliy being called…. thanks everyone for the help!!
use a snippet if possible (CMD-Shift-Enter, you can even have it highlight clojure syntax)
the intention here is to take a list like [{},{},{},{},{},{},{},{}] and turn it into this: [{}, {}, [{} {}], {:a {} :c [{} {}]}] based on some rules
I posted this a few weeks back, but since we're still looking for more responses, I'll post it here one more time for those who missed it: The Programing Research Laboratory at Northeastern University is conducting a study on the usability of visual and interactive syntax for ClojureScript. Participation involves filling out a questionnaire and is expected to take about 30 minutes. The questionnaire consists of multiple choice and free form responses. All questions are optional and responses are anonymous. If you are interested in participating, please visit: https://study.visr.pl (Chrome Recommended) To learn more about visual and interactive syntax for ClojureScript, please visit: https://prl.ccs.neu.edu/blog/2022/01/06/introducing-visual-and-interactive-syntax-realized-visr-for-clojurescript-and-javascript If you have any questions, please contact: <mailto:[email protected]|[email protected]>
@lucasjordan another thing you can do is turn on logging when classes are loaded:
-Xlog:class+load=info
Working on finally updating the https://github.com/jarcane/clojurice template, and running into the dreaded "illegal reflective access operation" errors, and even after updating pretty much every dependency possible in the entire application I'm still getting it. It's not even the same one all the time: in local dev, I get the error on the XNIO library, while on Travis, the CI logs show an error in dynapath. I managed to find an old issue about the latter but it indicated it should've been fixed years ago. Will attach boot show -d
in the thread, would welcome any ideas; I've scared up and down the tree and I'm not sure where the culprit is or if I can fix it.
you need to look at the error message and see where it occurred and fix that, blindly updating deps isn't guaranteed to fix anything
I would strongly recommend using the suggestion at the end there to use the debug setting
immutant is, I believe, no longer maintained, so there are much newer releases of the underlying libraries there
the warning I get is this:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (file:/home/annarcana/.m2/repository/org/jboss/xnio/xnio-nio/3.3.6.Final/xnio-nio-3.3.6.Final.jar) to constructor sun.nio.ch.EPollSelectorProvider()
WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release