Fork me on GitHub
#graalvm
<
2019-11-23
>
mattsfrey20:11:09

has anyone had trouble compiling with native image getting this error:

ERROR! Error: Main entry point class 'app.server-main' not found.
com.oracle.svm.core.util.UserError$UserException: Main entry point class 'app.server-main' not found.

borkdude21:11:07

@mattsfrey maybe you need to write app.server_main?

mattsfrey21:11:38

wow, yeah that was the problem, thanks!

mattsfrey21:11:44

..although now it’s been building at max cpu+mem usage for like 15+ mins with no end in sight 😒

borkdude21:11:55

what are you compiling?

borkdude21:11:04

No markdown in the channel topic 😉

mattsfrey21:11:00

going to take the dog on a long walk and see if the build ever finishes, after that if it was actually successful I’ll try running it in a container to try and isolate thing

mattsfrey21:11:21

guessing the classpath is ginormous

borkdude21:11:04

@mattsfrey @lee has a similar issues just with compiling clojure.test.

borkdude21:11:23

Requires 12gb of ram and takes 15 minutes or so.

borkdude21:11:45

So far I've had luck with smallish command line apps and a Clojure interpreter which is tweaked to be graalvm friendly

borkdude21:11:02

These all compile under 1 minute on my machine even on a 8GB laptop

mattsfrey21:11:08

any links for the tweaked clojure?

lread21:11:27

heya 👋

borkdude21:11:44

@mattsfrey It's mostly about avoiding reflection and avoiding CLJ-1472

borkdude21:11:43

And read-string and that kind of stuff, basically everything which requires eval

borkdude21:11:22

it's probably easier to start small and then build up, so you can see where it trips up graalvm

mattsfrey21:11:48

yeah unfortunately I’m starting with a very beefy fullstack framework

mattsfrey21:11:37

I’d have freed up some ram if I had known it was this bad, using like 3.6 wired and 7gb swap atm

lread21:11:48

Are you limiting RAM to native-image? default max is 14gb.

mattsfrey21:11:38

no I had a ton of other crap open though, multiple intellij windows, bajillion chrome tabs etc

lread21:11:14

not sure what target OSes you are trying to build for... if linux only drone cloud might be an option as it has 64gb RAM available for build.

mattsfrey21:11:07

ultimately deploying to linux only

mattsfrey21:11:12

building on osx atm

lread21:11:46

feel free to ask more questions, but also.. please consider contributing anything you learn to our repo: https://github.com/lread/clj-graal-docs

mattsfrey21:11:01

mostly experimenting with this to lower the memory footprint clojure microservices use in prod, if the builds require non trivial ram and take huge amounts of time this probably isn’t a feasible option

mattsfrey21:11:24

sure, i’ll definitely tinker around

borkdude21:11:41

that's also my rule of thumb: if it doesn't compile under 2 minutes with 3gb of ram, it's probably not going to work out well

mattsfrey21:11:16

i’ll spend more money on build costs than the savings in server ram ultimately once hooked to ci/cd lol

lread21:11:45

max out your RAM as big as you can to start... my stuff compiled in 3 minutes with 16gb an, 11 minutes with 8gb and failed with 4gb with out of memory after 1 hour.

mattsfrey21:11:58

I think trying to get a clean container with minified classpath and all that and then tweaking ram options might help, will have to see

mattsfrey21:11:31

I’ve been also looking at some clojure-to-go compilers but they seem pretty half baked

lread21:11:26

here's my drone cloud config, if you need a sample: https://github.com/lread/rewrite-cljs-playground/blob/master/.drone.yml. Note that my goal for this was to just run my tests after natively compiled by GraalVM.

mattsfrey22:11:08

it finally finished! ERROR! Fatal error: java.lang.OutOfMemoryError: Java heap space facepalm

lread22:11:49

yeah a slow run usually ends in that.

lread22:11:31

at least in my experience

mattsfrey23:11:29

throwing 24GB at it on my work station with 8 cores, will have to see how this goes

mattsfrey23:11:36

I think regardless this build process is going to be way too heavyweight for a while to use with production deployments

mattsfrey23:11:06

seems like its mostly useful for cli tools you can build and distribute binaries of

mattsfrey23:11:21

I would like to do another test on linux and see if that makes a difference vs running on osx

lread23:11:22

yes, you may be right there. native-image can be very RAM hungry!

lread23:11:48

I'm glad you are doing this experiment though. Gives us more intel! simple_smile

mattsfrey23:11:00

yeah its a cool project

mattsfrey23:11:23

would love to see more work in the area of getting native clojure

mattsfrey23:11:11

having to allocate 512mb ram per instance kind of kills using clojure in a microservice arch if you’re on a slim budget

mattsfrey23:11:19

probably going to just stick to monolithic backends because I’m loathe to write in a different language at this point

mattsfrey23:11:28

might also look into cljs with node for backend microservices

borkdude23:11:11

@mattsfrey the tradeoff between graalvm native and a normal JVM is usually latency vs throughput. the JVM is optimized for throughput

borkdude23:11:39

for long running servers throughput is more important than startup latency

borkdude23:11:29

for example, linting thousands of files with clj-kondo is faster on the JVM than with the native version of clj-kondo, but linting a single file is faster with the native version, because of the startup time

mattsfrey23:11:05

I’m mostly interested in the lower memory footprint

borkdude23:11:09

yeah, that's also one benefit of it. there are some Java microservice projects doing this with GraalVM, you could maybe explore those

mattsfrey23:11:56

yeah I’ve seen this

borkdude23:11:27

but it's maybe also good to not start with a huge framework to compile graalvm. I can imagine that just compojure + jetty could compile fine maybe

mattsfrey23:11:52

yeah that’s the other thing — I picked a super bulky framework with a huge ammount of deps to start with

mattsfrey23:11:18

would be nice to see what a minimalist backend would look like

borkdude23:11:34

could try to compile it to graalvm to see if it works one day

lread23:11:22

that seems like an interesting experiment @borkdude!

lread23:11:01

I'm going to add a git issue to clj-graal-docs to remind us.

borkdude23:11:23

ok. sleepy time here, bye