Start optimizing server list ping.
This commit is contained in:
@@ -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 \
|
||||
|
@@ -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");
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user