clojure-goes-fast / clj-async-profiler

Embedded high-precision Clojure profiler
http://clojure-goes-fast.com/kb/profiling/clj-async-profiler/
411 stars 17 forks source link

Error when using 0.2.0+ #8

Closed SevereOverfl0w closed 4 years ago

SevereOverfl0w commented 5 years ago
dev=> (require 'clj-async-profiler.core)
nil
dev=> (clj-async-profiler.core/profile {:return-file true}
 #_=>                                  true)
Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (URLClassLoader.java:382).
com.sun.tools.attach.VirtualMachine
❯ java -version          
java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)

OS: Linux x64

0.2.0+ gives me:

dev=> (clj-async-profiler.core/profile {:return-file true}
 #_=>                                  true)
Execution error (NullPointerException) at clj-async-profiler.core/mk-vm (core.clj:162).
null
alexander-yakushev commented 5 years ago

I can't reproduce this. Which Leiningen version are you using?

Here's what I get (2.8.3):

user@hostname:~$ lein update-in :dependencies conj "[com.clojure-goes-fast/clj-async-profiler \"0.3.0\"]" -- repl
nREPL server started on port 46348 on host 127.0.0.1 - nrepl://127.0.0.1:46348
REPL-y 0.4.3, nREPL 0.5.3
Clojure 1.8.0
OpenJDK 64-Bit Server VM 1.8.0_181-8u181-b13-1ubuntu0.16.04.1-b13
...
user=> (require '[clj-async-profiler.core :as prof])
nil
user=> (prof/list-event-types)
Basic events:
  cpu
  alloc
  lock
  wall
  itimer
Perf events:
  page-faults
  context-switches
  cycles
  instructions
  cache-references
  cache-misses
  branches
  branch-misses
  bus-cycles
  L1-dcache-load-misses
  LLC-load-misses
  dTLB-load-misses
  mem:breakpoint
  trace:tracepoint

nil

I tried with Clojure 1.10 too and it works.

SevereOverfl0w commented 5 years ago

My JVM output isn't too useful apparently. I've switched to Oracle-JDK (I think I was using Oracle JRE before) and it now seems to work.

It was an accident that I had the jre.

barkanido commented 4 years ago

Is using the Oracle JDK is a requirement? Or one merely needs to somehow point the profiler to libasyncProfiler-linux.so as mentioned in https://github.com/jvm-profiling-tools/async-profiler#profiling-java-in-a-container:

Also make sure that the target container can access libasyncProfiler.so by the same absolute path as on the host.

what is needed in order for a project that depends on this clj-async-profiler to profile correctly given:

Asking in another way- maybe the docs missing the recommended way to package the vendor/ files?

alexander-yakushev commented 4 years ago

A specific JDK vendor is not a requirement (it should work with Oracle JDK, OpenJDK, J9, whatever), but it has to be a JDK, not just a JRE distribution.

The .so file is unpacked automatically by the library, you don't have to do it yourself, regardless of whether it runs on the host machine or inside a container.

To run inside a container, you have to make sure that seccomp option is provided, like the link you posted says. You also need to set perf_event_paranoid on the host machine.

Can you first try to figure things out on a host machine and then try to reproduce it under Docker? I think this would be easier.

barkanido commented 4 years ago

from docker:

bash-4.4$ cat /proc/sys/kernel/perf_event_paranoid
1

from the host:

$ grep CONFIG_SECCOMP= /boot/config-$(uname -r)
CONFIG_SECCOMP=y

from docker:

bash-4.4$ cat /proc/1/status | grep Seccomp
Seccomp:        0

So, what do you think? Should this be enough? What else is required from the JDK?

alexander-yakushev commented 4 years ago

Can you describe what happens, what exactly doesn't work?

SevereOverfl0w commented 4 years ago

I haven't seen this in a long time, I suspect it was the JRE/JDK thing.