Skip to content

L30-Ability-to-restrict-max-threads-in-C++SyncServer.md#84

Merged
sreecha merged 6 commits into
masterfrom
sreecha-patch-2
Jul 24, 2018
Merged

L30-Ability-to-restrict-max-threads-in-C++SyncServer.md#84
sreecha merged 6 commits into
masterfrom
sreecha-patch-2

Conversation

@sreecha
Copy link
Copy Markdown
Contributor

@sreecha sreecha commented Jun 7, 2018

No description provided.

@sreecha sreecha requested a review from vjpai June 7, 2018 03:24
```
* Max threads are set to INT_MAX by default
* In the initial implementation, I plan to divide the max_threads equally among multiple `ThreadManager` objects (there are as many `ThreadManager` objects as the number of server completion queues). It is not clear on which strategy is better at this point
- (1) Have all thread managers create threads from a common pool (but potentially starving some thread managers and also making the quota-check a potential global contention point)
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.

Is thread creation a common enough occurrence that there's worry about contention?

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.

It could be if there are multiple server completion queues (and even though right now a Sync server creates just one server completion queue, in future we probably want to increase it to be equal to the number of cores).

FWIW, since we only have one server completion queue currently, both the strategies above will effectively be the same..

/// new_max_threads. There is no time bound on when this may happen i.e none
/// of the current threads are forcefully destroyed and all threads run their
/// normal course.
ResourceQuota& SetMaxThreads(int new_max_threads);
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.

Is 0 a valid value for max threads? Is that how I say "I will never use this server synchronously. Do not create any threads. I'll be polling completion queues myself"?

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.

0 is a valid value but that will effectively make the server not respond to any incoming requests. So it is not a good idea to initialize max_threads to 0. However, if for whatever reason, the application suddenly decides to stop accepting incoming requests for sometime, it can set the max_threads to 0.

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.

btw, as I am thinking more about this, it might be easier to just implement option (1) at this point. This way, when applications resize the max_threads by calling ResourceQuota::SetMaxThreads, it is easier to make those changes visible to all thread managers..

Copy link
Copy Markdown
Contributor Author

@sreecha sreecha Jun 7, 2018

Choose a reason for hiding this comment

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

..and oh to answer your other question

" Is that how I say "I will never use this server synchronously. Do not create any threads. I'll be polling completion queues myself"?"

No, actually the server completion queues used by the sync server are not exposed to the application. So there is no question of the application trying to poll the queues itself.

If application wants to poll itself, it has to create its own completion queues an poll them ..

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.

Can you start the grpc discussion thread for this proposal? We should move extended comments there.

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.

* Status: In Review
* Implemented in: C++
* Last updated: June 6, 2018
* Discussion at:
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.

Can you please start a discussion thread on grpc-io about this and add the URL? Most of the technical questions should actually belong there.

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.

Done.

Each of the `ThreadManager` objects in a given server check with the Server's resource quota object when creating new threads and will not create new threads if no quota is available.

## Details
More concretely, the following API changes are being proposed
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.

Can you take the code details out of the document and put them in a PR linked from the document instead? I like to add that in the "Implemented In" line in the header

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.

o you mean the private API details ? - the other code snippets are public API changes and I thought should be in this document..

There is no PR for this yet (I mean, I have an in-progress change in my local branch but I did not implement the bulk of the changes yet. I want to get some agreement on the API before proceeding.

…-Ability-to-restrict-max-threads-in-C++SyncServer.md
@sreecha sreecha changed the title Create L26-Ability-to-restrict-max-threads-in-C++SyncServer.md L30-Ability-to-restrict-max-threads-in-C++SyncServer.md Jun 7, 2018
@vjpai
Copy link
Copy Markdown
Contributor

vjpai commented Jun 8, 2018

I'm approving based on the current content, but the discussion thread will remain open.

The earliest possible merge date for this proposal is June 20.

@vjpai
Copy link
Copy Markdown
Contributor

vjpai commented Jul 16, 2018

Sending another approval to confirm that I still approve.

@sreecha sreecha merged commit 9f45477 into master Jul 24, 2018
@sreecha sreecha deleted the sreecha-patch-2 branch July 24, 2018 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants