Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

inprocess: Avoid creating unnecessary threads #2108

Merged
merged 1 commit into from
Aug 2, 2016

Conversation

ejona86
Copy link
Member

@ejona86 ejona86 commented Aug 1, 2016

Implementations of ManagedClientTransport.start() are restricted from
calling the passed listener until start() returns, in order to avoid
reentrency problems with locks. For most transports this isn't a
problem, because they need additional threads anyway. InProcess uses no
additional threads naturally so ends up needing a thread just to
notifyReady. Now transports can just return a Runnable that can be run
after locks are dropped.

This was originally intended to be a performance optimization, but the
thread also causes nondeterminism because RPCs are delayed until
notifyReady is called. So avoiding the thread reduces needless fakes
during tests.

I used ErrorProne to verify all calls to start() now handle the Runnable.

@zhangkun83
Copy link
Contributor

LGTM

Implementations of ManagedClientTransport.start() are restricted from
calling the passed listener until start() returns, in order to avoid
reentrency problems with locks. For most transports this isn't a
problem, because they need additional threads anyway. InProcess uses no
additional threads naturally so ends up needing a thread just to
notifyReady. Now transports can just return a Runnable that can be run
after locks are dropped.

This was originally intended to be a performance optimization, but the
thread also causes nondeterminism because RPCs are delayed until
notifyReady is called. So avoiding the thread reduces needless fakes
during tests.
@ejona86 ejona86 force-pushed the threadless-inprocess branch from 8eaf58e to 7d464fc Compare August 2, 2016 20:16
@ejona86 ejona86 merged commit 7d464fc into grpc:master Aug 2, 2016
@ejona86 ejona86 deleted the threadless-inprocess branch August 2, 2016 20:19
@ejona86
Copy link
Member Author

ejona86 commented Aug 2, 2016

@zhangkun83, do you think this should be backported to v1.0.x? I think we should, but I'm on the fence between doing it for v1.0.0 and v1.0.1.

@zhangkun83
Copy link
Contributor

Maybe 1.0.1? It may be a good idea to freeze the code for 1.0.0 at this moment, supposing 1.0.1 will happen soon after.

@ejona86
Copy link
Member Author

ejona86 commented Aug 2, 2016

SGTM. Will backport after v1.0.0 is out.

@ejona86 ejona86 added the TODO:backport PR needs to be backported. Removed after backport complete label Aug 4, 2016
@zhangkun83 zhangkun83 removed the TODO:backport PR needs to be backported. Removed after backport complete label Sep 14, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jan 21, 2019
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants