Skip to content

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

Open
khustup2 wants to merge 2 commits intomainfrom
sasun-improve
Open

feat: retry, concurrency control, and parallel DB optimizations#29
khustup2 wants to merge 2 commits intomainfrom
sasun-improve

Conversation

@khustup2
Copy link
Copy Markdown

Summary

  • Add retry with exponential backoff + concurrency semaphore to DeeplakeApi.query() — the single highest-impact change
  • 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 → 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, beta API)

Experiment Sessions Baseline Queries/Errors Optimized Queries/Errors QPS
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% 1,917 / 0.2% 2.8
u20×s10 200 15 (dead) / 40% 3,844 / 0.1% 2.9
u50×s5 250 8 (dead) / 12.5% 4,666 / 0.2% 2.1
u50×s10 500 100% failure 8,738 / 0.1% 2.8
  • Baseline crashed at 50+ concurrent sessions
  • Optimized handles 500 sessions at 0.1% error rate
  • QPS ~2x where both ran successfully

Test plan

  • All 152 unit tests pass
  • Build succeeds (tsc + esbuild)
  • Benchmark harness validates real plugin code paths (DeeplakeApi, DeeplakeFs)
  • Manual test with live Claude Code session

🤖 Generated with Claude Code

…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
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.

1 participant