perf: optimize throughput and scheduler efficency

This commit is contained in:
xboard
2026-03-23 14:46:43 +08:00
parent 4f1f41aa5d
commit e8e2abbc37
4 changed files with 135 additions and 46 deletions
+12
View File
@@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"sort"
"sync"
"github.com/cedar2025/xboard-node/internal/panel"
"golang.org/x/time/rate"
@@ -88,6 +89,17 @@ type Connection struct {
SourceIP string // client source IP (cleaned, no port/brackets)
}
var ConnectionSlicePool = sync.Pool{
New: func() any { return make([]Connection, 0, 256) },
}
func ReleaseConnectionSlice(s []Connection) {
if s == nil {
return
}
ConnectionSlicePool.Put(s[:0])
}
// UserDiff computes which users to add and which to remove when transitioning
// from oldUsers to newUsers. This is a pure helper used by callers; kernels
// may also use it internally.