Switch out Cloudflare zlib for libdeflate.
libdeflate is significantly faster than vanilla zlib, zlib-ng, and Cloudflare zlib. It is also MIT-licensed (so no licensing concerns). In addition, it simplifies a lot of the native code (something that's been tricky to get right). While we're at it, I have also taken the time to fine-time compression in Velocity in general. Thanks to this work, native compression only requires one JNI call, an improvement from the more than 2 (sometimes up to 5) that were possible before. This optimization also extends to the existing Java compressors, though they require potentially two JNI calls.
This commit is contained in:
@@ -1,21 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ ! -d zlib-ng ]; then
|
||||
echo "Cloning zlib-ng..."
|
||||
git clone https://github.com/zlib-ng/zlib-ng.git
|
||||
if [ ! -d libdeflate ]; then
|
||||
echo "Cloning libdeflate..."
|
||||
git clone https://github.com/ebiggers/libdeflate.git
|
||||
fi
|
||||
|
||||
echo "Compiling zlib-ng..."
|
||||
cd zlib-ng
|
||||
CFLAGS="-fPIC -O3" ./configure --zlib-compat --static
|
||||
make clean && make
|
||||
echo "Compiling libdeflate..."
|
||||
cd libdeflate || exit
|
||||
make
|
||||
cd ..
|
||||
|
||||
# Modify as you need.
|
||||
MBEDTLS_ROOT=mbedtls
|
||||
CFLAGS="-O3 -I$JAVA_HOME/include/ -I$JAVA_HOME/include/linux/ -fPIC -shared"
|
||||
gcc $CFLAGS -Izlib-ng src/main/c/jni_util.c src/main/c/jni_zlib_deflate.c src/main/c/jni_zlib_inflate.c \
|
||||
src/main/c/jni_zlib_common.c zlib-ng/libz.a -o src/main/resources/linux_x64/velocity-compress.so
|
||||
gcc $CFLAGS -I $MBEDTLS_ROOT/include -shared $MBEDTLS_ROOT/library/aes.c $MBEDTLS_ROOT/library/aesni.c \
|
||||
CFLAGS="-O3 -I$JAVA_HOME/include/ -I$JAVA_HOME/include/linux/ -fPIC -shared -Wl,-z,noexecstack"
|
||||
gcc $CFLAGS -Ilibdeflate src/main/c/jni_util.c src/main/c/jni_zlib_deflate.c src/main/c/jni_zlib_inflate.c \
|
||||
libdeflate/libdeflate.a -o src/main/resources/linux_x64/velocity-compress.so
|
||||
gcc $CFLAGS -I $MBEDTLS_ROOT/include -shared $MBEDTLS_ROOT/library/aes.c $MBEDTLS_ROOT/library/aesni.c \
|
||||
$MBEDTLS_ROOT/library/platform.c $MBEDTLS_ROOT/library/platform_util.c src/main/c/jni_util.c src/main/c/jni_cipher.c \
|
||||
-o src/main/resources/linux_x64/velocity-cipher.so
|
||||
-o src/main/resources/linux_x64/velocity-cipher.so
|
||||
|
Reference in New Issue
Block a user