Repository navigation
perf(build): smaller jars, with R8's marker stripped, a short package and fewer keep rules - #169
Merged
Merged
Conversation
zacharyk812
force-pushed
the
perf/jar-size
branch
from
November 25, 2026 03:25
e480b15 to
2c33875
Compare
… and fewer keep rules Every shrunk jar loses a fifth: R8's per-class marker string is emptied, renamed classes go to a package named for the plugin (xsample, not co.xenastudios.xsample.r8), the relocated core's api packages are kept only as far as the plugin's own API exposes them, the enum keep rule and the compile-time annotations go, and the jar is written at deflate's strongest level without data descriptors. xSample's Bukkit jar 521 -> 418 KiB, xTwin's 401 -> 311 KiB, the Fabric jars 23-25% smaller, xUtilities 3.0 574 -> 477 KiB. Budgets lowered to the new sizes plus about 10%. The budget check counts a plugin's R8 package as its own. Part of #123.
zacharyk812
force-pushed
the
perf/jar-size
branch
from
November 25, 2026 03:35
2c33875 to
b4b7cc6
Compare
zacharyk812
marked this pull request as ready for review
November 25, 2026 03:35
8 of 11 tasks
9 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #123. Based on main now that #166 (startup) has merged.
Every shrunk jar loses a fifth, through build-logic, so every plugin gets it. DECISIONS.md: "Smaller jars".
What changed
R8Shrink.withoutMarker): R8 writes a 186-byte~~R8{...}string as constant Dependency Dashboard #1 of every class, which nothing reads at runtime. The string is emptied in place, so no index changes. This was 11% of xUtilities' jar.xsample,xutilities), notco.xenastudios.<id>.r8. Every class name and descriptor carries that package, so this saves 6.5%. The name is still unique per server. The default comes from the project path's first name; on Fabric it's the mod id.analyze.pynow counts a plugin's R8 package as its own in samples and heap.apipackages outsidecore).shrinkJargenerates keep rules for exactly the core types that API names, followed transitively (for xUtilities:PlayerRef,Location,WorldRef, the event types)..kotlin_modulefiles are dropped.Sizes (KiB, shrunk jar; Fabric before Loom's remap)
Per step, measured on xUtilities' Bukkit jar (KB, deflate 9):
xutilitiesxUtilities is still about three times its 2.x jar (163 KiB). What's left is the core's own code, reachable through what the plugin uses.
Tried, not taken
-assumenosideeffectson Kotlin'sIntrinsicsnull checks: under 0.3%, and the checks are useful.-allowaccessmodification: R8 is already in full mode, so no change.Table,ColumnTypeandSqlValuethat remain describe the family player cache's file, which xUtilities uses.Checked
./gradlew build: ABI, jar budgets, the newR8ShrinkTest, andJarBootTeston both jars../gradlew -p core/platform-fabric build collect.scripts/budgets/check.sh: xSample startup is unchanged on the same machine (Paper 26.3: 41.0 ms vs 40.7 ms on the old jar; 1.21.11: 71.1 vs 71.0 ms). The startup list still maps 594 of 595 classes; R8 now merges one away. xTwin's startup is over 100 ms both before and after (136.5 / 123.5 ms). That isn't new, and CI budgets xSample only.Not checked: Fabric 1.20.1 and 1.21.11 boots (both built and within budget), Folia, and real boots of xUtilities. #167 needs a follow-up: its
packageName = "co.xenastudios.xutilities.r8"lines should go, so the default applies, and its jar-budget lines should drop to about 525 / 480–500 KiB.The jar rule
After these cuts xUtilities 3.0 is still about 477 KiB against 2.x's 163 KiB. The owner set the rule to 500 KiB per jar on every platform; ROADMAP.md and a DECISIONS.md bullet say so, and each jar's line in
gradle/jar-budgets.txtstill sits about 10% over its size.