This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-06-27
Channels
- # babashka (39)
- # beginners (256)
- # calva (33)
- # cider (4)
- # clj-otel (8)
- # clojure (48)
- # clojure-denmark (3)
- # clojure-europe (21)
- # clojure-nl (1)
- # clojure-norway (45)
- # clojure-poland (1)
- # clojure-sweden (2)
- # clojure-uk (5)
- # clojuredesign-podcast (5)
- # clr (13)
- # core-async (9)
- # cursive (12)
- # data-science (2)
- # datahike (80)
- # datomic (5)
- # hyperfiddle (14)
- # introduce-yourself (4)
- # jobs (4)
- # lsp (7)
- # missionary (6)
- # polylith (25)
- # proletarian (5)
- # releases (1)
- # shadow-cljs (12)
- # squint (7)
- # xtdb (2)
What other templating libraries than Selmer exist? Any with whitespace control?
You can try using https://phronmophobic.github.io/dewey/search.html. Apart from "template" that will produce quite a few non-matches, another good search term is "mustache".
thanks
Is there a tool like htop for JVM/Clojure. I’d like something for inspecting running threads and exploring runtime object trees.
yes, for the JVM you have Java Mission Control, or VisualVM
I normally use VisualVM, I find it easier for most cases
if you need very deep monitoring of the inner workings of the JVM, I think the most powerful is JFR (Java Flight Recorder) + JMC (Java Mission Control)
if you are running a repl in a terminal, and just want a thread dump (stack of each thread) you can hit Ctrl+\
and it will dump the threads
For the threads part, in yesterday's thread some options were described https://clojurians.slack.com/archives/C03S1KBA2/p1719422755625319
I think it would help to start with the actual problem you are trying to solve. A running system is constantly changing so you can inspect its snapshot at best. Or you need to actually fire up a debugger and interrupt a thread in whatever it’s doing Also not sure what you mean by runtime object trees
I guess with runtime object trees he refers to a heap dump
@U0739PUFQ whoottt!! never heard abt Ctrl+\ 🤯. I’m only using CIDER+nrepl, does it work there?
no, that only works on the terminal afaik. But you can do the same easily with VisualVM, or other tooling that already comes with the JVM like jstack
By runtime object trees i mean each thread’s tree of reachable objects, i.e the objects which won’t get GCed.
if you don't want to install anything for some reason you can do jps
to figure out the process id, and then run jstack PID
> By runtime object trees i mean each thread’s tree of reachable objects, i.e the objects which won’t get GCed. you can do a heap dump on the JVM also, but that will not be thread related. But you can see all objects in the heap and navigate the references
My immediate use case, is that I was concerned that I started a process, i call it the ingester, in two threads. I would like to see the currently running threads to see if I there was a duplicate so I could shut it down.
jstack PID
will list on the terminal all the threads running and their current methods stacks at the point you run the command, so you can figure out what threads are running, who is doing what, and also who is blocked waiting, etc
the nice thing about tools like VisualVM is that you have all this functionality from a UI, so you don't need to remember all the commands names and their args
both VisualVM and JMC can also analyze Java Flight Recorder files, which is something that can be turned on the JVM to record a bunch of events even on production, since it doesn't almost affect perf
yes, you can connect it to a remote process
but that process needs to be started with some special args, so it can connect to it
take a look at here for remote monitoring https://visualvm.github.io/applications_remote.html
> I never knew about jstack
if you list your jdk bin folder there are a ton of useful commands like jstack
for example jcmd
can send commands to a JVM, for doing a bunch of what VisualVM can do, like heap dump, run the GC, thread dumps, etc
you can do jcmd PID
and it will list all commands available
not sure augmented in what way, for example, if I run jcmd 134400 Thread.print
which does the same as jstack 134400
it will show like :
"main" #1 prio=5 os_prio=0 cpu=7525.64ms elapsed=24340.26s tid=0x00007fa288015df0 nid=0x20d09 waiting on condition [0x00007fa28d9fc000]
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep([email protected]/Native Method)
at nrepl.cmdline$dispatch_commands.invokeStatic(cmdline.clj:497)
at nrepl.cmdline$dispatch_commands.invoke(cmdline.clj:481)
at nrepl.cmdline$_main.invokeStatic(cmdline.clj:504)
at nrepl.cmdline$_main.doInvoke(cmdline.clj:499)
at clojure.lang.RestFn.applyTo(RestFn.java:140)
at clojure.lang.Var.applyTo(Var.java:707)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.main$main_opt.invokeStatic(main.clj:523)
at clojure.main$main_opt.invoke(main.clj:519)
at clojure.main$main.invokeStatic(main.clj:674)
at clojure.main$main.doInvoke(main.clj:626)
at clojure.lang.RestFn.applyTo(RestFn.java:140)
at clojure.lang.Var.applyTo(Var.java:707)
at clojure.main.main(main.java:40)
where you can see clojure and java files lines, and fns namesthat I don't think so, but maybe there are tools that can do that
VisualVM has a plugin system, maybe there is a plugin for a thread dump like that, no idea
for debugging there are a bunch of options, depending on what you need to debug, like : • stepping over java libraries I prefer IntelliJ debugger, if you have Cursive it can also step over Clojure code with some limitations • stepping over Clojure, if you already use Cider, it contains a simple debugger (same as VSCode) • I use http://www.flow-storm.org/ for Clojure debugging, which is time travel, ide independent (disclaimer I work on it) • many other debugging libraries (check the debugging section in https://www.clojure-toolbox.com/)
but happy to answer debugging questions about any approaches
flow storm