Преглед изворни кода

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.
Ryan Huber пре 5 дана
родитељ
комит
82488caa32
1 измењених фајлова са 25 додато и 0 уклоњено
  1. 25 0
      flow_tx_test.go

+ 25 - 0
flow_tx_test.go

@@ -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)
+			})
+		}
+	}
+}