You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reduce Execution API event-loop stalls for large JSON request bodies #77502
Large JSON request bodies can stall the Execution API event loop while FastAPI validates the request and Cadwyn migrates it. A task-state store PUT is the measured case. Other versioned endpoints that accept large JsonValue inputs may share this cost. Task-state conversion and benchmark
In the two PostgreSQL rounds for a 688,890-byte array, median loop stalls were 90 and 86 ms with the synchronous route and 133 and 121 ms with the async route. The measurements used Python 3.14.8 and SQLAlchemy 2.0.54 in Breeze. The loop-thread profile showed repeated Pydantic JsonValue validation and a Cadwyn model dump. Moving the handler’s json.dumps to a worker did not restore the baseline. The extra yields on the synchronous path are a possible explanation for the difference in stall duration. Performance follow-up from the review
To reproduce, send a PUT request with a value field containing an array of 100,000 integers to /execution/store/ti/{task_instance_id}/{key} for a valid task instance. Use the same dependencies, database and payload for both revisions. Check the response and stored value, then record the longest server-loop ticker interval for each warm request alongside request duration. Profile the request-body path and repeat on a second endpoint with a large JSON body to find out which routes share the bottleneck.
The goal is to reduce event-loop stalls while preserving request validation and versioned API behavior. The state-store model optimization is already proposed in #77113. This issue tracks the shared request-body cost and the scope beyond those models.
Drafted-by: Codex (GPT-6) (no human review before posting)
I reproduced the stall on the XCom routes and have a fix ready. It skips the redundant JsonValue validation and serialization walks for XCom request and response values, which are already decoded JSON. On a 688,890-byte value, POST falls from 123 ms to 82 ms and GET from 142 ms to 58 ms (median of 3 runs, 10 requests each), with the published OpenAPI schema unchanged. The state-store models in #77113 are untouched.
I will open a PR against main with the fix and the before/after numbers, unless you would rather I hold off.
Drafted-by: Muse Spark (no human review before posting)
Activity
PCTEJA commentedon Nov 24, 2026
I reproduced the stall on the XCom routes and have a fix ready. It skips the redundant JsonValue validation and serialization walks for XCom request and response values, which are already decoded JSON. On a 688,890-byte value, POST falls from 123 ms to 82 ms and GET from 142 ms to 58 ms (median of 3 runs, 10 requests each), with the published OpenAPI schema unchanged. The state-store models in #77113 are untouched.
I will open a PR against main with the fix and the before/after numbers, unless you would rather I hold off.
Drafted-by: Muse Spark (no human review before posting)