13
0
geforkt von Mirrors/Velocity

Try to reduce JNI calls into compressor.

Comparatively speaking, JNI calls are very expensive, so we want to
reduce them as much as possible.
Dieser Commit ist enthalten in:
Andrew Steinborn 2019-01-10 21:10:00 -05:00
Ursprung e240dac55b
Commit 1ddeb85f60
2 geänderte Dateien mit 4 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -56,7 +56,7 @@ public class NativeVelocityCompressor implements VelocityCompressor {
int produced = deflate.process(deflateCtx, source.memoryAddress() + source.readerIndex(),
source.readableBytes(),
destination.memoryAddress() + destination.writerIndex(), destination.writableBytes(),
!source.isReadable());
true);
source.readerIndex(source.readerIndex() + deflate.consumed);
destination.writerIndex(destination.writerIndex() + produced);
}

Datei anzeigen

@ -36,21 +36,21 @@ class VelocityCompressorTest {
compressor.dispose();
fail("Loaded regular compressor");
}
check(compressor, () -> Unpooled.directBuffer(TEST_DATA.length));
check(compressor, () -> Unpooled.directBuffer(TEST_DATA.length + 32));
}
@Test
void javaIntegrityCheckDirect() throws DataFormatException {
VelocityCompressor compressor = JavaVelocityCompressor.FACTORY
.create(Deflater.DEFAULT_COMPRESSION);
check(compressor, () -> Unpooled.directBuffer(TEST_DATA.length));
check(compressor, () -> Unpooled.directBuffer(TEST_DATA.length + 32));
}
@Test
void javaIntegrityCheckHeap() throws DataFormatException {
VelocityCompressor compressor = JavaVelocityCompressor.FACTORY
.create(Deflater.DEFAULT_COMPRESSION);
check(compressor, () -> Unpooled.buffer(TEST_DATA.length));
check(compressor, () -> Unpooled.buffer(TEST_DATA.length + 32));
}
private void check(VelocityCompressor compressor, Supplier<ByteBuf> bufSupplier)