wire: optimize parsing logic for STREAM, DATAGRAM and ACK frames (#5227)

ParseOtherFrames-16       148ns ± 4%     150ns ± 3%     ~     (p=0.223 n=8+8)
ParseAckFrame-16          302ns ± 2%     298ns ± 3%     ~     (p=0.246 n=8+8)
ParseStreamFrame-16       262ns ± 3%     213ns ± 2%  -18.61%  (p=0.000 n=8+8)
ParseDatagramFrame-16     561ns ± 5%     547ns ± 4%     ~     (p=0.105 n=8+8)
This commit is contained in:
Jannis Seemann
2025-07-20 14:14:38 +03:00
committed by GitHub
parent 893a5941fb
commit c2e784aaf2
49 changed files with 1097 additions and 450 deletions

View File

@@ -33,7 +33,7 @@ func TestWriteDataBlocked(t *testing.T) {
frame := DataBlockedFrame{MaximumData: 0xdeadbeef}
b, err := frame.Append(nil, protocol.Version1)
require.NoError(t, err)
expected := []byte{dataBlockedFrameType}
expected := []byte{byte(FrameTypeDataBlocked)}
expected = append(expected, encodeVarInt(0xdeadbeef)...)
require.Equal(t, expected, b)
require.Equal(t, protocol.ByteCount(1+quicvarint.Len(uint64(frame.MaximumData))), frame.Length(protocol.Version1))