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:
parent
d8dd1f35a5
commit
1fefb1d5e2
10
edges.py
10
edges.py
@ -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,10 +138,11 @@ class EdgesMixin:
|
|||||||
edge_id, edge_data, f"graph/{EDGES_DIR_NAME}/{edge_filename}"
|
edge_id, edge_data, f"graph/{EDGES_DIR_NAME}/{edge_filename}"
|
||||||
)
|
)
|
||||||
|
|
||||||
self._git_commit(
|
if not skip_commit:
|
||||||
f"relate: {from_id[:8]} --{rel_type}--> {to_id[:8]}",
|
self._git_commit(
|
||||||
[from_path, to_path, edge_path],
|
f"relate: {from_id[:8]} --{rel_type}--> {to_id[:8]}",
|
||||||
)
|
[from_path, to_path, edge_path],
|
||||||
|
)
|
||||||
return edge_id
|
return edge_id
|
||||||
|
|
||||||
def edge_get(self, edge_id: str) -> Optional[Dict[str, Any]]:
|
def edge_get(self, edge_id: str) -> Optional[Dict[str, Any]]:
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user