aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@google.com>2016-10-21 01:42:10 +0200
committerGravatar Jan Tattermusch <jtattermusch@google.com>2016-10-21 01:42:10 +0200
commitfac33ad5b7e302123eb6f8e552c9cf8c2245eec4 (patch)
tree96d5c107f8831c7e1520e8b2412fe80bc2623511
parent6e90171f370281edd6ab87561dd26673d73f6ace (diff)
expose knob for adjusting number of requested calls
-rw-r--r--src/csharp/Grpc.Core/Server.cs29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/csharp/Grpc.Core/Server.cs b/src/csharp/Grpc.Core/Server.cs
index 82ecc8ecd5..961b911fbb 100644
--- a/src/csharp/Grpc.Core/Server.cs
+++ b/src/csharp/Grpc.Core/Server.cs
@@ -47,7 +47,7 @@ namespace Grpc.Core
/// </summary>
public class Server
{
- const int InitialAllowRpcTokenCountPerCq = 1000;
+ const int DefaultRequestCallTokensPerCq = 2000;
static readonly ILogger Logger = GrpcEnvironment.Logger.ForType<Server>();
readonly AtomicCounter activeCallCounter = new AtomicCounter();
@@ -66,7 +66,7 @@ namespace Grpc.Core
bool startRequested;
volatile bool shutdownRequested;
-
+ int requestCallTokensPerCq = DefaultRequestCallTokensPerCq;
/// <summary>
/// Creates a new server.
@@ -133,6 +133,27 @@ namespace Grpc.Core
}
/// <summary>
+ /// Experimental API. Might anytime change without prior notice.
+ /// Number or calls requested via grpc_server_request_call at any given time for each completion queue.
+ /// </summary>
+ public int RequestCallTokensPerCompletionQueue
+ {
+ get
+ {
+ return requestCallTokensPerCq;
+ }
+ set
+ {
+ lock (myLock)
+ {
+ GrpcPreconditions.CheckState(!startRequested);
+ GrpcPreconditions.CheckArgument(value > 0);
+ requestCallTokensPerCq = value;
+ }
+ }
+ }
+
+ /// <summary>
/// Starts the server.
/// </summary>
public void Start()
@@ -145,9 +166,7 @@ namespace Grpc.Core
handle.Start();
- // Starting with more than one AllowOneRpc tokens can significantly increase
- // unary RPC throughput.
- for (int i = 0; i < InitialAllowRpcTokenCountPerCq; i++)
+ for (int i = 0; i < requestCallTokensPerCq; i++)
{
foreach (var cq in environment.CompletionQueues)
{