Skip to content

perf(lexical/index): batch ingestion API (add_documents / commit_batch) #551

Description

@mosuka

Round-3 perf push sub-issue (tracked under umbrella #533).

[L] Batch ingestion API (add_documents / commit_batch) (parity:Tantivy)

  • Where: laurus/src/lexical/store.rs:145-151 (single-doc upsert_document), laurus/src/engine.rs:170-272 (only single-doc put).
  • Current behavior: Every external ingest call takes one document, walks the full stack (apply_dynamic_schema → log.append → store_document → lexical.upsert_document → vector.upsert_document), and acquires the writer mutex once per doc.
  • Why it's a bottleneck/risk: Per-doc Mutex-acquire is a real cost at high QPS. The dynamic-schema policy resnapshots the schema's RwLock<Schema> once per doc. WAL fsync also happens once per doc.
  • Reference precedent: Tantivy IndexWriter::add_document is the API but is intended to be called from N threads with a single shared writer; the commit is one fsync per batch. Lucene IndexWriter.addDocuments(Iterable) exists.
  • Suggested direction: Add LexicalStore::upsert_documents(&self, batch: Vec<(u64, Document)>) -> Result<()> and a HybridEngine::put_batch. Inside, snapshot schema once, hold writer mutex once, WAL-batch all records under group-commit.
  • Risk / scope: M. Pure addition; no on-disk format change.


ID: LI-14 — see ~/.claude/tasks/laurus/20260523_perf_round3_audit/task_list.md for the full Round-3 issue list.

Task list (2026-07-13 campaign start, jointly with #572)

Phase 0: Investigation

Phase 1: Plan

Phase 2: Implementation

Wrap-up

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions