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:
Ursprung
e240dac55b
Commit
1ddeb85f60
@ -56,7 +56,7 @@ public class NativeVelocityCompressor implements VelocityCompressor {
|
|||||||
int produced = deflate.process(deflateCtx, source.memoryAddress() + source.readerIndex(),
|
int produced = deflate.process(deflateCtx, source.memoryAddress() + source.readerIndex(),
|
||||||
source.readableBytes(),
|
source.readableBytes(),
|
||||||
destination.memoryAddress() + destination.writerIndex(), destination.writableBytes(),
|
destination.memoryAddress() + destination.writerIndex(), destination.writableBytes(),
|
||||||
!source.isReadable());
|
true);
|
||||||
source.readerIndex(source.readerIndex() + deflate.consumed);
|
source.readerIndex(source.readerIndex() + deflate.consumed);
|
||||||
destination.writerIndex(destination.writerIndex() + produced);
|
destination.writerIndex(destination.writerIndex() + produced);
|
||||||
}
|
}
|
||||||
|
@ -36,21 +36,21 @@ class VelocityCompressorTest {
|
|||||||
compressor.dispose();
|
compressor.dispose();
|
||||||
fail("Loaded regular compressor");
|
fail("Loaded regular compressor");
|
||||||
}
|
}
|
||||||
check(compressor, () -> Unpooled.directBuffer(TEST_DATA.length));
|
check(compressor, () -> Unpooled.directBuffer(TEST_DATA.length + 32));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void javaIntegrityCheckDirect() throws DataFormatException {
|
void javaIntegrityCheckDirect() throws DataFormatException {
|
||||||
VelocityCompressor compressor = JavaVelocityCompressor.FACTORY
|
VelocityCompressor compressor = JavaVelocityCompressor.FACTORY
|
||||||
.create(Deflater.DEFAULT_COMPRESSION);
|
.create(Deflater.DEFAULT_COMPRESSION);
|
||||||
check(compressor, () -> Unpooled.directBuffer(TEST_DATA.length));
|
check(compressor, () -> Unpooled.directBuffer(TEST_DATA.length + 32));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void javaIntegrityCheckHeap() throws DataFormatException {
|
void javaIntegrityCheckHeap() throws DataFormatException {
|
||||||
VelocityCompressor compressor = JavaVelocityCompressor.FACTORY
|
VelocityCompressor compressor = JavaVelocityCompressor.FACTORY
|
||||||
.create(Deflater.DEFAULT_COMPRESSION);
|
.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)
|
private void check(VelocityCompressor compressor, Supplier<ByteBuf> bufSupplier)
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren