From 9edcb6f19f453018b5861931c692cb6f0301139b Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Mon, 27 Oct 2025 23:20:06 -0700 Subject: [PATCH] Remove cache fields from Server struct (bd-31) - Removed storageCache, cacheMu, maxCacheSize, cacheTTL, cleanupTicker fields - Removed cacheHits and cacheMisses metrics - Removed cache size/TTL parsing from env vars in NewServer() - Removed cleanup ticker goroutine from Start() - Removed cache cleanup logic from Stop() - Part of bd-29 epic to remove daemon storage cache Amp-Thread-ID: https://ampcode.com/threads/T-239a5531-68a5-4c98-b85d-0e3512b2553c Co-authored-by: Amp --- internal/rpc/server_core.go | 27 --------------------------- internal/rpc/server_lifecycle_conn.go | 19 +------------------ 2 files changed, 1 insertion(+), 45 deletions(-) diff --git a/internal/rpc/server_core.go b/internal/rpc/server_core.go index 1795c8a3..74a101ac 100644 --- a/internal/rpc/server_core.go +++ b/internal/rpc/server_core.go @@ -32,17 +32,9 @@ type Server struct { shutdownChan chan struct{} stopOnce sync.Once doneChan chan struct{} // closed when Start() cleanup is complete - // Per-request storage routing with eviction support - storageCache map[string]*StorageCacheEntry // repoRoot -> entry - cacheMu sync.RWMutex - maxCacheSize int - cacheTTL time.Duration - cleanupTicker *time.Ticker // Health and metrics startTime time.Time lastActivityTime atomic.Value // time.Time - last request timestamp - cacheHits int64 - cacheMisses int64 metrics *Metrics // Connection limiting maxConns int @@ -59,22 +51,6 @@ type Server struct { // NewServer creates a new RPC server func NewServer(socketPath string, store storage.Storage, workspacePath string, dbPath string) *Server { // Parse config from env vars - maxCacheSize := 50 // default - if env := os.Getenv("BEADS_DAEMON_MAX_CACHE_SIZE"); env != "" { - // Parse as integer - var size int - if _, err := fmt.Sscanf(env, "%d", &size); err == nil && size > 0 { - maxCacheSize = size - } - } - - cacheTTL := 30 * time.Minute // default - if env := os.Getenv("BEADS_DAEMON_CACHE_TTL"); env != "" { - if ttl, err := time.ParseDuration(env); err == nil && ttl > 0 { - cacheTTL = ttl - } - } - maxConns := 100 // default if env := os.Getenv("BEADS_DAEMON_MAX_CONNS"); env != "" { var conns int @@ -95,9 +71,6 @@ func NewServer(socketPath string, store storage.Storage, workspacePath string, d workspacePath: workspacePath, dbPath: dbPath, storage: store, - storageCache: make(map[string]*StorageCacheEntry), - maxCacheSize: maxCacheSize, - cacheTTL: cacheTTL, shutdownChan: make(chan struct{}), doneChan: make(chan struct{}), startTime: time.Now(), diff --git a/internal/rpc/server_lifecycle_conn.go b/internal/rpc/server_lifecycle_conn.go index 69ef7fe9..6412daa6 100644 --- a/internal/rpc/server_lifecycle_conn.go +++ b/internal/rpc/server_lifecycle_conn.go @@ -49,7 +49,6 @@ func (s *Server) Start(_ context.Context) error { close(s.readyChan) go s.handleSignals() - go s.runCleanupLoop() // Ensure cleanup is signaled when this function returns defer close(s.doneChan) @@ -107,23 +106,7 @@ func (s *Server) Stop() error { // Signal cleanup goroutine to stop close(s.shutdownChan) - // Close all cached storage connections outside lock - s.cacheMu.Lock() - stores := make([]storage.Storage, 0, len(s.storageCache)) - for _, entry := range s.storageCache { - stores = append(stores, entry.store) - } - s.storageCache = make(map[string]*StorageCacheEntry) - s.cacheMu.Unlock() - - // Close stores without holding lock - for _, store := range stores { - if closeErr := store.Close(); closeErr != nil { - fmt.Fprintf(os.Stderr, "Warning: failed to close storage: %v\n", closeErr) - } - } - - // Close default storage + // Close storage if s.storage != nil { if closeErr := s.storage.Close(); closeErr != nil { fmt.Fprintf(os.Stderr, "Warning: failed to close default storage: %v\n", closeErr)