From 16245803659269ae239edb8abff9f73ba9357722 Mon Sep 17 00:00:00 2001 From: Fabian Engelniederhammer Date: Wed, 3 Apr 2024 14:43:34 +0200 Subject: [PATCH] fix: speed up compressing responses #717 Tests on a medium-sized data set (3552 sequences): I measured request times of /sample/unalignedNucleotideSequences: - uncompressed: 1300 ms, 65 MB - gzip compressed: 3100 ms (before: 14 s), 8 MB - zstd compressed: 970 ms (before: 7.4 s), 342 kB --- .../lapis/controller/CompressionFilter.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lapis2/src/main/kotlin/org/genspectrum/lapis/controller/CompressionFilter.kt b/lapis2/src/main/kotlin/org/genspectrum/lapis/controller/CompressionFilter.kt index db7f7eb1..2a90aaae 100644 --- a/lapis2/src/main/kotlin/org/genspectrum/lapis/controller/CompressionFilter.kt +++ b/lapis2/src/main/kotlin/org/genspectrum/lapis/controller/CompressionFilter.kt @@ -222,6 +222,18 @@ class CompressingServletOutputStream( compressingStream.write(byte) } + override fun write(bytes: ByteArray) { + compressingStream.write(bytes) + } + + override fun write( + bytes: ByteArray, + offset: Int, + length: Int, + ) { + compressingStream.write(bytes, offset, length) + } + override fun isReady() = outputStream.isReady override fun setWriteListener(listener: WriteListener?) = outputStream.setWriteListener(listener)