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 <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2026-02-28 22:44:06 -06:00
parent d8dd1f35a5
commit 1fefb1d5e2
2 changed files with 7 additions and 4 deletions

View File

@ -30,6 +30,7 @@ class EdgesMixin:
strength: float = 0.8, strength: float = 0.8,
context: Optional[str] = None, context: Optional[str] = None,
description: Optional[str] = None, description: Optional[str] = None,
skip_commit: bool = False,
) -> str: ) -> str:
"""Create a relationship between two memories with an edge file. """Create a relationship between two memories with an edge file.
@ -137,6 +138,7 @@ class EdgesMixin:
edge_id, edge_data, f"graph/{EDGES_DIR_NAME}/{edge_filename}" edge_id, edge_data, f"graph/{EDGES_DIR_NAME}/{edge_filename}"
) )
if not skip_commit:
self._git_commit( self._git_commit(
f"relate: {from_id[:8]} --{rel_type}--> {to_id[:8]}", f"relate: {from_id[:8]} --{rel_type}--> {to_id[:8]}",
[from_path, to_path, edge_path], [from_path, to_path, edge_path],

View File

@ -632,6 +632,7 @@ def _auto_create_edges(
rel_type=rel_type, rel_type=rel_type,
description=desc, description=desc,
strength=strength, strength=strength,
skip_commit=True, # batched — git sync handles persistence
) )
if edge_id: # Empty string means duplicate if edge_id: # Empty string means duplicate