This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-25
Channels
- # announcements (8)
- # babashka (58)
- # beginners (59)
- # biff (4)
- # calva (39)
- # cider (2)
- # clj-kondo (8)
- # clj-together (4)
- # cljdoc (5)
- # cljsrn (1)
- # clojure (60)
- # clojure-australia (2)
- # clojure-europe (16)
- # clojure-nl (1)
- # clojure-norway (3)
- # clojurescript (13)
- # conjure (10)
- # cursive (9)
- # datomic (5)
- # dev-tooling (1)
- # emacs (6)
- # events (1)
- # graalvm (38)
- # graphql (5)
- # joyride (1)
- # kaocha (3)
- # lsp (23)
- # malli (2)
- # mount (2)
- # off-topic (31)
- # other-languages (13)
- # pathom (3)
- # polylith (12)
- # portal (4)
- # practicalli (22)
- # re-frame (6)
- # reagent (3)
- # releases (3)
- # sql (4)
- # squint (3)
- # tools-build (10)
- # tools-deps (10)
- # xtdb (4)
I'm looking to create a minimal statically linked (using musl) native-image Clojure build. My one-liner hello world app with zero dependencies currently weighs in at 17 MB (5MB with UPX). How can I shrink it more?
@U04V15CAJ is expert on doing that
(I'm including --enable-http
here because I'll need it eventually – without that flag the resulting build is 13MB)
Since it's just a hello world, probably there is nothing that much to improve on clojure side
(oh and I'm using https://github.com/clj-easy/graal-build-time)
https://github.com/borkdude/dynaload may be a good lib to consider depending on how much your code increase
(and -Dclojure.compiler.direct-linking=true
)
yeah, thanks
clojure-lsp adds
-H:ServiceLoaderFeatureExcludeServices=javax.sound.sampled.spi.AudioFileReader \
-H:ServiceLoaderFeatureExcludeServices=javax.sound.midi.spi.MidiFileReader \
-H:ServiceLoaderFeatureExcludeServices=javax.sound.sampled.spi.MixerProvider \
-H:ServiceLoaderFeatureExcludeServices=javax.sound.sampled.spi.FormatConversionProvider \
-H:ServiceLoaderFeatureExcludeServices=javax.sound.sampled.spi.AudioFileWriter \
-H:ServiceLoaderFeatureExcludeServices=javax.sound.midi.spi.MidiDeviceProvider \
-H:ServiceLoaderFeatureExcludeServices=javax.sound.midi.spi.SoundbankReader \
-H:ServiceLoaderFeatureExcludeServices=javax.sound.midi.spi.MidiFileWriter
to remove some unused stuff, but TBH I don't remember if that is worth/if affects that much the sizehmm okay
yeah, doesn't seem to make a difference
guess I'll write this thing in Rust instead 🙂
a utility that I'm packaging as a container, and that I need to be as small as possible to reduce latency when downloading it
a reduction in size with upx doesn't even outweigh the smaller download, since the download is already zipped
They just have a new Node 18 runner. ARM runners are the fastest especially when you choose more memory
it's for something more like a backend for running lambdas
I could make sure to load it upfront of course, in which case it wouldn't be that big a deal
if its the download latency youre worried about, id go with #nbb or layer in the binary in the runtime
but might as well go for smaller size so I can download it when I need it
ive used https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html for fat binaries before
thanks! 🙂
Also I think now you can also have ram loaded preemptively into AWS Lambda, so that startup time can become really minimal. I have not checked it out, but https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html?icmpid=docs_lambda_rss
There's also tools that compress your exe and decompress and run them at runtime, like UPX and gzexe https://upx.github.io/ https://linux.die.net/man/1/gzexe