Index Previous Next

Results

I don't yet have enough optimisations to make much of an impact on real applications. The typical reduction in the size of an application is of the order of 0.1% (excluding the change in size due to the stripping of line number information, which is over 10%.) Any change in performance is likewise tiny.

One experiment I've performed is to optimise Swing 1.0.2. The script I used to do this, swingopt, is available for you to try. Just edit the script to point at your copy of swingall.jar and run the script in an empty directory. The optimised swingall.jar is placed in swingall.new.

When I ran swingopt on my 133 MHz Pentium under Linux 2.0.33 it took about 25 minutes. The original jar file was 2,001,666 bytes long; the new one was 1,671,815 bytes. This doesn't mean much, though, as the jar file is compressed and the main reason for the size reduction is the removal of the line number and local variable information from the class files. The total number of bytes in the uncompressed class files is:

     Original                     3,709,377
     Unoptimised/no debug data    2,682,741
     Optimised/no debug data      2,680,866

The SwingSet demo works just as well after optimisation as it did before. (Though it is important to apply the fix to D-Java.)

The star performer of the optimisation is the class style32 in the package com.sun.java.swing.text.html. The optimiser manages to squeeze 175 bytes out of this file. style32.java was generated by the JavaCC compiler compiler. The optimisations are all in static initialisations of this form:

       static boolean[] jj_mask_0 = new boolean[122];
       static {
           jj_mask_0[SA_NAME] = true;
       }

The value stored in jj_mask_0 is immediately reused in the following statement and the fetch can be replaced by a duplication of the value.

The total number of bytes saved by the optimiser is 1875. There are 1268 class files in swingall.jar. Of these 873 weren't optimised at all; 138 saved just one byte; 213 saved between 2 and 10 bytes; 29 saved between 11 and 20 bytes; and the remaining 15 saved more than 20 bytes. Apart from style32.class mentioned above the next best saving was 41 bytes in JSlider.class.


Index Previous Next