What the bridge costs a player who doesn't use it: startup and frame time with --benchmark standard
(release builds, docs/benchmark.md), three ways: upstream's main; this branch built without the
java-mods feature; this branch built with it as the release builds it
(HORIZON_BRIDGE_PLATFORM=source), the switch off (no --java-mods) and a jar in mods-java/.
tools/java_bridge/perf_off.sh 5 # builds the three, runs each 5 times alternating, prints the table
SKIP_BUILD=1 tools/java_bridge/perf_off.sh 5 # again, same binariesWhat runs with the switch off, by reading the code: opted_in() once (arguments and two variables),
one mods-java/ listing for the log line, nothing else: no JVM, no thread, no library loaded, no
file of the bridge written. The build adds the bridge's code and its carried sources to the binary.
Machine: AMD Ryzen 5 9600X, AMD Radeon RX 9070 XT (RADV, Vulkan), Fedora 43 (kernel 6.19.12). Upstream
a27b7f20f, fork 8cff8dbc4. --benchmark standard, mean ± stdev over 5 runs each (frames: over every scene's
flight). Measured 2026-11-05 with tools/java_bridge/perf_off.sh 5.
| Upstream main | java-bridge, no feature | java-mods build, switch off | |
|---|---|---|---|
| Runs | 5 | 5 | 5 |
| Start to title (ms) | 772 ± 259 | 687 ± 8 | 676 ± 22 |
| Start to in-world (ms) | 2678 ± 300 | 2492 ± 68 | 2462 ± 110 |
| Average FPS | 3699 ± 338 | 3707 ± 383 | 3597 ± 379 |
| Frame p50 (ms) | 0.25 ± 0.02 | 0.25 ± 0.02 | 0.25 ± 0.02 |
| Frame p99 (ms) | 0.74 ± 0.13 | 0.74 ± 0.16 | 0.77 ± 0.16 |
| 1% low FPS | 856 ± 161 | 847 ± 161 | 827 ± 169 |
| Peak RSS (MB) | 1119 ± 11 | 1116 ± 15 | 1114 ± 12 |
| Binary (MB) | 89.9 | 87.9 | 93.4 |
Reading it: every difference is inside one standard deviation, so with the switch off the bridge costs
nothing measurable in start time, frame time or memory. The only real cost is the binary: +3.5 MB for the
java-mods build (the bridge's code and its Java sources). The plain build (no feature), which is what upstream
releases ship, is the same as main.
What a big Fabric pack costs Horizon: start time, memory, server tick time, and where they go.
Measured headless with tools/java_bridge/perf_measure.sh. Start with this page before tuning.
Machine: cloud container, 2 shared cores, 7.6 GB RAM, no GPU: Horizon's renderer and the mods' GPU device (the headless client's) both run on llvmpipe, on the same 2 cores. A desktop is faster everywhere, and much faster for the mods' GPU work (see "HUD" below). Compare runs on one machine, not across machines.
Pack: tools/java_bridge/get_test_pack.py → 81 jars (72 run, 166 mods with nested jars).
Seed 1234, creative. Each run: join, stand 60 s, sprint forward 30 s, stand 20 s.
MODS=~/hz-test/mods-java CACHE=/tmp/pack-cache tools/java_bridge/perf_measure.sh pack # the pack
MODS=~/hz-test/fapi tools/java_bridge/perf_measure.sh fapi # Fabric API alone
tools/java_bridge/perf_measure.sh vanilla # no Java (JAVA_MODS=0)It writes /tmp/hz-perf/<name>/: /tick query at each phase (*.tick), RSS (*.status), the
JVM's heap (*.heap) and native memory by area (*.nmt, -XX:NativeMemoryTracking=summary),
the live heap's classes after a full GC (histo.txt), the GC log, a JFR recording (perf.jfr:
CPU and native samples, allocations), the game's log with HORIZON_JAVA_PROFILE=1, screenshots.
jcmd attaches through -XX:+StartAttachListener (the bridge's JVM runs with -Xrs, so SIGQUIT,
which attach uses otherwise, is ignored). launch.sh now takes JAVA_MODS=0 (the Java side off).
| Vanilla Horizon | Fabric API alone | Pack, before | Pack, with the tap fix | Pack, fix + -Xmx3g |
|
|---|---|---|---|---|---|
| Start to joined | 10 s | 43–47 s | 182 s cold (content made: 52 s), 196 s warm | 209 s | 199 s |
| RSS standing / after walking | 1.49 / 1.63 GB | 2.26 / 2.45 GB | 4.42 / 4.24 GB | 4.06 / 4.18 GB | 3.93 / 4.95 GB |
| JVM committed (NMT) | — | 0.71 GB | 2.34–2.57 GB | 2.11–2.42 GB | — |
| Java heap: max / live after full GC | — | 1.5 GB / ~0.28 GB | 1.5 GB / 0.64–0.67 GB | 1.5 GB / 0.72–0.91 GB | 3 GB / 0.91–0.96 GB |
| Native "Other" (direct buffers) | — | ~0 | 250 → 795 MB | 5 MB | 5 MB |
| Tick avg / P95 / P99, standing (60 s) | 11.5 / 18 / 29 ms | 16.6 / 29 / 86 ms | 169 / 499 / 701 ms | 129 / 249 / 354 ms | 114 / 222 / 363 ms |
| Tick avg / P95 / P99, sprinting (30 s) | 12.4 / 22 / 25 ms | 19.5 / 33 / 49 ms | 243 / 654 / 3060 ms | 155 / 293 / 2080 ms | 114 / 212 / 288 ms |
| Tick avg / P95 / P99, standing after | 12.9 / 20 / 24 ms | 16.8 / 26 / 34 ms | 192 / 554 / 1019 ms | 108 / 211 / 293 ms | 100 / 215 / 237 ms |
| GC pauses (JFR window, ~2.5 min) | — | — | 158, 9.2 s, max 1.98 s | 198, 11.0 s, max 1.85 s | 108, 6.7 s, max 0.23 s |
/tick query covers the last 100 ticks of each phase. On 2 cores everything competes: the noise between two runs of the same jars is ±15% on tick
averages. RSS minus the JVM's committed memory is Horizon's own side (Rust, llvmpipe, the mods'
content, LWJGL's untracked mallocs): ~1.5 GB vanilla, ~1.7–1.8 GB with the pack.
HORIZON_JAVA_PROFILE=1, per server tick (Java profile (mirror tick)):
- The headless client: 110–115 ms. Its HUD (
client: HUD) 50–78 ms, its tick (client: tick, the mods' client ticks) 19–26 ms, frame end ~6 ms. - Mod entities 7.5 ms, their snapshot 4.3 ms, spawner 1.8 ms, the rest <1 ms each.
- Walking adds the mods' worldgen, called on the server thread: TERRAIN 75–118 ms a tick (145–675 ms a chunk), structure starts and references 34–100 ms, features 9–42 ms.
JFR on the server thread (Java and native samples):
- HUD: Java side ~40% of the client's samples.
HorizonGraphics.shrink(downsizing a window-sized GPU target before sending it) is the biggest leaf. Then gson writing the frame, Base64 of image pixels, Xaero's minimap, JourneyMap, MiniHUD and Jade. Native side: the mods' GPU passes (Gpu.endPass,clear) and readbacks (Gpu.readTexture), here on llvmpipe, i.e. CPU. This needs measuring on a real GPU before anyone optimises it. - VoxelMap: ~16% of the server thread's Java time. Its
MapChunk.isSurroundedByLoadedasks for client chunks. Each answer is aHorizonChunkscopy filled whole (98k blocks, lithium's state tracking on each set), refilled every time Horizon's chunk revision changes (any block set: random ticks, grass). - Allocation: 37% of the pack's allocation pressure is vanilla's own
WorldGenRegionconstructor (EnvironmentAttributeSystembaked per step, all biomes' layers). Vanilla does the same per step. Its biome layer holds the region'sBiomeManager, so it can't be shared per level.
- The JVM: 2.1–2.6 GB committed. Java heap 1.2–1.5 GB committed (the cap is 25% of RAM: 1.5 GB here), metaspace 212 MB, the CDS archive 228 MB (mapped from its file), code 86 MB, GC structures 66 MB, symbols 44 MB, class space 51 MB. JFR's own buffers (53 MB) are measurement overhead.
- Live heap: 0.64–0.96 GB. By package, shallow sizes after a full GC (the arrays belong to
all of these):
- The data fixer: 36–220 MB, the biggest swing. Up to 6 rule chains for mods' old
structure files are kept (
HorizonDataFixer.MAX_RULES), ~35 MB each. - Client models: ~37 MB (BakedQuads ~26 MB: 357k quads, ModelPart vertices). The model bake keeps them for the mods' renderers and item models.
- Structure templates: ~42 MB (StructureBlockInfo 20 MB + their BlockPos). The template manager's cache of every template loaded.
- Mixin's class nodes: ASM 28 MB + Mixin 8 MB. Mixin keeps them, as in any Fabric game.
- Block states and shapes: ~36 MB. Strings: ~25 MB (deduplicated).
- Fabric API alone: ~0.28 GB live, of which client models 19 MB.
- The data fixer: 36–220 MB, the biggest swing. Up to 6 rule chains for mods' old
structure files are kept (
- The mirror's chunks: small when idle (PalettedContainers ~10 MB live). They churn: chunk copies are refilled whole on every revision.
- The JVM's heap uses a ceiling, not a target. Churn (worldgen regions, chunk copies, HUD frames as JSON strings) fills the 1.5 GB cap within minutes, and G1 then runs a full compaction: 1.85–1.98 s, in every run of the pack. That is the P99 above.
| Phase | Time |
|---|---|
| Horizon's content and first frame (mods' content from the cache) | 19 s |
JVM + Knot + mixins (Minecraft bootstrap done in 19.7 s) |
~28 s |
| Mods' entrypoints (Fabric loader started: 166 mods) | ~26 s |
| Server data (5346 recipes, 4738 advancements) | 10 s |
| Spawn area generated through Java (TerraBlender, BOP: the overworld is Java's) | ~85 s |
| Headless client: atlases and model bake before the join | ~22 s |
Cold adds the content conversion (52 s), but here it overlapped. Cold and warm joined within the noise (182 vs 196 s). The CDS archive is written at the first run's end and used after.
- The packet tap kept a broken packet's bytes for good (
HorizonPacketTap.dropLeftover). The tap runs when a mod mixes intoConnection. In this pack that is FrozenLib's QSLConnectionMixin, a registry-sync patch, not a recorder. A packet the decoder couldn't read whole (here a >1 MiB payload: "Payload may not be larger than 1048576 bytes") left its 2.3 MB rest in theByteToMessageDecoder. Every later packet was appended to it: a new zeroed direct buffer of megabytes per packet. That was 31% of the server thread's Java time (SegmentFactories.initNativeMemory), up to 795 MB of native memory, and every later packet misread for the mods ("found 2325608 bytes extra", identifiers made of pixel data). Now each body's leftover is skipped (each body is one whole packet). Native "Other" 795 → 5 MB, average ticks 169/243/192 → 129/155/108 ms (standing, sprinting, after). ReplayMod's recording still passes (regress.py replaymod). - HUD sprite lookups searched every jar each frame (
HorizonSprites.texture). A "directory" atlas source asks the class loader, which walks all 81 jars' zip indexes. This ran per sprite per frame: ~5% of the HUD's Java time. Now each sprite's answer is kept (the jars don't change while the game runs). HORIZON_JAVA_TAP=0turns the tap off, for a pack whose connection mixins aren't recorders. The tap stays on by default (no change). After fix 1 the tap itself costs little here (tap off: 145/143/117 ms against 129/155/108, within the noise).
- Raise the JVM's heap ceiling for big packs (not done: it trades memory). With
-Xmx3gthe 1.9 s full compaction never happened: sprinting P99 2080 → 288 ms, GC pauses 11.0 → 6.7 s, max 1.85 s → 0.23 s. The cost is +0.5–0.8 GB RSS at peak, given back as the heap shrinks (MaxHeapFreeRatio=30). A floor of 3 GB (or-XX:MaxRAMPercentage=40) when RAM ≥ 8 GB would do it. A player can setHORIZON_JVM_OPTIONS=-Xmx3gtoday. Pair it with win 2, so the extra room goes to churn, not caches. - Keep fewer data-fixer chains (
HorizonDataFixer.MAX_RULES6 → 1 or 2). Its own comment says a chain is rarely used twice. The live heap swung 36 → 220 MB from this alone. One constant. Check first how long rebuilding a chain takes during worldgen (the spawn area's 85 s). - Refill VoxelMap-style client chunk copies less.
HorizonChunks.heldrefills a whole copy (98k blocks) on any revision change. Following the change (askeptdoes withwritten), or keying revisions per section, would cut most of the 16%. Also cheap: answer a chunk's loaded-ness with no copy where a mod only asks that (hasexists; VoxelMap'sisSurroundedByLoadedgoes throughgetChunk).
Worth a look after those, not cheap: the HUD on a real GPU first. If it's still big, draw the
HUD's GPU images at 10 Hz like big targets (PIP_INTERVAL), send image pixels as binary, not
Base64 in JSON, and downsize in Rust's readback. Also: generate the spawn area while the client
bakes its models (85 + 22 s, one after the other now), and drop the template manager's cache
once mods' templates are exported.
- jcmd can't attach to the bridge's JVM without
-XX:+StartAttachListener(-Xrs). GC.class_histogram -allcounts dead objects too (it skips the full GC): use it without-all.- The heap's
usedright after a run is mostly garbage: read the live set from the GC log'sPause Full (Heap Inspection Initiated GC) A->B, B. jfr print --jsonof a few minutes is ~700 MB; parse the text form (jfr print --events …).- JFR's Java samples miss the mods' GPU work: read
jdk.NativeMethodSampletoo (Gpu.*). lab.py decompilewas OOM-killed on 7.6 GB;javap -con.local/minecraft/26.3/jars/*.jaranswers single questions.