Skip to content
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
33 changes: 33 additions & 0 deletions ProtoActor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClusterPubSubBatchingProduc
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Proto.Cluster.PubSub.Tests", "tests\Proto.Cluster.PubSub.Tests\Proto.Cluster.PubSub.Tests.csproj", "{5B3A62B8-4C75-4551-9DDE-4107EE96FD03}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SkyriseMini", "SkyriseMini", "{DF09798D-20CC-418C-901B-DEFEEFF02E1B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkyriseMiniClient", "benchmarks\SkyriseMini\Client\SkyriseMiniClient.csproj", "{8B0466D8-C57E-4D29-98B3-CB2D087765DC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkyriseMiniServer", "benchmarks\SkyriseMini\Server\SkyriseMiniServer.csproj", "{7C08B7D5-90BD-45E9-BADF-1B6CEB1A3E97}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1259,6 +1265,30 @@ Global
{5B3A62B8-4C75-4551-9DDE-4107EE96FD03}.Release|x64.Build.0 = Release|Any CPU
{5B3A62B8-4C75-4551-9DDE-4107EE96FD03}.Release|x86.ActiveCfg = Release|Any CPU
{5B3A62B8-4C75-4551-9DDE-4107EE96FD03}.Release|x86.Build.0 = Release|Any CPU
{8B0466D8-C57E-4D29-98B3-CB2D087765DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8B0466D8-C57E-4D29-98B3-CB2D087765DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8B0466D8-C57E-4D29-98B3-CB2D087765DC}.Debug|x64.ActiveCfg = Debug|Any CPU
{8B0466D8-C57E-4D29-98B3-CB2D087765DC}.Debug|x64.Build.0 = Debug|Any CPU
{8B0466D8-C57E-4D29-98B3-CB2D087765DC}.Debug|x86.ActiveCfg = Debug|Any CPU
{8B0466D8-C57E-4D29-98B3-CB2D087765DC}.Debug|x86.Build.0 = Debug|Any CPU
{8B0466D8-C57E-4D29-98B3-CB2D087765DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8B0466D8-C57E-4D29-98B3-CB2D087765DC}.Release|Any CPU.Build.0 = Release|Any CPU
{8B0466D8-C57E-4D29-98B3-CB2D087765DC}.Release|x64.ActiveCfg = Release|Any CPU
{8B0466D8-C57E-4D29-98B3-CB2D087765DC}.Release|x64.Build.0 = Release|Any CPU
{8B0466D8-C57E-4D29-98B3-CB2D087765DC}.Release|x86.ActiveCfg = Release|Any CPU
{8B0466D8-C57E-4D29-98B3-CB2D087765DC}.Release|x86.Build.0 = Release|Any CPU
{7C08B7D5-90BD-45E9-BADF-1B6CEB1A3E97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C08B7D5-90BD-45E9-BADF-1B6CEB1A3E97}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C08B7D5-90BD-45E9-BADF-1B6CEB1A3E97}.Debug|x64.ActiveCfg = Debug|Any CPU
{7C08B7D5-90BD-45E9-BADF-1B6CEB1A3E97}.Debug|x64.Build.0 = Debug|Any CPU
{7C08B7D5-90BD-45E9-BADF-1B6CEB1A3E97}.Debug|x86.ActiveCfg = Debug|Any CPU
{7C08B7D5-90BD-45E9-BADF-1B6CEB1A3E97}.Debug|x86.Build.0 = Debug|Any CPU
{7C08B7D5-90BD-45E9-BADF-1B6CEB1A3E97}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7C08B7D5-90BD-45E9-BADF-1B6CEB1A3E97}.Release|Any CPU.Build.0 = Release|Any CPU
{7C08B7D5-90BD-45E9-BADF-1B6CEB1A3E97}.Release|x64.ActiveCfg = Release|Any CPU
{7C08B7D5-90BD-45E9-BADF-1B6CEB1A3E97}.Release|x64.Build.0 = Release|Any CPU
{7C08B7D5-90BD-45E9-BADF-1B6CEB1A3E97}.Release|x86.ActiveCfg = Release|Any CPU
{7C08B7D5-90BD-45E9-BADF-1B6CEB1A3E97}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1375,6 +1405,9 @@ Global
{4A162D2F-C82A-4919-962B-6B2C53316263} = {59DCCC96-DDAF-469F-9E8E-9BC733285082}
{8D481FB0-EEDC-4049-B18E-DEACA5BD8FF4} = {4A162D2F-C82A-4919-962B-6B2C53316263}
{5B3A62B8-4C75-4551-9DDE-4107EE96FD03} = {9AA2BCF0-19AB-4DD9-8D91-7D188E463806}
{DF09798D-20CC-418C-901B-DEFEEFF02E1B} = {0F3AB331-C042-4371-A2F0-0AFDFA13DC9F}
{8B0466D8-C57E-4D29-98B3-CB2D087765DC} = {DF09798D-20CC-418C-901B-DEFEEFF02E1B}
{7C08B7D5-90BD-45E9-BADF-1B6CEB1A3E97} = {DF09798D-20CC-418C-901B-DEFEEFF02E1B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CD0D1E44-8118-4682-8793-6B20ABFA824C}
Expand Down
36 changes: 36 additions & 0 deletions benchmarks/SkyriseMini/Client/ActorSystemHostedService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Proto;
using Proto.Cluster;

namespace ProtoActorSut.Shared;

public class ActorSystemHostedService : IHostedService
{
private readonly ActorSystem _actorSystem;
private readonly ILogger<ActorSystemHostedService> _logger;

public ActorSystemHostedService(ActorSystem actorSystem, ILogger<ActorSystemHostedService> logger)
{
_actorSystem = actorSystem;
_logger = logger;
}

public async Task StartAsync(CancellationToken cancellationToken)
{
_logger.LogInformation("Starting Proto actor system");

await _actorSystem
.Cluster()
.StartMemberAsync();
}

public async Task StopAsync(CancellationToken cancellationToken)
{
_logger.LogInformation("Stopping Proto actor system");

await _actorSystem
.Cluster()
.ShutdownAsync();
}
}
23 changes: 23 additions & 0 deletions benchmarks/SkyriseMini/Client/PingPongActorRaw.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Proto;
using ProtoActorSut.Contracts;

namespace SkyriseMini;

public class PingPongActorRaw : IActor
{
private Task Ping(PingMessage request, IContext ctx)
{
ctx.Respond(new PongMessage {Response = "Hello " + request.Name});
return Task.CompletedTask;
}

public Task ReceiveAsync(IContext context)
{
if (context.Message is PingMessage ping)
{
return Ping(ping, context);
}

return Task.CompletedTask;
}
}
69 changes: 69 additions & 0 deletions benchmarks/SkyriseMini/Client/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System.Reflection;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
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)
);

Console.WriteLine("Starting client");
builder.Services.AddSingleton<TestManager>();
builder.Services.AddTransient<MessagingTest>();
builder.Services.AddTransient<ActivationTest>();
builder.AddProtoActorTestServicesRaw();
builder.AddProtoActorClient();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

app.UseRouting();
app.UseSwagger();
app.UseSwaggerUI();

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));

return Task.CompletedTask;
}
);

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

return Task.CompletedTask;
}
);

app.Run();
}
catch (Exception e)
{
Log.Logger.Fatal(e, "Service crash");
throw;
}
finally
{
Log.CloseAndFlush();
}
15 changes: 15 additions & 0 deletions benchmarks/SkyriseMini/Client/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"TestRunner ProtoActor Raw": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5051",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
78 changes: 78 additions & 0 deletions benchmarks/SkyriseMini/Client/ProtoActorExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using System.IO.Compression;
using Grpc.Net.Client;
using Grpc.Net.Compression;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Proto;
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;
using ProtoActorSut.Shared;
using SkyriseMini.Tests;

namespace SkyriseMini;

public static class ProtoActorExtensions
{
public static WebApplicationBuilder AddProtoActorTestServicesRaw(this WebApplicationBuilder builder)
{
builder.Services.AddSingleton<ProtoActorTestServicesRaw>();
builder.Services.AddSingleton<Ping>(provider => provider.GetRequiredService<ProtoActorTestServicesRaw>().Ping);
builder.Services.AddSingleton<Activate>(provider => provider.GetRequiredService<ProtoActorTestServicesRaw>().Activate);

return builder;
}

public static WebApplicationBuilder AddProtoActorClient(this WebApplicationBuilder builder)
{

builder.Services.AddSingleton(provider =>
{
var config = builder.Configuration.GetSection("ProtoActor");

Log.SetLoggerFactory(provider.GetRequiredService<ILoggerFactory>());

var actorSystemConfig = ActorSystemConfig
.Setup()
.WithSharedFutures()
.WithDeadLetterThrottleCount(3)
.WithDeadLetterThrottleInterval(TimeSpan.FromSeconds(1));

var system = new ActorSystem(actorSystemConfig);

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

var clusterProvider = new ConsulProvider(new ConsulProviderConfig());

var clusterConfig = ClusterConfig
.Setup(config["ClusterName"], clusterProvider, new PartitionIdentityLookup());

system
.WithServiceProvider(provider)
.WithRemote(remoteConfig)
.WithCluster(clusterConfig)
.Cluster();

return system;
});

builder.Services.AddHostedService<ActorSystemHostedService>();

return builder;
}
}
39 changes: 39 additions & 0 deletions benchmarks/SkyriseMini/Client/ProtoActorTestServicesRaw.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Proto;
using Proto.Cluster;
using ProtoActorSut.Contracts;

namespace SkyriseMini;

public class ProtoActorTestServicesRaw
{
private readonly Cluster _cluster;

public ProtoActorTestServicesRaw(ActorSystem system)
{
_cluster = system.Cluster();
}

public async Task Ping(object handle, string name)
{
var ci = handle as ClusterIdentity ??
throw new ArgumentException($"Handle needs to be of type {nameof(ClusterIdentity)}", nameof(handle));

var pong = await _cluster.RequestAsync<PongMessage>(ci, new PingMessage { Name = name}, CancellationTokens.FromSeconds(5));

var expectedResponse = "Hello " + name;

if (pong == null)
{
throw new Exception("Request timed out");
}
if (pong.Response != expectedResponse)
throw new Exception($"Received response '{pong.Response}' but expected '{expectedResponse}'");
}

public async Task<object> Activate(string id)
{
var ci = ClusterIdentity.Create(id, "PingPongRaw");
var res = await _cluster.RequestAsync<PongMessage>(ci, new PingMessage(), CancellationToken.None);
return ci;
}
}
38 changes: 38 additions & 0 deletions benchmarks/SkyriseMini/Client/SkyriseMiniClient.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Proto.Cluster.Consul\Proto.Cluster.Consul.csproj" />
<ProjectReference Include="..\..\..\src\Proto.Cluster\Proto.Cluster.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Grpc.Tools" Version="2.47.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="OpenTelemetry" Version="1.3.0" />
<PackageReference Include="OpenTelemetry.Api" Version="1.3.0" />
<PackageReference Include="OpenTelemetry.Exporter.Prometheus" Version="1.3.0-rc.2" />
<PackageReference Include="prometheus-net" Version="6.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="6.0.0-dev-00265" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.2-dev-00890" />
<PackageReference Include="Serilog.Sinks.Seq" Version="5.1.2-dev-00225" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.1" />
</ItemGroup>

<ItemGroup>
<Protobuf Include="protos.proto" />
</ItemGroup>

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

</Project>
Loading