Skip to content

[Performance] Implement IndexedDB transaction batching #1501

@bbopen

Description

@bbopen

Summary

Each write operation currently creates a separate IndexedDB transaction. Batching multiple writes into single transactions would significantly improve throughput.

Problem

In core/gateways/indexeddb/gateway-impl.ts, each put() call creates its own transaction. IndexedDB transactions have overhead, and frequent small transactions are inefficient for bulk writes.

Proposed Solution

  1. Add batch queue configuration to database options
  2. Create BatchQueue at core/gateways/indexeddb/batch-queue.ts
  3. Implement time-window batching:
    • Collect writes within configurable window (e.g., 10ms)
    • Execute as single transaction
  4. Implement read-your-writes consistency check
  5. Add batch statistics reporting
  6. Create throughput benchmarks

Expected Outcomes

  • Multiple writes within time window share one transaction
  • Batched writes maintain atomicity
  • Read-your-writes consistency maintained
  • 5x throughput improvement on bulk writes (benchmark verified)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions