HpackDecoderULE128Benchmark Class — netty Architecture
Architecture documentation for the HpackDecoderULE128Benchmark class in HpackDecoderULE128Benchmark.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD de40d68e_4a6c_694e_c920_73882d2bb6c0["HpackDecoderULE128Benchmark"] 55349ded_2bee_8f6e_c33b_d147955d4e67["HpackDecoderULE128Benchmark.java"] de40d68e_4a6c_694e_c920_73882d2bb6c0 -->|defined in| 55349ded_2bee_8f6e_c33b_d147955d4e67 90d209db_8f50_8af2_1d14_4cf49cc039a0["setup()"] de40d68e_4a6c_694e_c920_73882d2bb6c0 -->|method| 90d209db_8f50_8af2_1d14_4cf49cc039a0 0717d033_95e3_63d9_c72a_27848976905b["decodeMaxLong()"] de40d68e_4a6c_694e_c920_73882d2bb6c0 -->|method| 0717d033_95e3_63d9_c72a_27848976905b b980840d_6eff_4de1_17c7_deeba7582a9a["decodeMaxIntWithLong()"] de40d68e_4a6c_694e_c920_73882d2bb6c0 -->|method| b980840d_6eff_4de1_17c7_deeba7582a9a 65c9c689_5b46_4739_5e08_b7862776759d["decodeMaxInt()"] de40d68e_4a6c_694e_c920_73882d2bb6c0 -->|method| 65c9c689_5b46_4739_5e08_b7862776759d 73150c3e_3cc6_cb4e_983f_f772f64eb38d["decodeMaxIntUsingLong()"] de40d68e_4a6c_694e_c920_73882d2bb6c0 -->|method| 73150c3e_3cc6_cb4e_983f_f772f64eb38d 380d7ceb_df2a_c296_08fd_47d51f945cda["decodeULE128UsingLong()"] de40d68e_4a6c_694e_c920_73882d2bb6c0 -->|method| 380d7ceb_df2a_c296_08fd_47d51f945cda 4c045bd6_da32_a2da_b609_246be602d082["decodeULE128()"] de40d68e_4a6c_694e_c920_73882d2bb6c0 -->|method| 4c045bd6_da32_a2da_b609_246be602d082
Relationship Graph
Source Code
microbench/src/main/java/io/netty/handler/codec/http2/HpackDecoderULE128Benchmark.java lines 35–154
@Threads(1)
@State(Scope.Benchmark)
@Fork(1)
@Warmup(iterations = 5)
@Measurement(iterations = 10)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public class HpackDecoderULE128Benchmark extends AbstractMicrobenchmark {
private static final Http2Exception DECODE_ULE_128_TO_LONG_DECOMPRESSION_EXCEPTION =
new Http2Exception(Http2Error.COMPRESSION_ERROR);
private static final Http2Exception DECODE_ULE_128_TO_INT_DECOMPRESSION_EXCEPTION =
new Http2Exception(Http2Error.COMPRESSION_ERROR);
private static final Http2Exception DECODE_ULE_128_DECOMPRESSION_EXCEPTION =
new Http2Exception(Http2Error.COMPRESSION_ERROR);
private ByteBuf longMaxBuf;
private ByteBuf intMaxBuf;
@Setup
public void setup() {
byte[] longMax = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
(byte) 0xFF, (byte) 0x7F};
longMaxBuf = Unpooled.wrappedBuffer(longMax);
byte[] intMax = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x07};
intMaxBuf = Unpooled.wrappedBuffer(intMax);
}
@Benchmark
@BenchmarkMode(Mode.AverageTime)
public long decodeMaxLong() throws Http2Exception {
long v = decodeULE128(longMaxBuf, 0L);
longMaxBuf.readerIndex(0);
return v;
}
@Benchmark
@BenchmarkMode(Mode.AverageTime)
public long decodeMaxIntWithLong() throws Http2Exception {
long v = decodeULE128(intMaxBuf, 0L);
intMaxBuf.readerIndex(0);
return v;
}
@Benchmark
@BenchmarkMode(Mode.AverageTime)
public int decodeMaxInt() throws Http2Exception {
int v = decodeULE128(intMaxBuf, 0);
intMaxBuf.readerIndex(0);
return v;
}
@Benchmark
@BenchmarkMode(Mode.AverageTime)
public int decodeMaxIntUsingLong() throws Http2Exception {
int v = decodeULE128UsingLong(intMaxBuf, 0);
intMaxBuf.readerIndex(0);
return v;
}
static int decodeULE128UsingLong(ByteBuf in, int result) throws Http2Exception {
final int readerIndex = in.readerIndex();
final long v = decodeULE128(in, (long) result);
if (v > Integer.MAX_VALUE) {
in.readerIndex(readerIndex);
throw DECODE_ULE_128_TO_INT_DECOMPRESSION_EXCEPTION;
}
return (int) v;
}
static long decodeULE128(ByteBuf in, long result) throws Http2Exception {
assert result <= 0x7f && result >= 0;
final boolean resultStartedAtZero = result == 0;
final int writerIndex = in.writerIndex();
for (int readerIndex = in.readerIndex(), shift = 0; readerIndex < writerIndex; ++readerIndex, shift += 7) {
byte b = in.getByte(readerIndex);
if (shift == 56 && ((b & 0x80) != 0 || b == 0x7F && !resultStartedAtZero)) {
// the maximum value that can be represented by a signed 64 bit number is:
// [0x01L, 0x7fL] + 0x7fL + (0x7fL << 7) + (0x7fL << 14) + (0x7fL << 21) + (0x7fL << 28) + (0x7fL << 35)
// + (0x7fL << 42) + (0x7fL << 49) + (0x7eL << 56)
// OR
// 0x0L + 0x7fL + (0x7fL << 7) + (0x7fL << 14) + (0x7fL << 21) + (0x7fL << 28) + (0x7fL << 35) +
// (0x7fL << 42) + (0x7fL << 49) + (0x7fL << 56)
Source
Frequently Asked Questions
What is the HpackDecoderULE128Benchmark class?
HpackDecoderULE128Benchmark is a class in the netty codebase, defined in microbench/src/main/java/io/netty/handler/codec/http2/HpackDecoderULE128Benchmark.java.
Where is HpackDecoderULE128Benchmark defined?
HpackDecoderULE128Benchmark is defined in microbench/src/main/java/io/netty/handler/codec/http2/HpackDecoderULE128Benchmark.java at line 35.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free