Bug - Fixed r20911 causes jar size regression

fewyn

Administrator
Staff member
Code:
jar:
      [jar] Building jar: /var/lib/jenkins/workspace/Kolmafia Pipeline/build/bundled-libs.jar
      [jar] Building jar: /var/lib/jenkins/workspace/Kolmafia Pipeline/dist/KoLmafia-20914.jar
      [jar] Warning: selected jar files include a META-INF/INDEX.LIST which will be replaced by a newly generated one.
   [delete] Deleting: /var/lib/jenkins/workspace/Kolmafia Pipeline/build/bundled-libs.jar

Maybe?
 

fronobulax

Developer
Staff member
I poked around.

The KoLmafia jar file contains bundled-libs.jar. There is a lot of duplication between bundled-libs and KoLmafia. I didn't check to see how close they were to identical.

Not that it matters but there is an empty clover subdirectory but several Clover generated html files are bundled in the jar. I'm not sure that is necessary.
 

fredg1

Member
source:
XML:
    <target name="jar" depends="compile">
      <jar destfile="${build}/bundled-libs.jar"
           basedir="${build}"
           update="true"
           index="true"
           compress="true">
        <zipgroupfileset dir="${lib}/jar">
          <include name="*.jar"/>
        </zipgroupfileset>
        <zipgroupfileset dir="${src}/jar">
          <include name="*.jar"/>
        </zipgroupfileset>
      </jar>

      <jar
          destfile="${jarfile}"
          basedir="${build}"
          update="true"
          index="true"
          compress="true">

        <manifest>
          <attribute name="Main-Class" value="${main}" />
        </manifest>
        <zipfileset src="${build}/bundled-libs.jar">
          <exclude name="META-INF/*.RSA"/>
          <exclude name="META-INF/*.DSA"/>
          <exclude name="META-INF/*.SF"/>
        </zipfileset>
      </jar>

      <delete file="${build}/bundled-libs.jar" />
    </target>


Separation:
1-
XML:
      <jar destfile="${build}/bundled-libs.jar"
           basedir="${build}"
           update="true"
           index="true"
           compress="true">
        <zipgroupfileset dir="${lib}/jar">
          <include name="*.jar"/>
        </zipgroupfileset>
        <zipgroupfileset dir="${src}/jar">
          <include name="*.jar"/>
        </zipgroupfileset>
      </jar>
2-
XML:
      <jar
          destfile="${jarfile}"
          basedir="${build}"
          update="true"
          index="true"
          compress="true">

        <manifest>
          <attribute name="Main-Class" value="${main}" />
        </manifest>
        <zipfileset src="${build}/bundled-libs.jar">
          <exclude name="META-INF/*.RSA"/>
          <exclude name="META-INF/*.DSA"/>
          <exclude name="META-INF/*.SF"/>
        </zipfileset>
      </jar>
3-
XML:
      <delete file="${build}/bundled-libs.jar" />

"1" creates "our jar". It has everything, including unwanted .RSA/.DSA/.SF.
"2" creates another jar, using "bundled-libs.jar" AND /build as source.
In short, "2" should only be transforming "bundled-libs.jar", rather than re-fetching the source. (at least as far as I know)
 

heeheehee

Developer
Staff member
So, the intent of bundled-libs was to just bundle all the other jars.

When I try removing basedir, that does nothing. On the other hand, I have had success adding excludes to the two jar commands. I'll commit that, since it brings the jar size back down to 20MB.
 

heeheehee

Developer
Staff member
Related: how much do we care about jar sizes?

Apparently the gradle-built jars are 30MB, although by using the shadow plugin with its minimize feature, that went down to 17MB.
 

fronobulax

Developer
Staff member
Related: how much do we care about jar sizes?

Apparently the gradle-built jars are 30MB, although by using the shadow plugin with its minimize feature, that went down to 17MB.

Ancient History tells of a time when a large portion of the user base was believed to have dial up connections and so the size of the jar file was a consideration. In 2021 I suspect it matters only if there are users with slow or unreliable connections. Like the refusal to update Java version I think the size is also a user community issue. How many people does it matter to and how many people do we alienate?
 

gausie

D̰͕̝͚̤̥̙̐̇̑͗̒e͍͔͎͈͔ͥ̉̔̅́̈l̠̪̜͓̲ͧ̍̈́͛v̻̾ͤe͗̃ͥ̐̊ͬp̔͒ͪ
Staff member
What would be the reason for not making it as small as possible? more efficient = more better, no?
Efficiency has nothing to do with bundle size necessarily. A bigger bundle might be because there's more efficient code and lots of it!
Related: how much do we care about jar sizes?
My personal take is that we care enough to check in on it but not so much that we'll let it stand in the way of a well considered 3rd party library (for example, though I can't think what else would contribute that significantly)
 

fronobulax

Developer
Staff member
Efficiency has nothing to do with bundle size necessarily.

Perhaps a different meaning of efficiency was being used? If you are looking at the efficiency of transmissions, smaller is better and more efficient. If you have ever had to live with dial up or support receivers with extremely low bandwidth then bundle size matters. When it takes 3 hours to download something, whether the result runs in 3 seconds or 30 seconds is much less a concern.

As alluded to above, if there are now KoL players and KoLmafia users that are constrained by bandwidth or storage then we don't seem to know about them. Until we find out otherwise, keeping bundle size small is more of a developer desire than anything an end user would know or care about.
 

heeheehee

Developer
Staff member
What would be the reason for not making it as small as possible? more efficient = more better, no?
Well, one argument (per a commit I added earlier today that added about 150KiB) is maintainability.

One way to minimize jars is to pull in the dependency sources (e.g. svnkit, or swingx), then prune them to the specific files we need. This takes a lot of effort, and if we patch these dependencies to work around issues, we should track those fixes (or risk losing them if we need to upgrade in the future). Usually it means we just don't upgrade our dependencies unless we need some critical feature we aren't willing to backport.

The simpler approach is to bundle the entire jar. Upgrading is trivial (download a new jar, delete the old one).
 
Top