You
Is the
A Clips Tamarin, a freely available distribution of open JDK, gets downloaded more than
10 million times a month across various JDK versions.
JDK image size improvements could have saved them about $30,000 US dollars of hypothetical
content delivery and at work costs.
In this talk, I'm going to show you what made those savings possible in JDK 24 and
how you as a travel developer or an application-bundler can profit from a similar savings
by reducing the size of your runtime that you bundle with the application.
Hi, I'm Siddling Gable, I'm a software engineer with Red Hat and about 2023, I was trying
to use J-Link to create an application bundle a custom runtime for my application and at
the time I had a distribution and had that didn't ship the J-mods, the package modules
with it.
I got disappointed really fast because it didn't work, I couldn't create my runtime.
So I thought, yeah, okay, I've been working on Open JDK for a while, like eight years and
then an Open JDK maintainer for, I don't know, five years this and I thought, okay, you
can contribute another republic to fix this problem and imagine my surprise when it took
me probably two years from the initial prototype to get this feature shipped in JDK 24
with Jet493.
Okay, so let's take a quick look back what changed.
The past JDK was JDK-23 and it looked about like this, right?
So if you download a JDK in this case I've used the clips, you see this when you extract
it to a folder, go there and see some sizes, right?
So the lip folder is about three quarters and there's a folder called J-mods, that's one
quarter and this, this CHAP493 basically goes ahead and removes this.
So you can still run J-Link, but you don't no longer need the J-mods to run J-Link.
So how does that look when you compare the JDK's, JDK version 23 and an EA build of
the Clips Tamarin that enables that CHAP, this is what it looks like, so the archive size
is the black bar and the extracted size is the red bar.
So for JDK-23 the archive size was about 200 megabytes in size and the JDK EA build
is about 133 megabytes in size in the archive and extracted it's 350 megabytes and 200
and it's close to 300 megabytes in size.
So this got the JDK about 35% smaller in archive size and about 15% smaller extracted
on disk.
Hold on a little, you just said the CHAP problem is 25% yeah there were other CHAPs that
got included with JDK-24 and there's one that that compressed object headers and includes
a new class that a sharing archive or two and 30 megabytes each so the CHAP493 reduced
it by 25% and then the CHAP 450 I think increased it a little bit again.
So this is how those 25% smaller are on disk and what the CHAP promises.
Okay so we have heard the Clips Tamarin could have saved 30,000 US dollars the past month.
It's a hypothetical cost I did some calculation and there being being sponsored by GitHub
so it's not a real one for them because I'd like to get up and what made those cost savings
possible was basically those size reduction of the archive size they transferred terabytes
of data every month and so how could you as a Java developer have the same benefit right
if you're bundling your application with a runtime or you provide an application with a container
and ship that a lot over the network then size matters and this is where custom runtime
images come in. So here's this scenario in this case I've picked the Quarkes application
I rest application running on the class path it requires a couple of JDK modules
Java logging, Java naming, JDK unsupported so I do want to ship that application to your
customers or users. Okay here's an option bundled at JDK how would that look like so we have
a live application 17 megabytes in size and then bundled at JDK but is about 300 megabytes
in size so there's who here uses the GRE or has heard of a GRE still
a lot okay doesn't really exist anymore but there's there's many many that still shipped
the chair E or what they call GRE it's just essentially it's it's it's JDK with fewer
modules in it and so I put that on the jar that just to to have an idea where the JDK
chair E here sits if you bundle out with their application and what you can do if you do
a custom runtime. So let's draw into this this is JDK 24 right so it has
jet 493 enabled and it already removes the j-mots folder. So basically 99% of the files
are in the live folder now so j-mots is gone and this is how I structured it if you go
and look there's a couple of s-o files without the j-m and there's a couple of other files
that I just put randomly in there it's a small size right 8 megabytes in size and 10
megabytes in size and there's the source tip okay a clips time range of some of the source
tip it's nice if you want a debug but you can remove that it's so it's you can ship
that or not this doesn't really matter here and then there's the jvm which is about
6886 megabytes in size and you cannot really remove that right and then there is this
live modules file right then how important megabytes wow that's almost half
the size of the entire extracted trouble and what you really want to look at is how do
you get this thing it's a signal file how do you get this thing smaller and yeah so what I'm
getting it bundling the j-dk or the chair e which no longer exists isn't probably the
best idea so here's a little observation right if you look at the default jdk it comes
with a set of modules 69 of them it includes modules such as jdk hotspot agent who knows
what that does a few of them and there's jdk internal ed so it comes with many modules and
probably half of them you don't need and then there's if you create a runtime that only includes
jvc that's that's 17 megabytes in size 21 modules okay and and and the the live modules files
rings if I remove the modules if it just includes Java base I have a live modules file of
30 megabytes okay but you really want to think about is go figure out what your application needs
in terms of modules in jdk modules and create a custom runtime so you select the modules that you need
right don't don't add the extra stuff that you never care about and you get a smaller size
so in order to do that you want to use jlank okay wait the you mentioned that the j mods
folder is gone and you you how do you use jlank but yeah well that was that is was what
493 does it enables you to use jlank without the j mods folder and you can create a custom
runtime so you get a smaller jdk download and then you run jlank on it to create a
smaller runtime and here is how you would figure out this is this is this this this this
interesting jdk build that enables running jlank without the j mods folder it says
okay the build is linking from runtime image enabled if it's enabled it's a build time option that
has to be enabled by your distributor and once it's enabled you can use it so in this case you can download
this jl there and get a jdk and has it enabled so back to our application and to our scenario right
you have an application that you know what modules it needs so you add add modules
put those modules on a line and wait a second you probably are interested in using some other
goodies right you want to you want maybe have some crypto needs or you want to do monitoring on
the result or attach a debugger so in this example I've added a couple of nice nice modules
that the jdk provides because I want to use the debugger and wanted to use jfr and the result
ends up in runtime for a rest at and the application still runs it it's all that that it needs and
that's it and if you're clear if you run the list modules command on the result it shows the actual
list of modules that it's that it includes in your custom runtime okay so how does that look
in terms of size of this lib models file we've we've just figured out okay this is what are in
for the megabytes in size on a default jdk includes 69 modules for your custom runtime in this
example it includes eight modules and 32 is 32 or 33 megabytes in size okay that reduced the
lib modules file by three quarters so what does that look like if you if you compare
bundling your application with a gre which no longer exists and compare it to a custom runtime
so the archive size in this specific case of the small app that only was 17 megabytes in size means
you have an archive size bundling the gre of 72 megabytes and an extracted size of 200 megabytes
and if you use the custom runtime you're a your archive shrinks 50% and you're on this size shrinks
is only 60% of the size if you bundled it with a gre remember the first a few fears earlier slides
showed that there was a jdk and gre and the gre was already smaller right so this is comparing
the gre that it is already smaller and so stop stop using gre bundling and you create your
custom runtime okay so a clips tamarin could have saved hypothetical 30 thousand yes dollars
the past month because they they get download a lot right so and that calculation is based on a
30 35% archive size saving as compared to the previous jdk and if you what I've what I've shown
with this small example app it it brought in a 50% size reduction and so a clips tamarin saved
I think 630 terabytes of data by just a small reduction if you if you not that out to previous
jdk and so what what kind of size or cost savings are you looking at if you if you bundled
the r custom runtime with their application instead of the full jdk or jdk because it's a 50%
reduction of as compared to bundling at jdk and so what now go and create your custom runtime for
your for your application you we've seen that jdk with jdk 24e got smaller in size so you can
even use it in c i c cd systems where you download the jdk and it's already it no longer
ships this jdk stuff and then then you can create your custom runtime on the fly if you need to
update your applications with with the latest security update so go and create your custom runtime
today that's all ahead thank you
any questions no it's not enabled by default so you have to you have to enable it using a
configure switch and create linkable runtime or enable sorry yeah there are a couple of restrictions
like one one that has been put in place that basically if you it immense it immense the jdk
jdk module with a couple of files that jdk needs to look at and so if the idea was to
for now disable this able creating a jdk including jdk jdk jdk if you're doing this mode
because there it uses some files on the file system and if you change the configuration it
fails still but but there's a certain limitations it's in the chat but for now it it just doesn't
allow you by design to create another one with jdk jdk jdk if that's removed then then it will
we will see what the use cases out there are to use to use the this mode instead of the default
with jdk jdk the question the question better okay any more questions thank you
you