Skip to content

feat: retry, concurrency control, and parallel DB optimizations#29

Merged
efenocchi merged 5 commits intomainfrom
sasun-improve
Apr 10, 2026
Merged

feat: retry, concurrency control, and parallel DB optimizations#29
efenocchi merged 5 commits intomainfrom
sasun-improve

Conversation

@khustup2
Copy link
Copy Markdown
Contributor

@khustup2 khustup2 commented Apr 10, 2026

Summary

  • Add retry with exponential backoff + concurrency semaphore to DeeplakeApi.query()
  • Retry covers both HTTP error codes (429/500/502/503/504) and network-level failures
  • Parallelize flush and bootstrap in DeeplakeFs
  • Fix appendFile cache invalidation bug (stale reads after append)
  • Single-query grep in pre-tool-use hook (6 round-trips to 1)
  • Re-queue failed writes on flush with throw for durability guarantees
  • Skip session bootstrap when sync fails to prevent stale data

Benchmark results

Real plugin code (DeeplakeApi + DeeplakeFs), beta API, 5-10 QA rounds per session.

Experiment Sessions Baseline Optimized
Queries Errors Queries Errors QPS
u5 s1 5 115 7.0% 119 3.4% 6.2
u5 s10 50 801 1.7% 973 0.4% 4.3
u10 s3 30 300 8.7% 564 0.7% 5.0
u10 s5 50 CRASHED - 945 0.4% 4.2
u10 s10 100 15 dead 40% 1917 0.2% 2.8
u20 s10 200 15 dead 40% 3844 0.1% 2.9
u50 s5 250 8 dead 12.5% 4666 0.2% 2.1
u50 s10 500 100% fail - 8738 0.1% 2.8
u100 s1 100 9 dead 33% 1894 0.2% 3.6
u100 s3 300 CRASHED - 5236 0.1% 4.4
u100 s5 500 100% fail - 9457 0.0% 2.1
u100 s10 1000 100% fail - 17599 0.0% 1.7
  • Baseline crashed at 50+ concurrent sessions
  • Optimized handles 1000 concurrent sessions at 0.03% error rate
  • QPS ~2x where both ran successfully
  • Total: 69534 queries executed across all optimized experiments

Test plan

  • All 163 unit tests pass
  • Build succeeds (tsc + esbuild)
  • Full 20-experiment benchmark matrix
  • Manual test with live Claude Code session

…B layer

- Add retry with exponential backoff (429/500/502/503/504 + network errors)
  to DeeplakeApi.query() — recovers transient failures that previously crashed
  sessions entirely
- Add concurrency semaphore (max 5 in-flight requests) to prevent rate-limit
  cascading under load
- Add retry to listTables() for resilient table setup
- Parallelize flush in DeeplakeFs — upserts run via Promise.allSettled with
  failed writes re-queued for retry, throws on partial failure for durability
- Parallelize bootstrap — sync + memory + sessions metadata load concurrently
- Fix appendFile cache invalidation — content cache was stale after SQL append
- Single-query grep in pre-tool-use hook — 6 HTTP round-trips reduced to 1
- Skip session bootstrap when sync fails to prevent stale data population

Benchmark results (real plugin code against beta API):
- Baseline crashed at 50+ concurrent sessions (0 retry, no backpressure)
- Optimized handles 500 sessions at 0.1% error rate
- QPS ~2x where both ran (parallel flush vs sequential)
- Error rate dropped from 8-40% to 0.1-0.4% across all experiments
@efenocchi efenocchi merged commit d745788 into main Apr 10, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants