tun: Benchmark the staged transmit pipeline

Run reads of eight 45-segment superpackets through listenIn into a
discarding socket, inline and with four workers, for both ciphers.
This commit is contained in:
Ryan Huber committed 2026-10-16 21:24:04 +00:00
1 parent eccaf1ca23
commit 82488caa32
1 file changed
+25
+25
View File
@@ -496,3 +496,28 @@ func TestFlowStagedTXAdaptiveBudget(t *testing.T) {
})
}
}
// BenchmarkFlowStagedTX runs reads of eight 45-segment superpackets through listenIn into a socket that discards
// them, inline and staged.
func BenchmarkFlowStagedTX(b *testing.B) {
for _, cipher := range []noise.CipherFunc{noiseutil.CipherAESGCM, noise.CipherChaChaPoly} {
for _, sc := range []stagedConfig{{}, stagedOn(4)} {
b.Run(cipher.CipherName()+"/"+stagedName(sc), func(b *testing.B) {
if sc.tx && cipher.CipherName() == noiseutil.CipherAESGCM.CipherName() && noiseutil.EncryptLockNeeded {
b.Skip("AES-GCM requires encryption in nonce order")
}
sender, _ := newFlowTestPair(b, cipher, sc)
sender.f.writers = []udp.Conn{udp.NoopConn{}}
batch, _ := flowTestBatches(1, 8, 4, 45)
batches := make([][]tio.Packet, b.N)
for i := range batches {
batches[i] = batch[0]
}
b.SetBytes(int64(8 * 45 * flowTestMSS))
b.ReportAllocs()
b.ResetTimer()
sender.f.listenIn(newFlowBatchQueue(batches), 0)
})
}
}
}