Summary
Add MapParallel — the recommended batch-processing primitive combining mapping (Map) with bounded concurrency (MaxConcurrency) and chunking (partition batches) to cut per-item Task/AsyncLocal/GC overhead.
Goal
Provide the recommended method for batch processing (e.g. batch import), with partition-based context management and concurrency caps.
Problem
Mapping each of 1000 items into its own Task + BeginContext is GC-heavy for small in-memory jobs. There is no single call that bounds concurrency and batches work into a few context scopes.
Scope
Design Expectations
- Composes
Map + MaxConcurrency into a single, recommended primitive.
- Chunking reduces GC/allocations for small jobs.
- Result order defaulting to ordered; opt-out reserved for the Ordered issue.
- Async-only.
Acceptance Criteria
Non-Goals
- No retry / partial-failure aggregation (Polly, TryEach).
- No graph orchestration (DAG).
- No streaming (IAsyncEnumerable).
Summary
Add
MapParallel— the recommended batch-processing primitive combining mapping (Map) with bounded concurrency (MaxConcurrency) and chunking (partition batches) to cut per-itemTask/AsyncLocal/GC overhead.Goal
Provide the recommended method for batch processing (e.g. batch import), with partition-based context management and concurrency caps.
Problem
Mapping each of 1000 items into its own
Task+BeginContextis GC-heavy for small in-memory jobs. There is no single call that bounds concurrency and batches work into a few context scopes.Scope
MapParallel(ctx, source, parallelOptions, workItem)whereparallelOptionshasMaxConcurrencyandChunkSize.sourceof N items split into M partitions (ChunkSize); oneBeginContextper partition → only M tasks.SemaphoreSlimlimits across chunks (static MaxConcurrency semaphores).MaxConcurrency = 4.Design Expectations
Map+MaxConcurrencyinto a single, recommended primitive.Acceptance Criteria
Non-Goals