Skip to content

Reduce jar size by using abstract classes #4751

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

joroKr21
Copy link
Member

@joroKr21 joroKr21 commented May 30, 2025

Traits generate bridge methods in every subclass

See #4750

main, 2.12
- JVM:     6.1MB jar, 23.6MB uncompressed, 28.8MB on disk
- JS:     10.9MB jar, 38.1MB uncompressed, 49.4MB on disk
- Native: 12.4MB jar, 39.7MB uncompressed, 58.2MB on disk

main, 2.13
- JVM:     6.4MB jar, 24.3MB uncompressed, 29.6MB on disk
- JS:     11.3MB jar, 39.2MB uncompressed, 50.7MB on disk
- Native: 12.8MB jar, 40.9MB uncompressed, 59.7MB on disk

main, 3.3
- JVM:     7.1MB jar, 23.8MB uncompressed, 31.6MB on disk
- JS:     11.8MB jar, 37.5MB uncompressed, 51.5MB on disk
- Native: 13.4MB jar, 39.9MB uncompressed, 61.4MB on disk

abstract-classes, 2.12
- JVM:     5.1MB jar, 15.3MB uncompressed, 20.6MB on disk
- JS:      8.9MB jar, 24.8MB uncompressed, 36.2MB on disk
- Native: 10.5MB jar, 26.3MB uncompressed, 44.8MB on disk

abstract-classes, 2.13
- JVM:     5.3MB jar, 15.8MB uncompressed, 21.0MB on disk
- JS:      9.1MB jar, 25.4MB uncompressed, 36.9MB on disk
- Native: 10.8MB jar, 26.9MB uncompressed, 45.8MB on disk

abstract-classes, 3.3
- JVM:     6.2MB jar, 16.2MB uncompressed, 23.9MB on disk
- JS:      9.9MB jar, 25.0MB uncompressed, 39.0MB on disk
- Native: 11.6MB jar, 26.9MB uncompressed, 48.3MB on disk

@johnynek
Copy link
Contributor

Can you add to the PR how the uncompressed jar size changes after this please?

Thanks for doing this.

Traits generate bridge methods in every subclass
@joroKr21 joroKr21 force-pushed the abstract-classes branch from 400ccdd to 3d4ac2e Compare May 31, 2025 08:01
@joroKr21
Copy link
Member Author

I updated the description with sizes

@joroKr21
Copy link
Member Author

Biggest offenders remaining (can't fix because they are static methods and binary compatibility):

457K Jan  1  2010 implicits.class
371K Jan  1  2010 SemigroupalArityFunctions.class
158K Jan  1  2010 Semigroupal$.class
153K Jan  1  2010 ApplyArityFunctions.class
150K Jan  1  2010 InvariantSemigroupal$.class
150K Jan  1  2010 ContravariantSemigroupal$.class
150K Jan  1  2010 ContravariantMonoidal$.class
125K Jan  1  2010 ParallelArityFunctions.class
123K Jan  1  2010 implicits$.class
121K Jan  1  2010 Semigroupal.class
117K Jan  1  2010 ContravariantMonoidal.class
116K Jan  1  2010 ContravariantSemigroupal.class
116K Jan  1  2010 InvariantSemigroupal.class
100K Jan  1  2010 ParallelArityFunctions2.class
103K Jan  1  2010 AllSyntaxBinCompat.class
475K Jan  1  2010 AbstractTupleInstances.class

@satorg
Copy link
Contributor

satorg commented Jun 1, 2025

@joroKr21 ,

Biggest offenders remaining

Yet a substantial decrease in sizes is achieved, thank you!

May I suggest the below representation of the size comparisons for nicer visualisation?

main
(jar)
abstract classes
(jar)
main
(uncompressed)
abstract classes
(uncompressed)
main
(disc)
abstract classes
(disc)
JVM 2.12 6.1MB 5.1MB 23.6MB 15.3MB 28.8MB 20.6MB
JVM 2.13 6.4MB 5.3MB 24.3MB 15.8MB 29.6MB 21.0MB
JVM 3.3 7.1MB 6.2MB 23.8MB 16.2MB 31.6MB 23.9MB
JS 2.12 10.9MB 8.9MB 38.1MB 24.8MB 49.4MB 36.2MB
JS 2.13 11.3MB 9.1MB 39.2MB 25.4MB 50.7MB 36.9MB
JS 3.3 11.8MB 9.9MB 37.5MB 25.0MB 51.5MB 39.0MB
Native 2.12 12.4MB 10.5MB 39.7MB 26.3MB 58.2MB 44.8MB
Native 2.13 12.8MB 10.8MB 40.9MB 26.9MB 59.7MB 45.8MB
Native 3.3 13.4MB 11.6MB 39.9MB 26.9MB 61.4MB 48.3MB

(generated from your data with help of Github Copilot)

@joroKr21 joroKr21 marked this pull request as ready for review June 2, 2025 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants