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
- Add batch queue configuration to database options
- Create
BatchQueue at core/gateways/indexeddb/batch-queue.ts
- Implement time-window batching:
- Collect writes within configurable window (e.g., 10ms)
- Execute as single transaction
- Implement read-your-writes consistency check
- Add batch statistics reporting
- 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)
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, eachput()call creates its own transaction. IndexedDB transactions have overhead, and frequent small transactions are inefficient for bulk writes.Proposed Solution
BatchQueueatcore/gateways/indexeddb/batch-queue.tsExpected Outcomes