Release 3.8.2.5: cheaper idle UI poll and tighter hot paths.
Delta getState by rev, pause when hidden, cancellable background loops, hostCache bounds, unlock PollUI around engine status, corebin singleflight, PingAll worker pool. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -18,6 +18,8 @@ type ProfileInfo struct {
|
||||
// hostCache avoids re-parsing large AWG conf bodies on every UI poll.
|
||||
var hostCache sync.Map // proxy URI/conf → host string
|
||||
|
||||
const hostCacheMax = 2048
|
||||
|
||||
func cachedProxyHost(proxy string) string {
|
||||
proxy = strings.TrimSpace(proxy)
|
||||
if proxy == "" {
|
||||
@@ -28,9 +30,32 @@ func cachedProxyHost(proxy string) string {
|
||||
}
|
||||
h := proxyHost(proxy)
|
||||
hostCache.Store(proxy, h)
|
||||
// Soft bound: subscription churn can retain stale URI keys; drop all if oversized.
|
||||
n := 0
|
||||
over := false
|
||||
hostCache.Range(func(_, _ any) bool {
|
||||
n++
|
||||
if n > hostCacheMax {
|
||||
over = true
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
if over {
|
||||
InvalidateHostCache()
|
||||
hostCache.Store(proxy, h)
|
||||
}
|
||||
return h
|
||||
}
|
||||
|
||||
// InvalidateHostCache clears parsed host strings (call after profile mutations).
|
||||
func InvalidateHostCache() {
|
||||
hostCache.Range(func(k, _ any) bool {
|
||||
hostCache.Delete(k)
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
// ListProfiles returns UI-friendly profile summaries.
|
||||
func (c *Config) ListProfiles() []ProfileInfo {
|
||||
out := make([]ProfileInfo, 0, len(c.Profiles))
|
||||
|
||||
Reference in New Issue
Block a user