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

オープン
#1,216 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
52/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
typescript

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
TypeScript
スター
3
フォーク
2
平均マージ
11時間 49分
マージ済み PR(30日)
102

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

d-oit/do-knowledge-studio のほかの issue

d-oit/do-knowledge-studio の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。