Commit b5fe55d
committed
feat: limit in-flight operations in map/parallel
max_concurrency previously sized the thread pool only, so branches
that suspended (invoke, wait, callbacks) released their thread and
the next item started immediately. All items were initiated at once
regardless of the configured limit.
Rework the concurrency executor around a single coordinator loop:
- The calling thread owns all branch state and schedules work; worker
threads only run branches and report outcomes on a queue. No locks
remain in the module.
- max_concurrency now bounds in-flight branches. A suspended branch
keeps its slot until it reaches a terminal state, matching the JS
and Java SDKs. When every in-flight branch is suspended, the parent
suspends with the earliest resume timestamp, or indefinitely.
- Branches start in index order and operation ids derive from the
branch index, so scheduling stays deterministic across invocations.
- Timed suspends resume in-process via the event queue timeout,
replacing the TimerScheduler background thread.
- Consolidate completion logic (thresholds and reason inference) into
CompletionPolicy, replacing ExecutionCounters and the duplicated
logic in BatchResult.
- Omit never-started branches from BatchResult, matching the JS SDK.
- Stop scheduling when a branch is orphaned: an ancestor completed,
so all further checkpoints under it would be rejected.
- Record the completion decision in map/parallel summaries and obey
it on replay: summaries carry the started-branch index set (or its
complement, whichever is smaller) and replay reconstructs the exact
live result instead of re-deriving statuses from child checkpoints.
Summaries without the record fall back to checkpoint derivation.
This also reconstructs FLAT results on replay, which checkpoint
derivation could not discriminate.
- Validate config bounds at construction, matching the Java SDK:
max_concurrency and min_successful must be at least 1,
tolerated_failure_count non-negative, tolerated_failure_percentage
within 0-100. Previously max_concurrency=0 silently meant
unlimited and min_successful=0 silently meant all items.
Closes #2791 parent 272c1f4 commit b5fe55d
10 files changed
Lines changed: 2176 additions & 2712 deletions
File tree
- packages
- aws-durable-execution-sdk-python-examples/test/map
- aws-durable-execution-sdk-python
- src/aws_durable_execution_sdk_python
- concurrency
- operation
- tests
- operation
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
26 | 29 | | |
27 | | - | |
| 30 | + | |
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
| |||
Lines changed: 309 additions & 307 deletions
Large diffs are not rendered by default.
0 commit comments