Skip to content

Use GIL to guard decref of jit::toPyObj return value in processRpc#38376

Closed
mrshenli wants to merge 7 commits intogh/mrshenli/175/basefrom
gh/mrshenli/175/head
Closed

Use GIL to guard decref of jit::toPyObj return value in processRpc#38376
mrshenli wants to merge 7 commits intogh/mrshenli/175/basefrom
gh/mrshenli/175/head

Conversation

@mrshenli
Copy link
Copy Markdown
Contributor

@mrshenli mrshenli commented May 13, 2020

Stack from ghstack:

Differential Revision: D21540179

mrshenli pushed a commit that referenced this pull request May 13, 2020
@xush6528
Copy link
Copy Markdown
Contributor

xush6528 commented May 13, 2020

This PR is for MessageType::PYTHON_RREF_FETCH_CALL.

There are more sites, right?
MessageType::PYTHON_CALL, and MessageType::PYTHON_REMOTE_CALL.

UPDATE:
Checked those 2 sites. They both have a scoped gil acquire enclosing the returned temp py::object.
But they don't have a comment line mentioning this subtlety.

All known sites are resolved?

namespace {

py::object toPyObj(IValue value) {
SerializedPyObj toSerializedPyObj(IValue value) {
Copy link
Copy Markdown
Contributor

@xush6528 xush6528 May 13, 2020

Choose a reason for hiding this comment

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

It's only used by MessageType::PYTHON_RREF_FETCH_CALL.

Can we move under case MessageType::PYTHON_RREF_FETCH_CALL and make it a named lambda, like the auto markComplete = [...](...){...}; lambda on line 116.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, edited, but the downside is that we will need to capture this lambda in two nested callbacks. I am not sure if the extra overhead worth it here.

Copy link
Copy Markdown
Contributor

@xush6528 xush6528 May 13, 2020

Choose a reason for hiding this comment

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

@mrshenli

Should be fine.

If there is no capture by value, the closure type is typically trivially copyable and trivially moveable.
http://www.cplusplus.com/forum/general/202662/

@dr-ci
Copy link
Copy Markdown

dr-ci Bot commented May 13, 2020

💊 CI failures summary and remediations

As of commit fbb7f05 (more details on the Dr. CI page):


  • 1/1 failures possibly* introduced in this PR
    • 1/1 non-CircleCI failure(s)

ci.pytorch.org: 1 failed


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker.

See how this bot performed.

This comment has been revised 14 times.

mrshenli pushed a commit that referenced this pull request May 13, 2020
Comment thread torch/csrc/distributed/rpc/request_callback_impl.cpp Outdated
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@mrshenli merged this pull request in afa4dbd.

@facebook-github-bot facebook-github-bot deleted the gh/mrshenli/175/head branch May 17, 2020 14:18
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
…ytorch#38376)

Summary: Pull Request resolved: pytorch#38376

Test Plan: Imported from OSS

Differential Revision: D21540179

Pulled By: mrshenli

fbshipit-source-id: 082fa5f11da7fc1f083710b498e72abc5ba2c244
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants