babashka-sci-dev 2022-09-09

So I tried adding six additional methods to Babashka that are necessary to implement auto-completion for Java methods. That increased the binary size by 29 Mb. 😬 I’m guessing that’s probably a no-go…

it is likely that you're hitting a dynamic require / resolve which causes this

show me the diff and I'll be able to tell you

Ī» du -h /usr/local/Cellar/babashka/0.9.161/bin/bb
 69M    /usr/local/Cellar/babashka/0.9.161/bin/bb
Ī» du -h bb # Compiled after the changes above
 98M    bb

have you done an experiment to see what exactly causes the difference, any one of those specifically?

I haven’t yet.

Hold on while I sacrifice some CPU cycles at the altar of progress…

šŸ™‡ 1

By the way, I ran upx on bb just for fun and it brings the binary size down to 21M. ’Course, can’t be sure it doesn’t break anything, though.

it increases startup time

Oh, I see. šŸ‘

btw there was also a request recently to add clojure.reflect in bb - since we're already using it in the nrepl server it might just be a small addition

Hmm, OK. Well, that depends on a number of java.lang.reflect things, too, I think.

yes, but we're already using it and it didn't impact the image size that much

this is why it would be interesting to see which one of the above is the offender

perhaps package makes a lot of things reachable

Ah, OK, I misunderstood. Yeah, I’ll figure it out.

It doesn’t seem to be Package. That’s the first one I tried.

well it isn't the method addition since the image even became smaller here when I added that ;)

Hmm, heh. šŸ™‚

Init:
-rwxr-xr-x  1 borkdude  staff  71656399 Sep  9 18:01 ./bb

Added methods to reflect.Method:
-rwxr-xr-x  1 borkdude  staff  71639887 Sep  9 19:58 ./bb

Added java.lang.reflect.Modifier
-rwxr-xr-x  1 borkdude  staff  71639887 Sep  9 20:01 ./bb

what did you add wrt/

java.lang.reflect.Field

it's not clear to me from the diff

Oh, hold on. I just realized I’m using an older version of GraalVM. Can that affect the size?

Just getName.

I’ll install the correct version, too.

Added java.lang.reflect.Field
-rwxr-xr-x  1 borkdude  staff  71639887 Sep  9 20:06 ./bb    

Well. I must be doing something wrong, then.

now the only one left is package

And after adding package:

$ ls -lat ./bb
-rwxr-xr-x  1 borkdude  staff  71639887 Sep  9 20:09 ./bb

It is the old GraalVM version. picard-facepalm

basically no growth

I'll make a branch and push it so it can run on CI

Yeah, I got the same result after updating GraalVM. Sorry for wasting your time.

the newest graalvm is also a lot faster. which version did you use

graalvm@21.1.0

interesting

(It is the latest available version on jabba, which is why I initially thought it is the latest available version period.)

Well, I guess it’s good to know that they’ve optimized it to that extent. šŸ™‚

let's follow the image sizes in #babashka-circleci-builds

šŸ‘ 1

$ ls -lat ./bb
-rwxr-xr-x  1 borkdude  staff  71639887 Sep  9 20:53 ./bb
with your PR... still nothing. Would appreciate it you could post a diff based on the previous commit, an absolute number doesn't say it all since the image size varies per environment

Gotcha. šŸ‘

These changes’ll get us here: https://tutkain.flowthing.me/bb2.mov

Heh. šŸ™‚ Let’s see how long it takes for me to ship this. šŸ˜›

Anyway, thanks once again. šŸ™‡

No problem, thank you for moving things forward :)