Commit 37e2d2a
Add optional parallel chunk processing via ThreadPoolExecutor
Draft. Adds `max_workers` to `@multi_value_chunked`; when set > 1
sub-requests run concurrently in a ``ThreadPoolExecutor``. Default
(``None``) keeps the existing sequential behavior, including the
mid-call quota guard and ``QuotaExhausted.partial_frame``
resumability. Parallel mode forfeits both: workers can race past the
floor before any one observes the crossing, and any chunk failure
discards completed-but-uncollected results.
Benchmarked on 671 CAMELS sites x ``get_field_measurements``
(337,808 rows, ~14 paginated chunks):
- sync: 82.1s +/- 12.1s
- workers=2: 100.2s (unstable; one run truncated by 429)
- workers=4: 51.5s +/- 2.8s (~1.6x; one run lightly truncated)
- workers=8: crashed on 429 mid-flight
Open question for follow-up: under parallelism we observe partial
data being returned silently when one chunk hits a paginated 429 --
``_walk_pages`` returns the rows it already has rather than
surfacing the truncation. This pre-existed but parallelism makes
it easier to trigger. Investigate as part of any future merge.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 526a7e4 commit 37e2d2a
1 file changed
Lines changed: 32 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
339 | 340 | | |
340 | 341 | | |
341 | 342 | | |
| 343 | + | |
342 | 344 | | |
343 | 345 | | |
344 | 346 | | |
| |||
362 | 364 | | |
363 | 365 | | |
364 | 366 | | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
365 | 375 | | |
366 | 376 | | |
367 | 377 | | |
| |||
385 | 395 | | |
386 | 396 | | |
387 | 397 | | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
388 | 419 | | |
389 | 420 | | |
390 | | - | |
391 | | - | |
| 421 | + | |
392 | 422 | | |
393 | 423 | | |
394 | 424 | | |
| |||
0 commit comments