Commit 920c021
authored
Add adaptive embedding throughput shaping for Azure 429 limits (#1115)
## Why
The previous retry-only fix still failed under sustained S0 throttling:
large embedding requests kept exhausting retries at the same payload
size. We need throughput shaping so rebuilds can continue progressing
under rate limits instead of stalling at repeated 429 exhaustion.
## What changed
- Added adaptive batch downshifting in embedding rebuilds:
- starts at configured max batch size
- on 429/RateLimitReached, splits throttled batches and retries smaller
sub-batches
- reuses the smaller successful size for subsequent requests in the same
run
- fails clearly if batch size 1 still exhausts retries
- Added explicit request pacing controls:
- `AIOptions:EmbeddingRetry:MaxEmbeddingBatchSize` (default 2048)
- `AIOptions:EmbeddingRetry:MinInterRequestDelayMs` (default 250)
- embedding requests are serialized and paced between calls to reduce
sustained RPM pressure
- Hardened Retry-After parsing:
- supports `retry-after`, `retry-after-ms`, `x-ms-retry-after-ms`
- supports extracting `retry after N seconds` from exception message
text
- Added coarse progress logging during rebuilds (not per call):
- logs start configuration
- logs progress at 10% milestones when total count is known
- falls back to every 500 chunks when total count is unknown
- includes current adaptive batch size in progress messages
## Validation
- `dotnet build
EssentialCSharp.Chat.Shared/EssentialCSharp.Chat.Common.csproj -c
Release --nologo`
- `dotnet test
EssentialCSharp.Chat.Tests/EssentialCSharp.Chat.Tests.csproj -c Release
--no-restore -v q`
Both passed.1 parent 5b3721a commit 920c021
4 files changed
Lines changed: 332 additions & 26 deletions
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
104 | | - | |
| 103 | + | |
| 104 | + | |
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| |||
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
37 | 51 | | |
38 | 52 | | |
39 | 53 | | |
| |||
74 | 88 | | |
75 | 89 | | |
76 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
77 | 100 | | |
78 | 101 | | |
79 | 102 | | |
| |||
0 commit comments