perf: optimize throughput and scheduler efficency
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user