Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
무엇
reembedMemoryTable이table.query().limit(1_000_000).toArray()로 전체를 읽던 것을offset/limit배치(기본REEMBED_BATCH_SIZE = 1000, 옵션batchSize)로 바꿨다. 배치마다 정규화·임베딩 후 임시 테이블에add한다. 행 수 상한으로 거부하지 않는다.countRows()로 원본 행 수를 잡고, 읽은 행 수·임시 테이블 행 수가 다르면 교체하지 않고 실패한다(불완전한 임시 테이블은 삭제, 라이브 테이블·signature는 그대로).overwrite, 이후는add로 쓴다. 교체 후 행 수를 다시 확인하고, 실패하면 기존처럼 임시 테이블을 복구용으로 남긴다.왜
큰 store에서 전체 행을 한 번에 메모리에 올려 메모리를 다 쓰고, 100만 행을 넘으면 조용히 잘렸다.
트레이드오프
교체가 이제 단일 overwrite가 아니라 overwrite + add 여러 번이다. 교체 도중 프로세스가 죽으면 라이브 테이블이 일부만 채워질 수 있다 — 그 경우
_reembed_<ts>임시 테이블에 완성본이 남아 있다(기존 실패 경로와 같은 복구 방식). 전역 id 정렬은 없어졌다(삽입 순서 유지).검증
reembed.test.ts의 mock을 offset/limit·add·countRows·overwrite를 지원하는 인메모리 테이블로 바꾸고 신규 2건 추가: 배치(5)보다 큰 23행 store에서 결과 행 수·id·vector가 원본과 같고 한 번에 읽고 쓰는 행이 5 이하, 실행 중 원본 행 수가 바뀌면 교체 거부. 두 신규 테스트는 수정 전 코드에서 실패 확인.vitest run src/memory15 파일 114 테스트 통과,tsc --noEmit -p tsconfig.check.json통과, oxlint 0건.reembed.store.test.ts추가(인코더만 mock): 7행·배치 3에서 행 수·id·vector 스키마 타입이 유지되고 모든 행이 새 vector를 가지며 임시 테이블이 정리된다. 교체 복사에서normalizeRecords를 빼면 이 테스트가Failed to infer data type for field vector.isValid로 실패함을 확인 — Lance가 돌려주는 Arrow vector를 그대로 쓰면 깨진다. 그래서 교체 복사도 정규화를 거친다.vitest run src/memory16 파일 115 테스트 통과. 대용량(수십만 행) 실측은 없다.Linear: AGT-4880