Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Understand Flank fat jar size #774

Closed
bootstraponline opened this issue May 8, 2020 · 9 comments
Closed

Understand Flank fat jar size #774

bootstraponline opened this issue May 8, 2020 · 9 comments
Assignees
Milestone

Comments

@bootstraponline
Copy link
Contributor

The Flank fat jar size is 35.3 MB. Let's investigate where all the weight is coming from. Maybe there's an opportunity to slim down the jar?

@bootstraponline bootstraponline added this to the June milestone May 16, 2020
@Sloox
Copy link
Contributor

Sloox commented Aug 26, 2020

Interestingly alot of discussion is about around reducing binary file sizes for android. I think it can be applied here.
Here is an example of reducing kotlin std lib by up to 99% by using the d8 obsfucation tool. It could possibly be applied here to reduce size if we cannot isolate out why it is so big in the first place.
https://jakewharton.com/shrinking-a-kotlin-binary/

@bootstraponline
Copy link
Contributor Author

that's awesome!

@Sloox
Copy link
Contributor

Sloox commented Aug 26, 2020

@bootstraponline ill assign it to myself as i have a good idea where to start. Ill ofcourse wait for the ranking.

@Sloox Sloox self-assigned this Aug 26, 2020
@bootstraponline
Copy link
Contributor Author

Sounds good! For clarity, this ticket is about understanding the size. Once that's known, then I think we'd create another ticket to evaluate solutions.

@Sloox
Copy link
Contributor

Sloox commented Aug 27, 2020

So after some investigation,
The size of the expanded Flank jar contains many dependacies. The following dependacies are listed based on their size when expanded from a built Flank.jar file.

  • Total Size: 145.5 MB
  • com.google-> 31.8 MB
    • common-> 10.4 MB
    • api-> 9.3 MB
    • protobuf-> 6.2 MB
    • cloud-> 2.4 MB
    • gson-> 824 KB
    • other-> ~2.7 MB
  • com.fasterxml.jackson-> 7.3 MB
  • com.ctc.wstx->5.5 MB
  • com.bugsnag-> 286 KBS
  • io.netty-> 25.6 MB
  • io.ktor-> 10.9 MB
  • io.opencensus-> 1.7 MB
  • org.apache.(http, threeten)-> 17 MB
  • kotlinx-> 5.6 MB
  • kotlin libraries -> 18.5 MB
  • Binaries
    nm-> 17MB

The largest collection of libraries come from the com.google namespace, then from io.netty, io.ktor and general kotlin libraries.

I will look into the actual dependancies in gradle and try see if there are any obvious issues.

@bootstraponline
Copy link
Contributor Author

Awesome. might be worth looking into graalvm

use a Graal native image to produce a minimal native binary

https://jakewharton.com/shrinking-a-kotlin-binary/

@Sloox
Copy link
Contributor

Sloox commented Aug 28, 2020

Yes, @bootstraponline thats definitely a good investigation point.
I see though from the investigation above that a-lot of the libraries are either essential to the project and/or sub-dependancies of other libraries. Especially since the google.commons is so large.
Therefore i investigated how we made the shadow jar.
There is a simple fix that can be applied for the gradle script for the shadow jar process:
https://imperceptiblethoughts.com/shadow/configuration/minimizing/
There is also a good reason to look into graalvm. i assume for graal we would be using the community edition (free).
There is also the possibility to apply the d8 optimisation tool that is well used within android (to create apks and lib files).
Lets create some sub-tasks and investigate each one independently.

  1. GraalVM
  2. D8
  3. ShadowJar minimisation

@bootstraponline
Copy link
Contributor Author

I think this ticket "Understand Flank jar size" is done. We have an understanding now of why the Flank jar is large. The additional tasks will handle the actual reduction of the jar size.

@Sloox
Copy link
Contributor

Sloox commented Sep 7, 2020

@bootstraponline Sure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants