Evaluate OPFS-backed binary persistence for the vector index (float32 layout instead of serialized IDB objects)

Đang mở
#1,216 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
52/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
performance, web-dev

Hướng nghiên cứu

Start with src/lib/search/vector-store.ts and src/lib/search/search-worker.ts, then run vector-store.bench.test.ts using vitest.bench.config.ts to establish the IndexedDB baseline. Evaluate OPFS sync access handles and the existing incremental re-embed path without removing the IndexedDB fallback. The evaluation is done when benchmark evidence and browser-support findings are recorded as an ADR under plans/ADRs/; implementation is only warranted if the issue’s “clears the bar” criterion is made explicit.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

discussion enhancement performance priority: low search

Summary

The semantic vector index persists in IndexedDB (src/lib/search/vector-store.ts:11). IndexedDB serializes every entry through structured clone, which is expensive for large float arrays. The 2026 local-first pattern for this exact access shape — "one enormous opaque payload, accessed positionally" — is a contiguous Float32Array packed into a single binary file in OPFS (navigator.storage.getDirectory()), read/written positionally by the search worker with sync access handles, and rebuilt incrementally from the existing content-hash digests.

Evidence

  • src/lib/search/vector-store.ts — IndexedDB persistence behind model/preprocessing/corpus fingerprints.
  • src/lib/search/semantic-digest.ts, vector-store-incremental.test.ts — incremental re-embed machinery already exists, which is the prerequisite for an append-friendly binary layout.
  • The search worker (src/lib/search/search-worker.ts) is the right thread for OPFS sync access handles.

Impact

  • Memory + startup: no structured-clone deserialization of thousands of vectors at boot; a single mmap-able-style buffer scan.
  • Query latency: single-pass dot-product over a contiguous buffer beats per-entry IDB reads, especially at the corpus sizes the semantic budget (semantic-budget.ts) allows.
  • Caveats to weigh: OPFS-in-worker browser support matrix; the current IDB path must remain the fallback; eviction semantics are shared with the corpus quota (pairs with the navigator.storage.persist() work).

Proposed approach

  1. Spike: measure current load time and memory for a representative corpus (the bench harness vitest.bench.config.ts + vector-store.bench.test.ts gives the baseline tooling).
  2. If it clears the bar, implement a dual-mode store (OPFS primary, IDB fallback) behind the existing vector-store interface; extend fingerprinting to cover the layout version.
  3. Record the decision as an ADR in plans/ADRs/ per repo workflow.
  4. Only pursue after the navigator.storage.persist() issue lands so eviction semantics are controlled.

References

Ngôn ngữ chính
TypeScript
Star
3
Fork
2
Merge trung bình
11 giờ 49 phút
Pull request đã merge (30 ngày)
102

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của d-oit/do-knowledge-studio

Tất cả issue của d-oit/do-knowledge-studio

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.