Repository navigation
Revert "[Serve] Set RAY_SERVE_RUN_SYNC_IN_THREADPOOL=1 to run sync in… - #61369
Merged
abrarsheikh merged 1 commit intoFeb 26, 2026
Merged
abrarsheikh merged 1 commit into
abrarsheikh merged 1 commit into
Conversation
… threadpool by default (ray-project#61229)" This reverts commit 9e1fa2e. Signed-off-by: akyang-anyscale <[email protected]>
akyang-anyscale
force-pushed
the
alexyang/revert-sync-threadpool
branch
from
February 26, 2026 20:14
9911b5e to
000b282
Compare
Contributor
There was a problem hiding this comment.
Code Review
This pull request reverts the default behavior of running synchronous methods in a threadpool (RAY_SERVE_RUN_SYNC_IN_THREADPOOL=1) back to running them on the event loop (RAY_SERVE_RUN_SYNC_IN_THREADPOOL=0), citing performance regressions. The changes correctly update the default flag value, adjust documentation to reflect the new default and guide users on opting into the threadpool behavior, and modify tests to explicitly cover the non-default case. The revert appears to be complete and correct. I have one minor suggestion for a typo in the documentation.
| Both FastAPI and Serve dispatch `def` methods to threadpool. | ||
| Important differences: | ||
|
|
||
| - FastAPI always dispatches `def` endpoints to a threadpool. |
Contributor
abrarsheikh
approved these changes
Feb 26, 2026
This was referenced Sep 23, 2026
eicherseiji
added a commit
that referenced
this pull request
Sep 29, 2026
## Description Run synchronous deployment methods in a thread pool by default so blocking synchronous I/O does not block the replica event loop. `RAY_SERVE_RUN_SYNC_IN_THREADPOOL=0` retains the legacy behavior for deployments whose shared state is not thread-safe. | Environment variable | `master` | After this PR | | --- | --- | --- | | `RAY_SERVE_RUN_SYNC_IN_THREADPOOL` | OFF | ON | The opt-in warning has been emitted since [#48897](#48897) merged on November 26, 2024—667 days (about 22 months) before this default swap. This provided an extended migration period for users to make synchronous deployment code thread-safe or convert it to `async def`. The documentation now describes thread safety requirements and the opt-out. This default was previously enabled in [#61229](#61229) and reverted in [#61369](#61369). ## Related PRs These default changes are independent and can merge in any order: - [#66432 Enable HAProxy by default on Linux](#66432) - [#66434 Select request body forwarding by router](#66434) - [#66435 Apply Serve LLM replica performance defaults](#66435) ## Tests - `RAY_USE_UVLOOP=0 python -m pytest -q python/ray/serve/tests/test_replica_sync_methods.py`: 9 passed. The executor-introspection cases target the standard asyncio loop used by this Bazel test. - Updated the thread-pool test target description - Pre-commit, including Ruff, Black, Buildifier, mypy, Pyrefly, docs style, and import-order checks ## Duplicate search I searched open Ray PRs for this environment variable and found no active duplicate. ## AI assistance AI assistance was used for implementation and testing. The generated changes and test results require submitter review before the PR is marked ready. Signed-off-by: Seiji Eicher <[email protected]>
nadongjun
pushed a commit
to nadongjun/ray
that referenced
this pull request
Oct 6, 2026
## Description Run synchronous deployment methods in a thread pool by default so blocking synchronous I/O does not block the replica event loop. `RAY_SERVE_RUN_SYNC_IN_THREADPOOL=0` retains the legacy behavior for deployments whose shared state is not thread-safe. | Environment variable | `master` | After this PR | | --- | --- | --- | | `RAY_SERVE_RUN_SYNC_IN_THREADPOOL` | OFF | ON | The opt-in warning has been emitted since [ray-project#48897](ray-project#48897) merged on November 26, 2024—667 days (about 22 months) before this default swap. This provided an extended migration period for users to make synchronous deployment code thread-safe or convert it to `async def`. The documentation now describes thread safety requirements and the opt-out. This default was previously enabled in [ray-project#61229](ray-project#61229) and reverted in [ray-project#61369](ray-project#61369). ## Related PRs These default changes are independent and can merge in any order: - [ray-project#66432 Enable HAProxy by default on Linux](ray-project#66432) - [ray-project#66434 Select request body forwarding by router](ray-project#66434) - [ray-project#66435 Apply Serve LLM replica performance defaults](ray-project#66435) ## Tests - `RAY_USE_UVLOOP=0 python -m pytest -q python/ray/serve/tests/test_replica_sync_methods.py`: 9 passed. The executor-introspection cases target the standard asyncio loop used by this Bazel test. - Updated the thread-pool test target description - Pre-commit, including Ruff, Black, Buildifier, mypy, Pyrefly, docs style, and import-order checks ## Duplicate search I searched open Ray PRs for this environment variable and found no active duplicate. ## AI assistance AI assistance was used for implementation and testing. The generated changes and test results require submitter review before the PR is marked ready. Signed-off-by: Seiji Eicher <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… threadpool by default (#61229)"
This reverts commit 9e1fa2e. Enabling the flag by default introduces a significant perf regression for lightweight workloads that are sensitive to context switching and that do not take full advantage of offloading work from python. will post a RFC for community feedback before making this the default
Description
Related issues
Additional information