Skip to content

[WIP][serve] Use ObjectRefGenerator._get_next_ref_n to avoid blocking on _to_object_ref - #64451

Closed
edoakes wants to merge 26 commits into
ray-project:masterfrom
edoakes:eoakes/serve-gen-peek
Closed

edoakes wants to merge 26 commits into
ray-project:masterfrom
edoakes:eoakes/serve-gen-peek

Conversation

@edoakes

@edoakes edoakes commented Jun 30, 2026 •

Copy link
Copy Markdown
Collaborator

Integrates with #62741 to fix the long-standing issue in serve where _to_object_ref blocks until the underlying result has been produced.

edoakes added 2 commits June 30, 2026 13:51
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
@edoakes edoakes added the go add ONLY when ready to merge, run all tests label Jun 30, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors ReplicaResult to eagerly fetch and register completion callbacks on the underlying ObjectRefs from the ObjectRefGenerator instead of lazily resolving them under a lock. However, the reviewer identified critical issues: _get_next_ref_n(1) returns a list rather than a single ObjectRef, which will cause an AttributeError when calling _on_completed, and there is a typo referencing self._object_ref_gen instead of self._obj_ref_gen.

edoakes and others added 24 commits June 30, 2026 13:56
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Rueian Huang <[email protected]>
Signed-off-by: Rueian Huang <[email protected]>
Signed-off-by: Rueian Huang <[email protected]>
Signed-off-by: Rueian Huang <[email protected]>
Signed-off-by: Rueian Huang <[email protected]>
Signed-off-by: Rueian Huang <[email protected]>
Signed-off-by: Rueian Huang <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

You can always ask for help on our discussion forum or Ray's public slack channel.

If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Jul 29, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no more activity in the 14 days
since being marked stale.

Please feel free to reopen or open a new pull request if you'd still like this to be addressed.

Again, you can always ask for help on our discussion forum or Ray's public slack channel.

Thanks again for your contribution!

@github-actions github-actions Bot closed this Aug 13, 2026
rueian added a commit that referenced this pull request Sep 26, 2026
…65243)

Continue the #64451 to fix the
long-standing issue in serve where `_to_object_ref` blocks until the
underlying result has been produced.
(#46893)

## Summary

`_to_object_ref` used to block until the replica produced the user
value. After this PR it returns the user `ObjectRef` as soon as the
request is assigned, without fetching the value.

On the default unary path (`handle_request_with_rejection`),
`get_rejection_response()` peeks that ref with `_get_next_ref_n(1)`
after the replica accepts. That is what makes `_to_object_ref`
non-blocking on the user value.

`ObjectRef._ready()` is a new separate presence wait
(`CoreWorker::WaitAsync` on the local memory store, no plasma pull).
Serve uses it so composition args are not enqueued until the upstream
object exists.

---------

Signed-off-by: Rueian Huang <[email protected]>
Co-authored-by: Edward Oakes <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…ay-project#65243)

Continue the ray-project#64451 to fix the
long-standing issue in serve where `_to_object_ref` blocks until the
underlying result has been produced.
(ray-project#46893)

## Summary

`_to_object_ref` used to block until the replica produced the user
value. After this PR it returns the user `ObjectRef` as soon as the
request is assigned, without fetching the value.

On the default unary path (`handle_request_with_rejection`),
`get_rejection_response()` peeks that ref with `_get_next_ref_n(1)`
after the replica accepts. That is what makes `_to_object_ref`
non-blocking on the user value.

`ObjectRef._ready()` is a new separate presence wait
(`CoreWorker::WaitAsync` on the local memory store, no plasma pull).
Serve uses it so composition args are not enqueued until the upstream
object exists.

---------

Signed-off-by: Rueian Huang <[email protected]>
Co-authored-by: Edward Oakes <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go add ONLY when ready to merge, run all tests stale The issue is stale. It will be closed within 7 days unless there are further conversation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants