Skip to content

perf(core): startup under budget: Paper's loader for the libraries, startup classes loaded ahead - #166

Merged
zacharyk812 merged 1 commit into
mainfrom
perf/startup-budget
Nov 25, 2026
Merged

zacharyk812 merged 1 commit into
mainfrom
perf/startup-budget

Conversation

@zacharyk812

Copy link
Copy Markdown
Contributor

Brings the first plugin's startup under its 150 ms budget, with both options from the perf-budgets entry, and makes startup a failing budget again in the Boot workflow (#162).

xSample, scripts/budgets/check.sh, M1 Pro, median of 3 boots Server's part onLoad onEnable Total
Paper 1.21.11 (Java 21), before 96 20.1 138.3 252.6 ms
Paper 1.21.11, paper-plugin.yml loader only 10 15.3 112.5 137.4 ms
Paper 1.21.11, + startup classes loaded ahead 10 15.3 34.5 59.5 ms
Paper 26.3 (Java 25), before 78 17.7 97.5 193.9 ms
Paper 26.3, after 4 4.3 30.2 39.0 ms
  • On Paper 1.19.3+ the jar is also a Paper plugin. Its paper-plugin.yml names the core's PaperLibraryLoader (core-loader's new paper source set, Java 17 class files). The loader takes the libraries from the family's pinned cache in plugins/Xena/libraries/ and hands them to Paper as JarLibrarys. Paper then skips Maven's resolver and its legacy class rewriting (Commodore) at every boot. Spigot and older Paper ignore the file and keep using plugin.yml's libraries: or the shim. This was already the model for today's plugins, and other plugins can still reach a Paper plugin's API (checked in M1).
  • A build-time list of startup classes, loaded ahead. check.sh --record-startup records a real boot's class loading and writes the list (startup_classes.py), with the jar's own classes under their pre-R8 names. The project keeps it as startup-classes.txt. R8Shrink maps it to R8's names and writes it into the jar as META-INF/xena/startup-classes.txt, and the shim's preload thread loads those classes (without initializing them) between onLoad and onEnable. A stale list only costs speed.
  • Measuring: with no libraries: line to time, the loader reports its own time through the shim's Startup times line, and analyze.py reads it. Paper building the class loader and the main class is about 8 ms of CPU that no log line bounds; that is written down in DECISIONS.md.
  • boot.yml: --report-only is dropped from the budgets job, so being over on startup fails it again.

Verified

  • ./gradlew build passes.
  • Budget checks on Paper 1.21.11 and 26.3: the numbers above.
  • Boots: Paper 26.3 with the family test (xSample as a Paper plugin, xTwin with plugin.yml), Folia 26.3, and Spigot 1.8.8 (Java 8) with the family test.
  • actionlint: clean apart from the existing ubuntu-26.04 runner-label notice.

Not verified here: Paper 1.19.3–1.20.4 on Java 17 (the oldest servers that read paper-plugin.yml), and Paper 1.16.5. The nightly matrix covers 1.16.5.

For each real plugin, its Bukkit module needs:

  • a paper-plugin.yml with loader: co.xenastudios.<plugin>.core.loader.paper.PaperLibraryLoader
  • a recorded startup-classes.txt

DECISIONS.md: "Startup under budget".

Part of #123. Part of #162.

… classes loaded ahead

On Paper and Folia from 1.19.3 the jar is also a Paper plugin whose loader
(core-loader's PaperLibraryLoader) hands Paper the libraries from the
family's cache, skipping Maven's resolver and the legacy class rewriting at
every boot. The classes a plugin loads as it starts are recorded on a real
server (check.sh --record-startup), mapped to R8's names at build time and
loaded by the shim's preload thread before onEnable. xSample on Paper
1.21.11: 252.6 ms to 59.5 ms; on 26.3: 193.9 ms to 39.0 ms. The budgets job
fails on startup again.
@zacharyk812
zacharyk812 merged commit c9c8ec3 into main Nov 25, 2026
31 checks passed
@zacharyk812
zacharyk812 deleted the perf/startup-budget branch November 25, 2026 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core The shared core and build documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant