Start optimizing server list ping.

This commit is contained in:
Andrew Steinborn
2020-10-04 15:30:28 -04:00
parent cb74210cd8
commit 3bf252cf45
10 changed files with 216 additions and 39 deletions

View File

@@ -7,10 +7,10 @@ fi
echo "Compiling libdeflate..."
cd libdeflate || exit
CFLAGS="-fPIC -O2" make
CFLAGS="-fPIC -O2 -fomit-frame-pointer" make
cd ..
CFLAGS="-O3 -I$JAVA_HOME/include/ -I$JAVA_HOME/include/linux/ -fPIC -shared -Wl,-z,noexecstack"
CFLAGS="-O2 -I$JAVA_HOME/include/ -I$JAVA_HOME/include/linux/ -fPIC -shared -Wl,-z,noexecstack -fomit-frame-pointer"
ARCH=$(uname -m)
mkdir -p src/main/resources/linux_$ARCH
gcc $CFLAGS -Ilibdeflate src/main/c/jni_util.c src/main/c/jni_zlib_deflate.c src/main/c/jni_zlib_inflate.c \

View File

@@ -63,6 +63,23 @@ public class LibdeflateVelocityCompressor implements VelocityCompressor {
}
}
@Override
public boolean deflateSingle(ByteBuf source, ByteBuf destination) throws DataFormatException {
ensureNotDisposed();
long sourceAddress = source.memoryAddress() + source.readerIndex();
long destinationAddress = destination.memoryAddress() + destination.writerIndex();
int produced = deflate.process(deflateCtx, sourceAddress, source.readableBytes(),
destinationAddress, destination.writableBytes());
if (produced > 0) {
destination.writerIndex(destination.writerIndex() + produced);
return true;
}
return false;
}
private void ensureNotDisposed() {
Preconditions.checkState(!disposed, "Object already disposed");
}

View File

@@ -14,4 +14,9 @@ public interface VelocityCompressor extends Disposable, Native {
throws DataFormatException;
void deflate(ByteBuf source, ByteBuf destination) throws DataFormatException;
default boolean deflateSingle(ByteBuf source, ByteBuf destination) throws DataFormatException {
deflate(source, destination);
return true;
}
}