Commit 120afa8
committed
fix: shorten checkpoint wait for blocked caller
The checkpoint collector waited on an empty queue after it had already
collected a synchronous checkpoint. A synchronous checkpoint has a
caller blocked until the batch is persisted, and a blocked caller cannot
enqueue more work. So that wait could not enlarge the batch. It only
delayed the caller by the shutdown-signal poll interval of 100 ms.
Sequential steps paid that cost once per step. Measured in us-east-1 on
python3.13 at 1024 MB over 1000 steps, warm, comparing this change
against d61985e:
median interval between StepSucceeded 142 ms -> 41 ms
p95 interval 163 ms -> 62 ms
invocation duration 144.4 s -> 43.1 s
steps per second 6.92 -> 23.22
The step body performs no I/O, so nearly all of the removed time was the
idle wait.
Changes
- Track whether a batch holds a synchronous checkpoint that carries an
operation update. Set the flag on all three insertion paths: the
overflow drain, the first blocking read, and the additional read.
- Once set, wait only _BLOCKED_CALLER_WAIT_SECONDS on an empty queue
instead of the full poll interval. Work already queued still joins the
batch, so an asynchronous step START still travels in the same request
as its synchronous SUCCEED. Sequential steps keep one checkpoint call
of two updates per step, unchanged.
- Wait 1 ms rather than not at all. Branch threads start one at a time,
so gaps in checkpoint arrivals occur while a parallel or map thread
pool starts. Not waiting cut extra small batches during that startup.
On Lambda, waiting 1 ms produced the same checkpoint call count as
d61985e at both 200 and 500 branches, and ran 1.21x to 1.28x faster.
- Leave empty synchronous checkpoints on the full window. The branch
resubmitter issues one per branch on resume, so a wide map resuming at
once produces hundreds simultaneously, and flushing early would split
them across requests. That is the coalescing added in #325 and guarded
by map_with_concurrent_waits_int_test. The exclusion costs one delay
per resume wave, not per branch.
- Leave asynchronous-only batching unchanged. With no blocked caller the
wait costs no latency and still reduces the API call count.
- Name the existing 0.1 second literal _STOP_SIGNAL_POLL_SECONDS. Both
waits in the collector are now named, so the min() compares two named
intervals rather than one named value and one literal.
- Correct the max_batch_time_seconds docstring. It bounds the total
collection window, not the idle wait, which the poll interval caps
regardless of the configured value.
Neither constant is reachable by an end user, so this changes no public
signature. CheckpointBatcherConfig is absent from the package exports,
no caller outside state.py passes batcher_config, and config.py has no
batcher settings.
Tests
Add six collector tests that assert the timeout values passed to the
queue read rather than elapsed time. The collector's waiting policy is
fully described by those timeouts, so the tests need no sleeps and no
wall-clock thresholds. Four of the six fail when the shortened wait is
removed; the other two pin the paths this change leaves alone.
Replace the wall-clock assertion in
test_create_checkpoint_multiple_sync_calls_all_block. Each caller
started its clock after the processor began its 150 ms sleep, so its
own elapsed time was always under 150 ms. The assertion held only
because the collector added 100 ms on top, which is the defect. It now
asserts the real invariant: no caller returns before its batch is
collected, and every caller stays blocked across the processor delay.
Fixes #7101 parent 8742ad9 commit 120afa8
2 files changed
Lines changed: 255 additions & 43 deletions
File tree
- packages/aws-durable-execution-sdk-python
- src/aws_durable_execution_sdk_python
- tests
Lines changed: 40 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
50 | 58 | | |
51 | 59 | | |
52 | 60 | | |
53 | 61 | | |
54 | 62 | | |
55 | 63 | | |
56 | 64 | | |
57 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
58 | 69 | | |
59 | 70 | | |
60 | 71 | | |
| |||
1025 | 1036 | | |
1026 | 1037 | | |
1027 | 1038 | | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
1028 | 1047 | | |
1029 | 1048 | | |
1030 | 1049 | | |
| |||
1037 | 1056 | | |
1038 | 1057 | | |
1039 | 1058 | | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
1040 | 1064 | | |
1041 | 1065 | | |
1042 | 1066 | | |
| |||
1060 | 1084 | | |
1061 | 1085 | | |
1062 | 1086 | | |
| 1087 | + | |
| 1088 | + | |
1063 | 1089 | | |
1064 | 1090 | | |
1065 | 1091 | | |
| |||
1071 | 1097 | | |
1072 | 1098 | | |
1073 | 1099 | | |
1074 | | - | |
1075 | | - | |
| 1100 | + | |
| 1101 | + | |
1076 | 1102 | | |
1077 | 1103 | | |
1078 | 1104 | | |
1079 | 1105 | | |
1080 | 1106 | | |
1081 | 1107 | | |
1082 | 1108 | | |
| 1109 | + | |
| 1110 | + | |
1083 | 1111 | | |
1084 | 1112 | | |
1085 | 1113 | | |
| |||
1101 | 1129 | | |
1102 | 1130 | | |
1103 | 1131 | | |
1104 | | - | |
| 1132 | + | |
1105 | 1133 | | |
1106 | 1134 | | |
1107 | 1135 | | |
1108 | 1136 | | |
1109 | 1137 | | |
1110 | 1138 | | |
1111 | | - | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
1112 | 1145 | | |
1113 | 1146 | | |
1114 | 1147 | | |
| |||
1130 | 1163 | | |
1131 | 1164 | | |
1132 | 1165 | | |
| 1166 | + | |
| 1167 | + | |
1133 | 1168 | | |
1134 | 1169 | | |
1135 | 1170 | | |
| |||
0 commit comments