Skip to content

Skyrisemini #1692

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions benchmarks/AutoClusterBenchmark/AutoClusterBenchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
<RootNamespace>ClusterExperiment1</RootNamespace>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<ServerGarbageCollection>true</ServerGarbageCollection>
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Proto.Cluster.Consul\Proto.Cluster.Consul.csproj" />
Expand Down
1 change: 1 addition & 0 deletions benchmarks/RemoteBenchmark/Node1/Node1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<LangVersion>10</LangVersion>
<TargetFrameworks>net5.0;net6.0;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Proto.Actor\Proto.Actor.csproj" />
<ProjectReference Include="..\..\..\src\Proto.Remote\Proto.Remote.csproj" />
Expand Down
16 changes: 10 additions & 6 deletions benchmarks/SkyriseMini/Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Proto;
using Serilog;
using SkyriseMini;
using SkyriseMini.Tests;
using Log = Serilog.Log;

var builder = WebApplication.CreateBuilder(args);


try
{
builder.Host.UseSerilog((_, lcfg) =>
lcfg
.ReadFrom.Configuration(builder.Configuration)
.WriteTo.Console()
.WriteTo.Seq(builder.Configuration["SeqUrl"])
.Enrich.WithProperty("Service", Assembly.GetExecutingAssembly().GetName().Name)
);
.Enrich.WithProperty("Service", Assembly.GetExecutingAssembly().GetName().Name));


Console.WriteLine("Starting client");
builder.Services.AddSingleton<TestManager>();
Expand All @@ -38,10 +38,14 @@

app.MapPost("/runMessagingTest",
(HttpContext _, IServiceProvider provider, TestManager manager, [FromQuery] int parallelism, [FromQuery] int durationInSeconds)
=> {
var test = provider.GetRequiredService<MessagingTest>();
manager.TrackTest(cancel => test.RunTest(parallelism, durationInSeconds, cancel));
=> {

var __ = SafeTask.Run( () => {
var test = provider.GetRequiredService<MessagingTest>();
manager.TrackTest(cancel => test.RunTest(parallelism, durationInSeconds, cancel));
return Task.CompletedTask;
}
).ConfigureAwait(false);
return Task.CompletedTask;
}
);
Expand Down
5 changes: 4 additions & 1 deletion benchmarks/SkyriseMini/Client/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5051",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_TieredPGO":"1",
"DOTNET_TC_QuickJitForLoops":"1",
"DOTNET_ReadyToRun":"0"
}
}
}
Expand Down
19 changes: 9 additions & 10 deletions benchmarks/SkyriseMini/Client/ProtoActorExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.IO.Compression;
using System.IO.Compression;
using Grpc.Net.Client;
using Grpc.Net.Compression;
using Microsoft.AspNetCore.Builder;
Expand All @@ -8,7 +8,6 @@
using Proto.Cluster;
using Proto.Cluster.Consul;
using Proto.Cluster.Partition;
using Proto.Cluster.PartitionActivator;
using Proto.DependencyInjection;
using Proto.Remote;
using Proto.Remote.GrpcNet;
Expand Down Expand Up @@ -47,14 +46,14 @@ public static WebApplicationBuilder AddProtoActorClient(this WebApplicationBuild

var remoteConfig = GrpcNetRemoteConfig.BindToLocalhost()
.WithProtoMessages(ProtoActorSut.Contracts.ProtosReflection.Descriptor)
// .WithChannelOptions(new GrpcChannelOptions
// {
// CompressionProviders = new[]
// {
// new GzipCompressionProvider(CompressionLevel.Fastest)
// }
// }
// )
.WithChannelOptions(new GrpcChannelOptions
{
CompressionProviders = new[]
{
new GzipCompressionProvider(CompressionLevel.Fastest)
}
}
)
.WithLogLevelForDeserializationErrors(LogLevel.Critical);

var clusterProvider = new ConsulProvider(new ConsulProviderConfig());
Expand Down
15 changes: 14 additions & 1 deletion benchmarks/SkyriseMini/Client/SkyriseMiniClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup>
<ServerGarbageCollection>true</ServerGarbageCollection>
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Proto.Cluster.Consul\Proto.Cluster.Consul.csproj" />
<ProjectReference Include="..\..\..\src\Proto.Cluster\Proto.Cluster.csproj" />
Expand All @@ -32,7 +37,15 @@
</ItemGroup>

<ItemGroup>
<Folder Include="Monitoring" />

<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

<Content Include="appsettings.Development.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

</ItemGroup>

</Project>
19 changes: 15 additions & 4 deletions benchmarks/SkyriseMini/Client/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
{
"Logging": {
"LogLevel": {
"ProtoActor": {
"ClusterName": "dev"
},

"SeqUrl": "http://localhost:5341",

"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
"Override": {
"Microsoft.AspNetCore": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
},

"AllowedHosts": "*"
}
5 changes: 4 additions & 1 deletion benchmarks/SkyriseMini/Server/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
"launchBrowser": false,
"applicationUrl": "http://localhost:5800",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_TieredPGO":"1",
"DOTNET_TC_QuickJitForLoops":"1",
"DOTNET_ReadyToRun":"0"
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions benchmarks/SkyriseMini/Server/ProtoActorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ public static WebApplicationBuilder AddProtoActorSUT(this WebApplicationBuilder

var remoteConfig = GrpcNetRemoteConfig.BindToLocalhost()
.WithProtoMessages(ProtoActorSut.Contracts.ProtosReflection.Descriptor)
// .WithChannelOptions(new GrpcChannelOptions
// {
// CompressionProviders = new[]
// {
// new GzipCompressionProvider(CompressionLevel.Fastest)
// }
// }
// )
.WithChannelOptions(new GrpcChannelOptions
{
CompressionProviders = new[]
{
new GzipCompressionProvider(CompressionLevel.Fastest)
}
}
)
.WithLogLevelForDeserializationErrors(LogLevel.Critical);

var clusterProvider = new ConsulProvider(new ConsulProviderConfig());
Expand Down
15 changes: 15 additions & 0 deletions benchmarks/SkyriseMini/Server/SkyriseMiniServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup>
<ServerGarbageCollection>true</ServerGarbageCollection>
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Proto.Cluster.Consul\Proto.Cluster.Consul.csproj" />
<ProjectReference Include="..\..\..\src\Proto.Cluster\Proto.Cluster.csproj" />
Expand All @@ -31,4 +36,14 @@
<Protobuf Include="protos.proto" />
</ItemGroup>

<ItemGroup>

<Content Include="appsettings.Development.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
19 changes: 19 additions & 0 deletions benchmarks/SkyriseMini/Server/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"ProtoActor": {
"ClusterName": "dev"
},

"SeqUrl": "http://localhost:5341",

"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft.AspNetCore": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
},

"AllowedHosts": "*"
}
27 changes: 23 additions & 4 deletions src/Proto.Remote/Endpoints/RemoteMessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// -----------------------------------------------------------------------

using System;
using System.Diagnostics.Metrics;
using System.Linq;
using Microsoft.Extensions.Logging;
using Proto.Mailbox;
Expand Down Expand Up @@ -54,7 +55,12 @@ public void HandleRemoteMessage(RemoteMessage currentMessage)

var typeNames = batch.TypeNames.ToArray();

var m = RemoteMetrics.RemoteDeserializedMessageCount;

Counter<long>? m = null;
if (System.Metrics.Enabled)
{
m = RemoteMetrics.RemoteDeserializedMessageCount;
}

foreach (var envelope in batch.Envelopes)
{
Expand All @@ -75,7 +81,9 @@ public void HandleRemoteMessage(RemoteMessage currentMessage)
var typeName = typeNames[envelope.TypeId];

if (System.Metrics.Enabled)
m.Add(1, new("id", System.Id), new("address", System.Address), new("messagetype", typeName));
{
m!.Add(1, new("id", System.Id), new("address", System.Address), new("messagetype", typeName));
}

object message;

Expand Down Expand Up @@ -122,12 +130,23 @@ public void HandleRemoteMessage(RemoteMessage currentMessage)
default:
Proto.MessageHeader? header = null;
if (envelope.MessageHeader is not null) header = new Proto.MessageHeader(envelope.MessageHeader.HeaderData);
var localEnvelope = new Proto.MessageEnvelope(message, sender, header);

object? messageOrEnvelope = null;

if (header == null && sender == null)
{
messageOrEnvelope = message;
}
else
{
messageOrEnvelope = new Proto.MessageEnvelope(message, sender, header);
}

if (_logger.IsEnabled(LogLevel.Trace))
_logger.LogTrace("[{SystemAddress}] Received user message {MessageType} {Message} for {Target} from {Sender}",
System.Address, message.GetType().Name, message, target, sender
);
System.Root.Send(target, localEnvelope);
System.Root.Send(target, messageOrEnvelope);
break;
}
}
Expand Down