Repository navigation
feat: add BatchWorkpool for high-throughput task processing - #167
Open
sethconvex wants to merge 34 commits into
Open
sethconvex wants to merge 34 commits into
sethconvex wants to merge 34 commits into
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
BatchWorkpool, a new execution mode where a small number of long-lived executor actions each run many task handlers concurrently. This eliminates the 1-action-per-task overhead of standard mode and enables much higher effective concurrency.Key design decisions
complete,fail, andreleasemutations verify the calling executor still owns the task, preventing duplicate completions from stale executors.What's included
src/client/batch.ts—BatchWorkpoolclass withaction(),executor(),enqueue(),enqueueBatch(),enqueueByHandle()src/component/batch.ts— Component-side mutations: enqueue, claim, complete, fail, release, executor lifecyclesrc/component/schema.ts—batchTaskstable with slot-partitioned indexes,batchConfigsingletonsrc/client/batch.test.ts— 100+ client-side unit tests (executor loop, retry, backoff, memory pressure)src/component/batch.test.ts— 100+ component-side unit tests (claim ownership, slot isolation, edge cases)example/— Full comparison app with standard vs batch modes, stress test handlersREADME.md— BatchWorkpool documentation and usage guideBATCH_DESIGN_ANALYSIS.md— Detailed architecture rationaleBenchmarks: Standard vs Batch mode
Head-to-head comparison on the same Convex dev deployment. Each task runs a 2-second simulated handler (
slowWork).Standard mode processes ~100 tasks every ~2s (limited by maxParallelism and per-action scheduling overhead). Batch mode runs all tasks concurrently across 5 long-lived executors, completing 1K tasks in a single 2s cycle and 10K tasks in ~4 cycles.
Additional stress tests (batch mode only)
Zero OCC errors across all test configurations, validating the slot-based executor partitioning design.
Test plan
npm test)npm run build)🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Documentation
Latest branch benchmark (2026-02-14)
Additional apples-to-apples operational comparison on this branch:
example:enqueueABunchOfActions× 67 (~2010 actions)test:runBatch(count=2000, mock translation enabled)Derived from this run:
Artifact:
benchmark_results/standard_vs_batch_comparison_2026-02-14.txt