perf(sub): cache each inbound's settings without clients for subscription bodies (#6758)

Every subscription fetch read and scanned each inbound's whole settings
blob, about 25 MB at 100k clients, although subscription bodies resolve
their clients from the clients table and never use its clients array.

Each inbound's settings minus the clients array are now cached, keyed by
inbound and shared by all its subscribers; the inbound row, clients,
stats and hosts are still read per fetch, and WireGuard and AmneziaWG keep
full settings for their peers. Panel edits purge the cache through an
invalidator registry the subscription server releases on stop, with a
10 s TTL as the backstop. At 100k clients a hit takes 2.1 ms on SQLite
(72.5 ms before) and 20.7 ms on PostgreSQL (332 ms).
This commit is contained in:
Шакирзянов Амир
2026-10-24 23:45:46 +03:00
committed by GitHub
parent 8da3b3c344
commit 73fad424ed
13 changed files with 469 additions and 13 deletions
+3
View File
@@ -466,6 +466,9 @@ func (s *Server) Start() (err error) {
// Stop gracefully shuts down the subscription server and closes the listener.
func (s *Server) Stop() error {
s.cancel()
if s.sub != nil {
s.sub.Close()
}
var err1 error
var err2 error