diff --git a/internal/perfcheck/main.go b/internal/perfcheck/main.go index d7e4281..ea97070 100644 --- a/internal/perfcheck/main.go +++ b/internal/perfcheck/main.go @@ -46,6 +46,7 @@ type snapshot struct { Goroutines int `json:"goroutines"` Connections int64 `json:"connections"` Accepted int64 `json:"accepted"` + ActiveRequests int64 `json:"activeRequests,omitempty"` FileDescriptors int `json:"fileDescriptors,omitempty"` } @@ -193,12 +194,14 @@ func serve(adapter string, tlsEnabled bool) error { }) done := make(chan error, 1) var shutdown func(context.Context) error + var stats func() native.Stats switch adapter { case "native": server := native.New(application) server.MaxConnections = 8192 server.MaxConcurrentRequests = 4096 shutdown = server.Shutdown + stats = server.Stats go func() { done <- server.Serve(context.Background(), serveListener) }() case "nethttp": server := &http.Server{ @@ -246,11 +249,16 @@ func serve(adapter string, tlsEnabled bool) error { } var memory runtime.MemStats runtime.ReadMemStats(&memory) + connections, accepted, activeRequests := tracked.active.Load(), tracked.accepted.Load(), int64(0) + if stats != nil { + value := stats() + connections, accepted, activeRequests = value.ActiveConnections, int64(value.AcceptedConnections), value.ActiveRequests + } if err := encoder.Encode(snapshot{ HeapAlloc: memory.HeapAlloc, HeapInuse: memory.HeapInuse, StackInuse: memory.StackInuse, TotalAlloc: memory.TotalAlloc, Mallocs: memory.Mallocs, NumGC: memory.NumGC, - Goroutines: runtime.NumGoroutine(), Connections: tracked.active.Load(), Accepted: tracked.accepted.Load(), + Goroutines: runtime.NumGoroutine(), Connections: connections, Accepted: accepted, ActiveRequests: activeRequests, FileDescriptors: openFileDescriptorCount(), }); err != nil { return err diff --git a/scripts/verifyProxy.py b/scripts/verifyProxy.py index 7806083..bc4d726 100644 --- a/scripts/verifyProxy.py +++ b/scripts/verifyProxy.py @@ -249,6 +249,10 @@ def main() -> None: stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) assert backend.stdin is not None + assert backend.stdout is not None + backend.stdin.write('"snapshot"\n') + backend.stdin.flush() + print(f"native after proxy drain: {backend.stdout.readline().strip()}", flush=True) backend.stdin.write('"stop"\n') backend.stdin.flush() exit_code = backend.wait(timeout=5)