babashka-sci-dev

flowthing 2022-09-09T17:24:38.232329Z

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…

borkdude 2022-09-09T17:26:37.778569Z

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

borkdude 2022-09-09T17:26:44.337909Z

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

flowthing 2022-09-09T17:29:17.149389Z

borkdude 2022-09-09T17:43:35.310159Z

That's it?

flowthing 2022-09-09T17:43:39.506609Z

Yes.

flowthing 2022-09-09T17:45:18.450859Z

Ī» 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

borkdude 2022-09-09T17:45:32.357369Z

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

flowthing 2022-09-09T17:45:39.086909Z

I haven’t yet.

flowthing 2022-09-09T17:45:53.317019Z

Could do.

flowthing 2022-09-09T17:47:13.845209Z

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

šŸ™‡ 1
flowthing 2022-09-09T17:48:58.955279Z

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.

borkdude 2022-09-09T17:49:14.683169Z

it increases startup time

flowthing 2022-09-09T17:49:32.608409Z

Oh, I see. šŸ‘

borkdude 2022-09-09T17:51:59.498799Z

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

flowthing 2022-09-09T17:54:05.052959Z

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

borkdude 2022-09-09T17:54:42.209799Z

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

borkdude 2022-09-09T17:55:03.023509Z

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

borkdude 2022-09-09T17:55:11.562419Z

perhaps package makes a lot of things reachable

flowthing 2022-09-09T17:55:14.902309Z

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

flowthing 2022-09-09T17:55:33.076019Z

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

borkdude 2022-09-09T17:59:24.478679Z

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

flowthing 2022-09-09T18:01:05.191279Z

Hmm, heh. šŸ™‚

borkdude 2022-09-09T18:02:43.637909Z

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

borkdude 2022-09-09T18:03:59.488939Z

what did you add wrt/

java.lang.reflect.Field

borkdude 2022-09-09T18:04:04.254079Z

it's not clear to me from the diff

flowthing 2022-09-09T18:04:24.337039Z

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

borkdude 2022-09-09T18:04:32.387949Z

possibly

flowthing 2022-09-09T18:04:32.698759Z

Just getName.

flowthing 2022-09-09T18:04:41.673389Z

I’ll install the correct version, too.

borkdude 2022-09-09T18:07:01.180639Z

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

flowthing 2022-09-09T18:07:35.771089Z

Well. I must be doing something wrong, then.

borkdude 2022-09-09T18:07:38.452359Z

now the only one left is package

borkdude 2022-09-09T18:09:56.679449Z

And after adding package:

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

flowthing 2022-09-09T18:09:58.510419Z

It is the old GraalVM version. picard-facepalm

borkdude 2022-09-09T18:10:09.950539Z

basically no growth

borkdude 2022-09-09T18:10:19.169659Z

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

flowthing 2022-09-09T18:10:37.846929Z

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

borkdude 2022-09-09T18:10:55.441659Z

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

flowthing 2022-09-09T18:11:07.788429Z

graalvm@21.1.0

borkdude 2022-09-09T18:11:16.112259Z

interesting

flowthing 2022-09-09T18:11:39.791849Z

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

flowthing 2022-09-09T18:12:20.865579Z

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

borkdude 2022-09-09T18:12:31.081909Z

https://github.com/babashka/babashka/pull/1360

šŸŽ‰ 1
borkdude 2022-09-09T18:12:50.711679Z

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

šŸ‘ 1
borkdude 2022-09-09T18:24:48.253189Z

@flowthing Merged

šŸŽ‰ 1
borkdude 2022-09-09T18:55:05.746039Z

$ 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

flowthing 2022-09-09T19:00:22.174739Z

Gotcha. šŸ‘

flowthing 2022-09-09T19:03:51.612879Z

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

flowthing 2022-09-09T19:11:17.312319Z

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

flowthing 2022-09-09T19:11:28.190549Z

Anyway, thanks once again. šŸ™‡

borkdude 2022-09-09T19:14:37.728489Z

No problem, thank you for moving things forward :)