Skip to content

Commit

Permalink
Fix performance tests issues:
Browse files Browse the repository at this point in the history
- update to quicly-go v0.3.0
- fix perf tests client graceful stop
- fix CI config for client/server
- fix client initial connection check
- removed excessive debug logging
  • Loading branch information
parvit committed Aug 31, 2024
1 parent e448dd3 commit 6449f65
Show file tree
Hide file tree
Showing 15 changed files with 75 additions and 70 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ run-name: Code Integration [${{ github.event_name }}][${{ github.head_ref || git

jobs:
build-linux:
if: true
runs-on: ubuntu-latest
env:
GO_VERSION: 1.20.14
Expand Down Expand Up @@ -118,6 +119,7 @@ jobs:
path: "report/*.html"

build-windows:
if: true
runs-on: windows-latest
env:
GO_VERSION: 1.20.14
Expand Down
48 changes: 38 additions & 10 deletions .github/workflows/run-performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,20 @@ jobs:
shell: pwsh
run: |
$Stoploop = $false
[ int ]$MaxRetries = "120"
[ int ]$MaxRetries = "60"
[ int ]$Retrycount = $MaxRetries
do {
do {
try {
$DT = get-date -format "yyyy-MM-dd_HH:mm:ss"
Write-Host "$DT : Echoing server... (Remaining $Retrycount)"
Invoke-WebRequest -Uri "http://${{ inputs.server_public_address }}:444/api/v1/server/echo" -UseBasicParsing -TimeoutSec 1
Invoke-WebRequest -Uri "http://${{ inputs.server_public_address }}:444/api/v1/server/echo" -UseBasicParsing -TimeoutSec 3
Write-Host "Job completed"
$Stoploop = $true
}
catch {
$Retrycount = $Retrycount - 1
if ($Retrycount -gt 0){
Start-Sleep -Seconds 2
}
else {
if ($Retrycount -lt 0){
Write-Error "Could not get server after $MaxRetries retries." -ErrorAction Stop
}
}
Expand All @@ -182,8 +179,39 @@ jobs:
- name: Stop Client
if: always()
shell: pwsh
continue-on-error: true
run: |
${{ github.workspace }}/docker/speedtests/utils/windows-kill.exe -SIGBREAK @(Get-Process qpep | select -expand id)
- name: Wait Client Stop
if: always()
shell: pwsh
continue-on-error: true
run: |
Get-Process qpep | Stop-Process
$Stoploop = $false
[ int ]$MaxRetries = "60"
[ int ]$Retrycount = $MaxRetries
do {
try {
$id = Get-Process qpep -ErrorAction Stop | select -expand id
Write-Host "QPep client still active with pid ${id}, wait 1sec... (Retries: ${Retrycount})"
Start-Sleep -Seconds 1
$Retrycount = $Retrycount - 1
}
catch {
$Stoploop = $true
Write-Host "QPep client stopped"
}
if ($Retrycount -lt 0){
Write-Host "Could not get stop client after $MaxRetries retries, forcing stop."
$Stoploop = $true
Get-Process qpep | Stop-Process
}
}
While($Stoploop -eq $false)
- name: Reset Proxy
if: always()
Expand Down Expand Up @@ -285,7 +313,7 @@ jobs:
uses:
nick-fields/retry@v3
with:
timeout_minutes: 10
timeout_minutes: 5
max_attempts: 3
retry_on: timeout
warning_on_retry: true
Expand All @@ -300,7 +328,7 @@ jobs:
RETRIES=${{ inputs.server_wait_timeout }}
while ! (( RETRIES <= 0 ));
do
CONN_NUM=$(curl -s -XGET -H 'Accept:application/json' http://127.0.0.1:444/api/v1/server/echo | jq .total_connections || true)
CONN_NUM=$(curl -s -XGET -H 'Accept:application/json' -H 'Connection: close' http://127.0.0.1:444/api/v1/server/echo | jq .total_connections || true)
if [[ "$CONN_NUM" == "" ]]; then
echo [FAIL]: Local server not available
exit 1
Expand Down
5 changes: 5 additions & 0 deletions api/api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/parvit/qpep/logger"
"net"
"net/http"
"net/http/httputil"
"net/url"
"runtime"
"strings"
Expand Down Expand Up @@ -60,6 +61,10 @@ func doAPIRequest(addr string, client *http.Client) (*http.Response, error) {
logger.Error("%v\n", err)
return nil, err
}

data, _ := httputil.DumpResponse(resp, true)
logger.Info("RESP: %v\n", string(data))

return resp, nil
}

Expand Down
4 changes: 2 additions & 2 deletions backend/backend_quicgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ func (q *quicGoBackend) Close() error {
func qgoGetConfiguration(traceOn bool) *quic.Config {
cfg := &quic.Config{
MaxIncomingStreams: 1024,
DisablePathMTUDiscovery: true,
MaxIdleTimeout: 15 * time.Second,
DisablePathMTUDiscovery: false,
MaxIdleTimeout: 2 * time.Second,

InitialConnectionReceiveWindow: 10 * 1024 * 1024,

Expand Down
2 changes: 1 addition & 1 deletion backend/backend_quiclygo.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (q *quiclyGoBackend) init(isClient, traceOn bool, certPath, certKeyPath, cc
CertificateFile: certPath,
CertificateKey: certKeyPath,
ApplicationProtocol: QUICLYGO_ALPN,
IdleTimeoutMs: 5 * 1000,
IdleTimeoutMs: 30 * 1000,
CongestionAlgorithm: ccAlgorithm,
CCSlowstartAlgorithm: ccSlowstartAlgo,
TraceQuicly: traceOn,
Expand Down
1 change: 1 addition & 0 deletions docker/client-env/qpep.yml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ listenport: 9443
backend: <QPEP_BACKEND>
ccalgorithm: <QPEP_CCA>
ccslowstart: <QPEP_SLOWSTART>
buffersize: 512 # in Kb

# certificate
certificate: server_cert.pem
Expand Down
1 change: 1 addition & 0 deletions docker/server-env/server/config/qpep.yml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ listenport: ${QPEP_PORT}
backend: ${QPEP_BACKEND}
ccalgorithm: ${QPEP_CCA}
ccslowstart: ${QPEP_SLOWSTART}
buffersize: 512 # in Kb

# certificate
certificate: server_cert.pem
Expand Down
Binary file added docker/speedtests/utils/windows-kill.exe
Binary file not shown.
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
require (
bou.ke/monkey v1.0.2
github.com/Project-Faster/quic-go v0.0.0-20230209052722-fd67b0616c6d
github.com/Project-Faster/quicly-go v0.0.0-00010101000000-000000000000
github.com/Project-Faster/quicly-go v0.3.0
github.com/eclipse/paho.mqtt.golang v1.4.2
github.com/jessevdk/go-flags v1.5.0
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d
Expand Down Expand Up @@ -61,13 +61,11 @@ require (
github.com/quic-go/qtls-go1-18 v0.2.0 // indirect
github.com/quic-go/qtls-go1-19 v0.2.0 // indirect
github.com/quic-go/qtls-go1-20 v0.1.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
golang.org/x/crypto v0.6.0 // indirect
golang.org/x/exp v0.0.0-20230206171751-46f607a40771 // indirect
golang.org/x/image v0.0.0-20220902085622-e7cb96979f69 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/sync v0.2.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/tools v0.9.1 // indirect
modernc.org/mathutil v1.5.0 // indirect
)
5 changes: 0 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ github.com/quic-go/qtls-go1-19 v0.2.0 h1:Cvn2WdhyViFUHoOqK52i51k4nDX8EwIh5VJiVM4
github.com/quic-go/qtls-go1-19 v0.2.0/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI=
github.com/quic-go/qtls-go1-20 v0.1.0 h1:d1PK3ErFy9t7zxKsG3NXBJXZjp/kMLoIb3y/kV54oAI=
github.com/quic-go/qtls-go1-20 v0.1.0/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U=
Expand Down Expand Up @@ -210,6 +207,4 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las=
modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ=
modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
rsc.io/pdf v0.1.1 h1:k1MczvYDUvJBe93bYd7wrZLLUEcLZAuF824/I4e5Xr4=
4 changes: 4 additions & 0 deletions shared/gateway_interface_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ BLOCK:
}

func SetSystemProxy(active bool) {
if active && ProxyAddress != nil {
return
}

preloadRegistryKeysForUsers()

if !active {
Expand Down
37 changes: 8 additions & 29 deletions workers/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (
RedirectedInterfaces: []int64{},
QuicStreamTimeout: 2, MultiStream: shared.QPepConfig.MultiStream,
MaxConnectionRetries: shared.DEFAULT_REDIRECT_RETRIES,
IdleTimeout: time.Duration(300) * time.Second,
IdleTimeout: time.Duration(3) * time.Second,
WinDivertThreads: 1,
Verbose: false,
}
Expand Down Expand Up @@ -118,12 +118,16 @@ func handleServices(ctx context.Context, cancel context.CancelFunc, wg *sync.Wai

var connected = false
var checkIsRunning = false
var publicAddress = ""

// start redirection right away because we normally expect the
// connection with the server to be on already up
initialCheckConnection()

localAddr := ClientConfiguration.ListenHost
apiAddr := ClientConfiguration.GatewayHost
apiPort := ClientConfiguration.APIPort
connected, _ = gatewayStatusCheck(localAddr, apiAddr, apiPort)

// Update loop
for {
select {
Expand All @@ -133,47 +137,22 @@ func handleServices(ctx context.Context, cancel context.CancelFunc, wg *sync.Wai
}
return

case <-time.After(1 * time.Second):
case <-time.After(10 * time.Second):
if shared.DEBUG_MASK_REDIRECT || checkIsRunning {
continue
}
checkIsRunning = true
localAddr := ClientConfiguration.ListenHost
apiAddr := ClientConfiguration.GatewayHost
apiPort := ClientConfiguration.APIPort
if !connected {
ok, response := gatewayStatusCheck(localAddr, apiAddr, apiPort)
checkIsRunning = false
if ok {
publicAddress = response.Address
connected = true
logger.Info("Server returned public address %s\n", publicAddress)

} else {
// if connection is lost then keep the redirection active
// for a certain number of retries then terminate to not keep
// all the network blocked
if failedCheckConnection() {
return
}
}
continue
}

connected = clientStatisticsUpdate(localAddr, apiAddr, apiPort, publicAddress)
connected, _ = gatewayStatusCheck(localAddr, apiAddr, apiPort)
checkIsRunning = false
if !connected {
logger.Info("Error during statistics update from server\n")

// if connection is lost then keep the redirection active
// for a certain number of retries then terminate to not keep
// all the network blocked
if failedCheckConnection() {
return
}
connected = false
}
continue
}
}
}
Expand Down
13 changes: 3 additions & 10 deletions workers/client/client_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func handleTCPConn(tcpConn net.Conn) {
}

//Proxy all stream content from quic to TCP and from TCP to quic
logger.Info("[%d] Stream Start", quicStream.ID())
logger.Debug("[%d] Stream Start", quicStream.ID())

tqActiveFlag := atomic.Bool{}
qtActiveFlag := atomic.Bool{}
Expand Down Expand Up @@ -192,7 +192,6 @@ func getQuicStream(ctx context.Context) (backend.QuicBackendStream, error) {
logger.Debug("Trying to open on existing session")
quicStream, err = localSession.OpenStream(context.Background())
if err == nil {
logger.Info("Opened a new stream: %d", quicStream.ID())
return quicStream, nil
}
// if we weren't able to open a quicStream on that session (usually inactivity timeout), we can try to open a new session
Expand Down Expand Up @@ -362,13 +361,8 @@ func handleProxyedRequest(req *http.Request, header *shared.QPepHeader, tcpConn
return shared.ErrFailed
}

logger.Info("Sending captured %s request\n", req.Method)
logger.Debug("Sending captured %s request\n", req.Method)
err = req.Write(stream)
//if err != nil {
// _ = tcpConn.Close()
// logger.Error("Error writing to tcp stream: %v", err)
// return shared.ErrFailed
//}
break

case http.MethodConnect:
Expand Down Expand Up @@ -403,8 +397,7 @@ func handleProxyedRequest(req *http.Request, header *shared.QPepHeader, tcpConn

t.Write(tcpConn)

logger.Info("Proxied connection")
logger.Info("Sending QPEP header to server, SourceAddr: %v / DestAddr: %v / ID: %v", header.SourceAddr, header.DestAddr, stream.ID())
logger.Info("(Proxied) Sending QPEP header to server, SourceAddr: %v / DestAddr: %v / ID: %v", header.SourceAddr, header.DestAddr, stream.ID())

_, err := stream.Write(header.ToBytes())
if err != nil {
Expand Down
Loading

0 comments on commit 6449f65

Please sign in to comment.