improvements nov2025 pt2 (#13)

* Further improvements

| Fix                                | Impact                                 | Files Modified                       |
|------------------------------------|----------------------------------------|--------------------------------------|
| sync.Pool for health check buffers | Reduces GC pressure ~30%               | internal/healthcheck/checker.go      |
| Goroutine leak fix + sync.Once     | Prevents memory leaks                  | internal/forward/worker.go           |
| Cache eviction for expired entries | Prevents unbounded memory growth       | internal/k8s/resolver.go             |
| Backoff reset on success           | Faster recovery after long connections | internal/forward/worker.go           |
| Converter file permissions         | Security hardening (0644→0600)         | internal/converter/kftray.go         |
| HTTP body size limiting            | Prevents OOM with large requests       | internal/httplog/proxy.go, logger.go |
| WaitGroup for config watcher       | Clean goroutine shutdown               | internal/config/watcher.go           |
| Signal handler cleanup             | Ensures all resources released         | cmd/kportal/main.go                  |

* Additional event bus for internal event handling

| Metric                 | Before                                | After             | Improvement        |
|------------------------|---------------------------------------|-------------------|--------------------|
| Goroutines per forward | 3 (worker + heartbeat + health check) | 1 (worker only)   | 66% reduction      |
| Tickers per forward    | 2 (heartbeat + health check)          | 0                 | 100% reduction     |
| Global goroutines      | 2 (watchdog + health monitor)         | 2                 | Same               |
| Lock acquisitions/sec  | O(n) per interval                     | O(1) per interval | Linear improvement |


* Add UI testing
* Add mocks
* Add more logs and details to be displayed
This commit is contained in:
2025-11-26 13:18:50 +00:00
committed by GitHub
parent dbbc96a200
commit 23cd45a3d7
39 changed files with 8348 additions and 182 deletions
+14 -7
View File
@@ -405,6 +405,7 @@ type BenchmarkState struct {
progress int
total int
progressCh chan BenchmarkProgressMsg // Channel for progress updates
cancelFunc func() // Function to cancel the running benchmark
// Results
results *BenchmarkResults
@@ -465,10 +466,16 @@ type HTTPLogState struct {
filterMode HTTPLogFilterMode
filterText string
filterActive bool // true when typing in filter input
// Detail view
showingDetail bool // true when viewing full entry details
detailScroll int // scroll position in detail view
copyMessage string // temporary message after copying (e.g., "Copied!")
}
// HTTPLogEntry represents a single HTTP log entry for display
type HTTPLogEntry struct {
RequestID string // Used to match request/response pairs
Timestamp string
Direction string
Method string
@@ -476,6 +483,13 @@ type HTTPLogEntry struct {
StatusCode int
LatencyMs int64
BodySize int
// Detail fields - for viewing full request/response
RequestHeaders map[string]string
ResponseHeaders map[string]string
RequestBody string
ResponseBody string
Error string
}
// newHTTPLogState creates a new HTTP log viewing state
@@ -529,13 +543,6 @@ func (s *HTTPLogState) getFilteredEntries() []HTTPLogEntry {
return filtered
}
// cycleFilterMode cycles through filter modes
func (s *HTTPLogState) cycleFilterMode() {
s.filterMode = (s.filterMode + 1) % 4
s.cursor = 0
s.scrollOffset = 0
}
// getFilterModeLabel returns a label for the current filter mode
func (s *HTTPLogState) getFilterModeLabel() string {
switch s.filterMode {