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

Aperta
#1,216 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
TypeScript
Stelle
3
Fork
2
Merge medio
11h 49m
PR unite (30g)
102

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di d-oit/do-knowledge-studio

Tutte le issue di d-oit/do-knowledge-studio

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.