Merge pull request #13418 from jtattermusch/csharp_honor_optimizationtarget

C# benchmark improvements
pull/13439/head
Jan Tattermusch 7 years ago committed by GitHub
commit d9186a7e9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs
  2. 15
      src/csharp/Grpc.IntegrationTesting/ClientRunners.cs
  3. 43
      src/csharp/Grpc.IntegrationTesting/ControlExtensions.cs
  4. 3
      src/csharp/Grpc.IntegrationTesting/ServerRunners.cs

@ -176,10 +176,10 @@ namespace Grpc.Core.Internal
try try
{ {
var callback = cq.CompletionRegistry.Extract(tag); var callback = cq.CompletionRegistry.Extract(tag);
// Use cached delegates to avoid unnecessary allocations queuedContinuationCounter.Increment();
if (!inlineHandlers) if (!inlineHandlers)
{ {
queuedContinuationCounter.Increment(); // Use cached delegates to avoid unnecessary allocations
ThreadPool.QueueUserWorkItem(success ? runCompletionQueueEventCallbackSuccess : runCompletionQueueEventCallbackFailure, callback); ThreadPool.QueueUserWorkItem(success ? runCompletionQueueEventCallbackSuccess : runCompletionQueueEventCallbackFailure, callback);
} }
else else

@ -72,7 +72,7 @@ namespace Grpc.IntegrationTesting
Logger.Warning("ClientConfig.CoreList is not supported for C#. Ignoring the value"); Logger.Warning("ClientConfig.CoreList is not supported for C#. Ignoring the value");
} }
var channels = CreateChannels(config.ClientChannels, config.ServerTargets, config.SecurityParams); var channels = CreateChannels(config.ClientChannels, config.ServerTargets, config.SecurityParams, config.ChannelArgs);
return new ClientRunnerImpl(channels, return new ClientRunnerImpl(channels,
config.ClientType, config.ClientType,
@ -84,19 +84,20 @@ namespace Grpc.IntegrationTesting
() => GetNextProfiler()); () => GetNextProfiler());
} }
private static List<Channel> CreateChannels(int clientChannels, IEnumerable<string> serverTargets, SecurityParams securityParams) private static List<Channel> CreateChannels(int clientChannels, IEnumerable<string> serverTargets, SecurityParams securityParams, IEnumerable<ChannelArg> channelArguments)
{ {
GrpcPreconditions.CheckArgument(clientChannels > 0, "clientChannels needs to be at least 1."); GrpcPreconditions.CheckArgument(clientChannels > 0, "clientChannels needs to be at least 1.");
GrpcPreconditions.CheckArgument(serverTargets.Count() > 0, "at least one serverTarget needs to be specified."); GrpcPreconditions.CheckArgument(serverTargets.Count() > 0, "at least one serverTarget needs to be specified.");
var credentials = securityParams != null ? TestCredentials.CreateSslCredentials() : ChannelCredentials.Insecure; var credentials = securityParams != null ? TestCredentials.CreateSslCredentials() : ChannelCredentials.Insecure;
List<ChannelOption> channelOptions = null; var channelOptions = new List<ChannelOption>();
if (securityParams != null && securityParams.ServerHostOverride != "") if (securityParams != null && securityParams.ServerHostOverride != "")
{ {
channelOptions = new List<ChannelOption> channelOptions.Add(new ChannelOption(ChannelOptions.SslTargetNameOverride, securityParams.ServerHostOverride));
{ }
new ChannelOption(ChannelOptions.SslTargetNameOverride, securityParams.ServerHostOverride) foreach (var channelArgument in channelArguments)
}; {
channelOptions.Add(channelArgument.ToChannelOption());
} }
var result = new List<Channel>(); var result = new List<Channel>();

@ -0,0 +1,43 @@
#region Copyright notice and license
// Copyright 2016 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#endregion
using System;
using Grpc.Core;
using Grpc.Testing;
namespace Grpc.IntegrationTesting
{
/// <summary>
/// Helpers for Control.cs
/// </summary>
public static class ControlExtensions
{
public static ChannelOption ToChannelOption(this ChannelArg channelArgument)
{
switch (channelArgument.ValueCase)
{
case ChannelArg.ValueOneofCase.StrValue:
return new ChannelOption(channelArgument.Name, channelArgument.StrValue);
case ChannelArg.ValueOneofCase.IntValue:
return new ChannelOption(channelArgument.Name, channelArgument.IntValue);
default:
throw new ArgumentException("Unsupported channel argument value.");
}
}
}
}

@ -78,7 +78,8 @@ namespace Grpc.IntegrationTesting
throw new ArgumentException("Unsupported ServerType"); throw new ArgumentException("Unsupported ServerType");
} }
var server = new Server var channelOptions = new List<ChannelOption>(config.ChannelArgs.Select((arg) => arg.ToChannelOption()));
var server = new Server(channelOptions)
{ {
Services = { service }, Services = { service },
Ports = { new ServerPort("[::]", config.Port, credentials) } Ports = { new ServerPort("[::]", config.Port, credentials) }

Loading…
Cancel
Save