perf(826-1): M02 층 목록 요약 색인 — 자국 같으면 항목 파일 안 엶 · 판 · 요약 · 쓰는곳수 기억
- 새 M02_Layer_Index — 항목마다 자국(고친 때 · 크기) · 판 · 서고 요약 기억(메모리 + storage _derived/m02_layer_index) · 바뀐 항목만 다시 읽어 셈 - 기준금액 기댐 = 셈 코드 내용 · M01 폴더 · 층 곁 파일 자국 + 셈 때 읽은 참조 파일 자국(refs.SEEN) - 쓰는곳수 = 요청마다 쓰는 곳 파일 한 번 훑어 거꾸로 셈 · 참조 이름표 기억도 파생 저장본(ids.json) - 판 확인(저장 · 지움 409)은 그대로 파일 내용 · 목록 답 내용 · 차례 그대로(8004 바이트 대조) - 개인 층(102 줄) 두 번째 3.0 → 0.14 초 · 다시 뜬 뒤 첫 9.9 → 0.24 초 · 마스터 2.9 → 0.10 초 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -24,6 +24,7 @@ from __future__ import annotations
|
||||
import json
|
||||
import re
|
||||
from collections.abc import Callable
|
||||
from contextvars import ContextVar
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
@@ -125,11 +126,18 @@ def copy_ref(body: dict[str, Any], key: str) -> Ref:
|
||||
}
|
||||
|
||||
|
||||
#: 참조 파일을 읽기 직전에 부름(826-1 층 목록 색인 기댐 · `M02_Layer_Index`) — None = 안 부름.
|
||||
SEEN: ContextVar[Callable[[Path], None] | None] = ContextVar("m02_refs_seen", default=None)
|
||||
|
||||
|
||||
def read_ref(ref: Ref) -> dict[str, Any] | None:
|
||||
if is_copy(ref):
|
||||
return ref["몸"]
|
||||
try:
|
||||
got = json.loads(ref_path(ref).read_bytes())
|
||||
path = ref_path(ref)
|
||||
if (note := SEEN.get()) is not None:
|
||||
note(path)
|
||||
got = json.loads(path.read_bytes())
|
||||
except (OSError, ValueError):
|
||||
return None
|
||||
return got if isinstance(got, dict) else None
|
||||
|
||||
Reference in New Issue
Block a user