groovy
  1. groovy
  2. GROOVY-4157

groovyall.jar is too heavy, can we reduce it?

    Details

    • Type: Wish Wish
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      1

      Description

      I like groovy but the groovy-all*.jar is too big. sth should do now.
      there are so many source code is for java1.4, we can rewrite them in java 1.5 to make groovy slim.
      for example:
      src/main/org/codehaus/groovy/runtime/ArrayUtil.java (ArrayUtil.class 1,093,546B)
      src/main/org/codehaus/groovy/reflection/MethodHandle.java
      src/main/org/codehaus/groovy/runtime/callsite/AbstractCallSite.java
      we can reduce ArrayUtil.class to 909B!!! if we rewrite like this:

      public class ArrayUtil {
          private static final Object[] EMPTY = new Object[0];
      
          public static Object[] createArray() {
              return EMPTY;
          }
      
          public static Object[] createArray(Object... args) {
              return args;
          }
      }
      

      1,759 KB groovy-all-1.0-JSR-06.jar
      2,238 KB groovy-all-1.0.jar
      2,762 KB groovy-all-1.5.4.jar
      2,775 KB groovy-all-1.5.5.jar
      2,784 KB groovy-all-1.5.6.jar
      4,536 KB groovy-all-1.6.3.jar
      4,399 KB groovy-all-1.6.4.jar
      4,448 KB groovy-all-1.6.7.jar
      4,054 KB groovy-all-1.6.jar
      4,922 KB groovy-all-1.7-beta-2.jar
      5,119 KB groovy-all-1.7.1.jar
      5,165 KB groovy-all-1.7.2.jar

        Issue Links

          Activity

          Hide
          Guillaume Laforge added a comment -

          This ArrayUtil class was generated in that way for some performance reasons. Sometimes there are tradeoffs.

          Anyway, we're planning to change our build and make Groovy more modular, so that users can pickup just what they need.

          We could also use Pack200 for better packing the JAR(s), to diminish its(/their) overal size(s).

          JAR size is less of a concern nowadays, with our huge hard drives, unless perhaps you're on some mobile device, in applets/web start apps, or in embedded systems with strong space/memory constraints?

          Show
          Guillaume Laforge added a comment - This ArrayUtil class was generated in that way for some performance reasons. Sometimes there are tradeoffs. Anyway, we're planning to change our build and make Groovy more modular, so that users can pickup just what they need. We could also use Pack200 for better packing the JAR(s), to diminish its(/their) overal size(s). JAR size is less of a concern nowadays, with our huge hard drives, unless perhaps you're on some mobile device, in applets/web start apps, or in embedded systems with strong space/memory constraints?
          Hide
          lwh added a comment -

          I made a test, use "ArrayUtil.createArray" and "Variable Arguments" to process 5 int , 5 string , 17string for 100,000,000 times。It shows when argument count little ArrayUtil is faster than "Variable Arguments"(but only very little). when count becomes big, VA is more faster.
          Here is result( ArrayUtil2 Use VA):
          5 int ArrayUtil use 2984
          5 int ArrayUtil2 use 3016
          5 string ArrayUtil use 2453
          5 string ArrayUtil2 use 2703
          17 string ArrayUtil use 8000
          17 string ArrayUtil2 use 6875

          Show
          lwh added a comment - I made a test, use "ArrayUtil.createArray" and "Variable Arguments" to process 5 int , 5 string , 17string for 100,000,000 times。It shows when argument count little ArrayUtil is faster than "Variable Arguments"(but only very little). when count becomes big, VA is more faster. Here is result( ArrayUtil2 Use VA): 5 int ArrayUtil use 2984 5 int ArrayUtil2 use 3016 5 string ArrayUtil use 2453 5 string ArrayUtil2 use 2703 17 string ArrayUtil use 8000 17 string ArrayUtil2 use 6875
          Hide
          lwh added a comment -

          test for ArrayUtil and VA(ArrayUtil.java not in it) compile them and run "java -cp . ArrayTest"

          Show
          lwh added a comment - test for ArrayUtil and VA(ArrayUtil.java not in it) compile them and run "java -cp . ArrayTest"
          Hide
          blackdrag blackdrag added a comment -

          we decided to keep the class till Groovy 3. The purpose is actually only partially the maybe higher speed you can directly see in a microbenchmark. It is to reduce the bytecode size, since you save using all the index entries to create the array. Anyway... Groovy 3 will go a different way here and won't need this class anymore. Se also GROOVY-5483

          Show
          blackdrag blackdrag added a comment - we decided to keep the class till Groovy 3. The purpose is actually only partially the maybe higher speed you can directly see in a microbenchmark. It is to reduce the bytecode size, since you save using all the index entries to create the array. Anyway... Groovy 3 will go a different way here and won't need this class anymore. Se also GROOVY-5483
          Hide
          blackdrag blackdrag added a comment -

          one more word on the size. Yes, it is a big class, but it is well compressed and thus makes only a minimal difference for the size of the jar

          Show
          blackdrag blackdrag added a comment - one more word on the size. Yes, it is a big class, but it is well compressed and thus makes only a minimal difference for the size of the jar

            People

            • Assignee:
              blackdrag blackdrag
              Reporter:
              lwh
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: