Skip to content

Updated Upstream (BungeeCord), drop macOS natives, default native cipher off - #874

Merged
electronicboy merged 3 commits into
masterfrom
upstream/bungeecord
Sep 1, 2026
Merged

Updated Upstream (BungeeCord), drop macOS natives, default native cipher off#874
electronicboy merged 3 commits into
masterfrom
upstream/bungeecord

Conversation

@electronicboy

@electronicboy electronicboy commented Aug 31, 2026

Copy link
Copy Markdown
Member

Updates the BungeeCord submodule by 16 commits, and takes the opportunity to clean up
two things the update surfaced: the jline pin, and the native cipher.

Upstream changes

Mostly dependabot bumps, plus three substantive commits:

  • f56d37f4 Revert back to Cloudflare zlib not zlib_ng
  • dc538cb2 #3998: Use pending connection online mode state for login packet
  • 0b2812d2 Fix Minecraft 26.2 scoreboard team packet

Patches dropped

Two of our temporary patches are gone — upstream took both verbatim, with only our
explanatory comments differing:

  • Use proxy online mode state → upstream #3998
  • Temp fixup: 26.2 team packet → upstream 0b2812d2

macOS natives removed

OSX native zlib and crypto is dropped rather than updated.

Upstream's zlib-ng revert left the prebuilt osx-native-compress-arm.so we vendored
linked against an implementation upstream no longer uses. Rather than rebuild it, the
whole patch goes: isSupportedPlatformAndArch() returns to upstream's Linux-only check,
so macOS uses pure Java for both cipher and compression. That also removes ~98Ki of
vendored binaries and the macOS branches in compile-native-arm.sh.

For the cipher this costs nothing — see below, the native cipher was a pessimisation on
macOS by a factor of ~16. For compression, macOS loses a genuine 1.2–1.4x, which is the
actual trade being made here.

Native cipher now opt-in

The mbedtls native cipher is slower than the JDK's own implementation on every platform
and every supported JDK. Measured 2026-08-31, AES-128-CFB8, 16 MiB, median of 3, across
JDK 17/21/25:

Platform mbedtls native JDK JavaCipher native vs JDK
macOS arm64 4.2 MiB/s 69.5 0.06x
Linux aarch64 7.2 MiB/s ~63 0.11x
Linux x86_64 29.4 MiB/s ~41 0.71x

AESCE/AESNI are compiled in and dispatching; the cost is that mbedtls's CFB8 driver calls
mbedtls_aes_crypt_ecb once per byte. The native cipher dates to 2013 (BungeeCord
c70006a3) when it beat Java 7 — the JDK baseline moved on and the comparison was never
re-run.

Those figures are single-call throughput on a large buffer, so they say nothing on their
own about packet-sized work. Re-measured across realistic sizes on Linux x86_64 (JDK 21,
median of 5 after 3 warmup rounds, 128 MiB per round, direct pooled buffers as in the
real pipeline) the ratio is flat:

buffer mbedtls MiB/s JDK MiB/s native/JDK
256 B 31.3 40.8 0.77x
1 KiB 30.9 41.4 0.75x
16 KiB 30.9 41.8 0.74x
1 MiB 31.5 41.2 0.76x
16 MiB 31.4 41.4 0.76x

Per-call overhead never gets a look in: at ~31 MiB/s a 256-byte packet takes roughly 8 µs,
against a JNI transition of tens of nanoseconds. NativeCipher is zero-copy via
memoryAddress() and JavaCipher copies through heap arrays, and even so the difference
is under 1% of the work at the smallest realistic packet. The per-byte mbedtls_aes_crypt_ecb
call dominates at every size.

Only the default changes. -Dnet.md_5.bungee.jni.native-cipher.enable=true restores it.
NativeCode gains a defaultEnabled parameter used as the System.getProperty fallback;
its existing constructors still default to enabled, so EncryptionUtil is the only site
opting out.

Native compression is untouched and still enabled — it remains genuinely ahead of
java.util.zip.

jline 4.4.0

The Temp backbump jline to 4.0.9 patch existed because the FFM terminal provider crashes
on 4.1.x–4.3.1. 4.4.0 contains the fix, so the backbump is replaced by setting
jline-terminal-ffm / jline-terminal-jni to 4.4.0 where we introduce them, in the
TerminalConsoleAppender console patch.

Upstream's own org.jline:jline dep lives in the log module, which that same patch
comments out of the reactor — so it needs no patch at all, and we now carry no divergence
from upstream's jline version.

Testing

mvn clean package on JDK 21: BUILD SUCCESS, all tests pass, including NativeCipherTest
(which builds its own NativeCode and still sees the native cipher load, confirming the
default only moved at the EncryptionUtil call site) and the native zlib tests covering
upstream's zlib revert.

Cipher defaults verified against the built jar rather than just the unit tests:

property cipher impl compress impl
unset JavaCipher NativeZlib
native-cipher.enable=true NativeCipher NativeZlib
native-cipher.enable=false JavaCipher NativeZlib

Note that JDK 25 cannot build this — its javac rejects maven.compiler.release=17.

Upstream has released updates that appear to apply and compile correctly.

Two temporary patches were dropped as upstream has taken them verbatim:
"Use proxy online mode state" (upstream #3998) and "Temp fixup: 26.2 team packet".

This update has not been tested by PaperMC and as with ANY update, please do your own testing

BungeeCord Changes:
267f1ef2 #4015: Bump io.netty:netty-bom from 4.2.16.Final to 4.2.17.Final
76111147 #4014: Bump org.junit.jupiter:junit-jupiter from 6.1.2 to 6.1.3
b5ddebd5 #4010: Drop packets of different phases that are not transition acknowledgements
df0f3db3 #4012: Bump com.mysql:mysql-connector-j from 9.7.0 to 26.7.0
2e729325 #4008: Bump it.unimi.dsi:fastutil-core from 8.5.18 to 8.5.19
a65ee854 #4007: Bump org.apache.maven.plugins:maven-jar-plugin from 3.5.0 to 3.5.1
662925a1 #4006: Bump org.junit.jupiter:junit-jupiter from 6.1.1 to 6.1.2
793fbb9c #4004: Bump io.netty:netty-bom from 4.2.15.Final to 4.2.16.Final
edb28b4a #4003: Bump org.jline:jline from 4.2.1 to 4.3.1
87084ae7 #4002: Bump org.junit.jupiter:junit-jupiter from 6.1.0 to 6.1.1
01cec650 #4000: Bump actions/checkout from 6 to 7
0874f09f #3996: Bump org.sonatype.central:central-publishing-maven-plugin
04a99694 #3999: Bump org.jline:jline from 4.1.3 to 4.2.1
f56d37f4 Revert back to Cloudflare zlib not zlib_ng
dc538cb2 #3998: Use pending connection online mode state for login packet
0b2812d2 Fix Minecraft 26.2 scoreboard team packet
The FFM terminal provider in jline 4.3.1 and earlier has a bug that causes
crashes; 4.4.0 contains the fix, replacing the temporary backbump to 4.0.9.

jline-terminal-ffm/jni are deps we add ourselves, so the version is set where
they are introduced, in the TerminalConsoleAppender console patch. Upstream's
own jline dep lives in the log module, which that same patch comments out of
the reactor, so it needs no patch of its own.
Removes the "OSX native zlib and crypto" patch and replaces it with one that
makes the native cipher opt-in.

Dropping the macOS patch reverts isSupportedPlatformAndArch() to upstream's
Linux-only check, so macOS uses pure Java for both cipher and compression, and
removes the two vendored osx-*.so binaries (~98Ki) along with the macOS
branches in compile-native-arm.sh.

The native cipher is then defaulted off everywhere. The mbedtls implementation
is slower than the JDK's on every platform and every supported JDK -- measured
2026-08-31, AES-128-CFB8, 16 MiB, median of 3, across JDK 17/21/25:

  Platform        mbedtls native   JDK JavaCipher   native vs JDK
  macOS arm64        4.2 MiB/s         69.5            0.06x
  Linux aarch64      7.2 MiB/s         ~63             0.11x
  Linux x86_64      29.4 MiB/s         ~41             0.71x

AESCE/AESNI are compiled in and dispatching; the cost is that mbedtls's CFB8
driver calls mbedtls_aes_crypt_ecb once per byte. The native cipher dates to
2013 (BungeeCord c70006a) when it beat Java 7 -- the JDK baseline moved on and
the comparison was never re-run.

Native compression is untouched and still enabled: it remains genuinely ahead
of java.util.zip (1.2-1.4x).

The cipher default is still overridable with
-Dnet.md_5.bungee.jni.native-cipher.enable=true. NativeCode's existing
constructors continue to default to enabled, so only the EncryptionUtil call
site opts out.
@electronicboy electronicboy changed the title Updated Upstream (BungeeCord) Updated Upstream (BungeeCord), drop macOS natives, default native cipher off Aug 31, 2026
@electronicboy
electronicboy merged commit 5a1ca80 into master Sep 1, 2026
2 checks passed
@electronicboy
electronicboy deleted the upstream/bungeecord branch September 1, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant