The GitHub Actions job "Validate and test" on pekko-http.git/hpack-huffman-decode-scratch has succeeded. Run started by GitHub user pjfanning (triggered by pjfanning).
Head commit for run: 3038532d1be16ac9c4dd10d659fcda1e832e4989 / PJ Fanning <[email protected]> perf: Huffman decode HPACK string literals into reusable scratch arrays Motivation: HuffmanDecoder collected the decoded symbols in a ByteArrayOutputStream, one synchronized write(int) per symbol, growing it from 32 bytes by doubling, and copied it out with toByteArray; Decoder then copied the result again into a String. The raw literal path allocated and copied once through InputStream.readNBytes and again into the String. This runs for every string literal of every inbound header block, which browsers Huffman code almost entirely. Modification: Decoder keeps two scratch arrays, reused across header blocks: the coded literal is read into one with readNBytes(byte[], int, int), and HuffmanDecoder.decode(buf, length, out) writes the symbols by index into the other, which the caller sizes from the static bound that the shortest code in the HPACK Huffman table is 5 bits (maxDecodedLength). The String is built straight from the scratch array with the ISO-8859-1 charset, the single copy left in either path. The arrays grow to the longest literal seen on the connection, which the max header list size and the dynamic table capacity bound. A MiMa exclude covers the package-private HuffmanDecoder signature. Result: No lock, no stream growth and one copy instead of two or three per string literal: decoding a typical browser request's header block is about 20-25% faster Huffman coded and 35-40% faster raw on JDK 17 (see the PR for the JMH figures, taken on a loaded laptop). Tests: - sbt "http-core/Test/testOnly org.apache.pekko.http.shaded.com.twitter.hpack.HuffmanDecoderSpec org.apache.pekko.http.impl.engine.http2.hpack.HpackDecoderSpec" (Scala 2.13.18 and 3.3.8) - sbt "http2-tests/Test/testOnly org.apache.pekko.http.impl.engine.http2.Http2ServerSpec org.apache.pekko.http.impl.engine.http2.Http2ClientSpec org.apache.pekko.http.impl.engine.http2.RequestParsingSpec" - sbt "http-bench-jmh/Jmh/run -f 1 -wi 3 -i 5 -w 1 -r 1 HpackDecoderBenchmark" on main and on this branch - sbt http-core/mimaReportBinaryIssues; sbt headerCheckAll; sbt javafmtCheckAll (JDK 17) - scalafmt --mode diff-ref=upstream/main References: Refs #1301 - the same change for the encoder; Refs #1251 - the InputStream decoding this builds on Report URL: https://github.com/apache/pekko-http/actions/runs/35936860673 With regards, GitHub Actions via GitBox --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
