From 1fefb1d5e24bfdba5af6e45f930668a1ed1ce2fc Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Sat, 28 Feb 2026 22:44:06 -0600 Subject: [PATCH] perf: skip per-edge git commits during auto-edge creation Auto-edges called relate() up to 3 times per store, each triggering a blocking git subprocess (~50-100ms each). Now relate() accepts skip_commit=True so auto-edges defer to the fire-and-forget git sync, cutting 150-300ms of latency from every memory_store call. Closes #2 Co-Authored-By: Claude Opus 4.6 --- edges.py | 10 ++++++---- mcp_server.py | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/edges.py b/edges.py index a7769c0..9462f82 100644 --- a/edges.py +++ b/edges.py @@ -30,6 +30,7 @@ class EdgesMixin: strength: float = 0.8, context: Optional[str] = None, description: Optional[str] = None, + skip_commit: bool = False, ) -> str: """Create a relationship between two memories with an edge file. @@ -137,10 +138,11 @@ class EdgesMixin: edge_id, edge_data, f"graph/{EDGES_DIR_NAME}/{edge_filename}" ) - self._git_commit( - f"relate: {from_id[:8]} --{rel_type}--> {to_id[:8]}", - [from_path, to_path, edge_path], - ) + if not skip_commit: + self._git_commit( + f"relate: {from_id[:8]} --{rel_type}--> {to_id[:8]}", + [from_path, to_path, edge_path], + ) return edge_id def edge_get(self, edge_id: str) -> Optional[Dict[str, Any]]: diff --git a/mcp_server.py b/mcp_server.py index 31e918e..2ea9667 100644 --- a/mcp_server.py +++ b/mcp_server.py @@ -632,6 +632,7 @@ def _auto_create_edges( rel_type=rel_type, description=desc, strength=strength, + skip_commit=True, # batched — git sync handles persistence ) if edge_id: # Empty string means duplicate