Skip to content
Open
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
48 changes: 24 additions & 24 deletions benchmark/BDN.benchmark/BDN.benchmark.csproj
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>../../Garnet.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>../../Garnet.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" />
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" />
<PackageReference Include="KeraLua" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\libs\cluster\Garnet.cluster.csproj" />
<ProjectReference Include="..\..\libs\host\Garnet.host.csproj" />
<ProjectReference Include="..\..\libs\common\Garnet.common.csproj" />
<ProjectReference Include="..\..\libs\server\Garnet.server.csproj" />
<ProjectReference Include="..\..\modules\GarnetJSON\GarnetJSON.csproj" />
<ProjectReference Include="..\..\modules\NoOpModule\NoOpModule.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\libs\cluster\Garnet.cluster.csproj" />
<ProjectReference Include="..\..\libs\host\Garnet.host.csproj" />
<ProjectReference Include="..\..\libs\common\Garnet.common.csproj" />
<ProjectReference Include="..\..\libs\server\Garnet.server.csproj" />
<ProjectReference Include="..\..\modules\GarnetJSON\GarnetJSON.csproj" />
<ProjectReference Include="..\..\modules\NoOpModule\NoOpModule.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\..\main\GarnetServer\Extensions\MyDictObject.cs" Link="Custom\MyDictObject.cs" />
<Compile Include="..\..\main\GarnetServer\Extensions\MyDictSet.cs" Link="Custom\MyDictSet.cs" />
<Compile Include="..\..\main\GarnetServer\Extensions\MyDictGet.cs" Link="Custom\MyDictGet.cs" />
<Compile Include="..\..\main\GarnetServer\Extensions\SetIfPM.cs" Link="Custom\SetIfPM.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\main\GarnetServer\Extensions\MyDictObject.cs" Link="Custom\MyDictObject.cs" />
<Compile Include="..\..\main\GarnetServer\Extensions\MyDictSet.cs" Link="Custom\MyDictSet.cs" />
<Compile Include="..\..\main\GarnetServer\Extensions\MyDictGet.cs" Link="Custom\MyDictGet.cs" />
<Compile Include="..\..\main\GarnetServer\Extensions\SetIfPM.cs" Link="Custom\SetIfPM.cs" />
</ItemGroup>

</Project>
</Project>
19 changes: 15 additions & 4 deletions benchmark/BDN.benchmark/Cluster/ClusterContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,28 @@ public void Dispose()
server.Dispose();
}

public void SetupSingleInstance(bool disableSlotVerification = false)
public void SetupSingleInstance(ClusterParams clusterParams)
{
var opt = new GarnetServerOptions
{
QuietMode = true,
EnableCluster = !disableSlotVerification,
EnableCluster = !clusterParams.disableSlotVerification,
EndPoints = [new IPEndPoint(IPAddress.Loopback, port)],
CleanClusterConfig = true,
ClusterAnnounceEndpoint = new IPEndPoint(IPAddress.Loopback, port)
ClusterAnnounceEndpoint = new IPEndPoint(IPAddress.Loopback, port),
EnableAOF = clusterParams.enableAof,
};

if (clusterParams.enableAof)
{
opt.EnableAOF = true;
opt.UseAofNullDevice = true;
opt.FastAofTruncate = true;
opt.CommitFrequencyMs = -1;
opt.AofPageSize = "128m";
opt.AofMemorySize = "256m";
}

if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
opt.CheckpointDir = "/tmp";
server = new EmbeddedRespServer(opt);
Expand Down Expand Up @@ -168,5 +180,4 @@ public void CreateCTXNSET(int keySize = 8, int batchSize = 100)
public void Consume(byte* ptr, int length)
=> session.TryConsumeMessages(ptr, length);
}

}
4 changes: 2 additions & 2 deletions benchmark/BDN.benchmark/Cluster/ClusterMigrate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public unsafe class ClusterMigrate
/// </summary>
public IEnumerable<ClusterParams> ClusterParamsProvider()
{
yield return new(false);
yield return new(false, false);
}

ClusterContext cc;
Expand All @@ -34,7 +34,7 @@ public IEnumerable<ClusterParams> ClusterParamsProvider()
public void GlobalSetup()
{
cc = new ClusterContext();
cc.SetupSingleInstance();
cc.SetupSingleInstance(Params);
cc.AddSlotRange([(0, 16383)]);
cc.CreateGetSet();
cc.CreateMGetMSet();
Expand Down
7 changes: 4 additions & 3 deletions benchmark/BDN.benchmark/Cluster/ClusterOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ public unsafe class ClusterOperations
/// </summary>
public IEnumerable<ClusterParams> ClusterParamsProvider()
{
yield return new(false);
yield return new(true);
yield return new(false, false);
yield return new(true, false);
yield return new(false, true);
}

ClusterContext cc;
Expand All @@ -32,7 +33,7 @@ public IEnumerable<ClusterParams> ClusterParamsProvider()
public virtual void GlobalSetup()
{
cc = new ClusterContext();
cc.SetupSingleInstance(Params.disableSlotVerification);
cc.SetupSingleInstance(Params);
cc.AddSlotRange([(0, 16383)]);
cc.CreateGetSet();
cc.CreateMGetMSet();
Expand Down
14 changes: 12 additions & 2 deletions benchmark/BDN.benchmark/Cluster/ClusterParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,35 @@ public struct ClusterParams
/// </summary>
public bool disableSlotVerification;

/// <summary>
/// Whether to enable AOF
/// </summary>
public bool enableAof;

/// <summary>
/// Constructor
/// </summary>
public ClusterParams(bool disableSlotVerification)
public ClusterParams(bool disableSlotVerification, bool enableAof)
{
this.disableSlotVerification = disableSlotVerification;
this.enableAof = enableAof;
}

/// <summary>
/// String representation
/// </summary>
public override string ToString()
{
if (!disableSlotVerification)
if (!disableSlotVerification && !enableAof)
return "None";

var ret = "";
if (disableSlotVerification)
ret += "DSV";

if (enableAof)
ret += ret.Length == 0 ? "AOF" : "+AOF";

return ret;
}
}
Expand Down
8 changes: 4 additions & 4 deletions libs/client/ClientSession/GarnetClientSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private async Task<Socket> ConnectSendSocketAsync(int millisecondsTimeout = 0, C
NoDelay = true
};

if (await TryConnectSocketAsync(socket, endpoint, millisecondsTimeout, cancellationToken))
if (await TryConnectSocketAsync(socket, endpoint, millisecondsTimeout, cancellationToken).ConfigureAwait(false))
return socket;
}
}
Expand All @@ -226,7 +226,7 @@ private async Task<Socket> ConnectSendSocketAsync(int millisecondsTimeout = 0, C
if (EndPoint is not UnixDomainSocketEndPoint)
socket.NoDelay = true;

if (await TryConnectSocketAsync(socket, EndPoint, millisecondsTimeout, cancellationToken))
if (await TryConnectSocketAsync(socket, EndPoint, millisecondsTimeout, cancellationToken).ConfigureAwait(false))
return socket;
}

Expand All @@ -251,12 +251,12 @@ private async Task<bool> TryConnectSocketAsync(Socket socket, EndPoint endpoint,
using var timeoutCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);

var connectTask = socket.ConnectAsync(endpoint, timeoutCts.Token).AsTask();
if (await Task.WhenAny(connectTask, Task.Delay(millisecondsTimeout, timeoutCts.Token)) == connectTask)
if (await Task.WhenAny(connectTask, Task.Delay(millisecondsTimeout, timeoutCts.Token)).ConfigureAwait(false) == connectTask)
{
// Task completed within timeout.
// Consider that the task may have faulted or been canceled.
// We re-await the task so that any exceptions/cancellation is rethrown.
await connectTask;
await connectTask.ConfigureAwait(false);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public sealed unsafe partial class GarnetClientSession : IServerHook, IMessageCo
/// <param name="aofBeginAddress"></param>
/// <param name="aofTailAddress"></param>
/// <returns></returns>
/// <seealso cref="T:Garnet.cluster.ClusterSession.NetworkClusterInitiateReplicaSync"/>
/// <seealso cref="M:Garnet.cluster.ClusterSession.NetworkClusterInitiateReplicaSync"/>
public Task<string> ExecuteReplicaSync(string nodeId, string primary_replid, byte[] checkpointEntryData, long aofBeginAddress, long aofTailAddress)
{
var tcs = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
Expand Down Expand Up @@ -113,7 +113,7 @@ public Task<string> ExecuteReplicaSync(string nodeId, string primary_replid, byt
/// <param name="fileTokenBytes"></param>
/// <param name="fileType"></param>
/// <param name="data"></param>
/// <seealso cref="T:Garnet.cluster.ClusterSession.NetworkClusterSendCheckpointMetadata"/>
/// <seealso cref="M:Garnet.cluster.ClusterSession.NetworkClusterSendCheckpointMetadata"/>
public Task<string> ExecuteSendCkptMetadata(Memory<byte> fileTokenBytes, int fileType, Memory<byte> data)
{
var tcs = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
Expand Down Expand Up @@ -180,7 +180,7 @@ public Task<string> ExecuteSendCkptMetadata(Memory<byte> fileTokenBytes, int fil
/// <param name="startAddress"></param>
/// <param name="data"></param>
/// <param name="segmentId"></param>
/// <seealso cref="T:Garnet.cluster.ClusterSession.NetworkClusterSendCheckpointFileSegment"/>
/// <seealso cref="M:Garnet.cluster.ClusterSession.NetworkClusterSendCheckpointFileSegment"/>
public Task<string> ExecuteSendFileSegments(Memory<byte> fileTokenBytes, int fileType, long startAddress, Span<byte> data, int segmentId = -1)
{
var tcs = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
Expand Down Expand Up @@ -266,7 +266,7 @@ public Task<string> ExecuteSendFileSegments(Memory<byte> fileTokenBytes, int fil
/// <param name="beginAddress"></param>
/// <param name="tailAddress"></param>
/// <returns></returns>
/// <seealso cref="T:Garnet.cluster.ClusterSession.NetworkClusterBeginReplicaRecover"/>
/// <seealso cref="M:Garnet.cluster.ClusterSession.NetworkClusterBeginReplicaRecover"/>
public Task<string> ExecuteBeginReplicaRecover(bool sendStoreCheckpoint, bool replayAOF, string primary_replid, byte[] checkpointEntryData, long beginAddress, long tailAddress)
{
var tcs = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
Expand Down Expand Up @@ -355,7 +355,7 @@ public Task<string> ExecuteBeginReplicaRecover(bool sendStoreCheckpoint, bool re
/// </summary>
/// <param name="syncMetadata"></param>
/// <returns></returns>
/// <seealso cref="T:Garnet.cluster.ClusterSession.NetworkClusterAttachSync"/>
/// <seealso cref="M:Garnet.cluster.ClusterSession.NetworkClusterAttachSync"/>
public Task<string> ExecuteAttachSync(byte[] syncMetadata)
{
var tcs = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
Expand Down Expand Up @@ -403,7 +403,7 @@ public Task<string> ExecuteAttachSync(byte[] syncMetadata)
/// Set CLUSTER SYNC header info
/// </summary>
/// <param name="sourceNodeId"></param>
/// <seealso cref="T:Garnet.cluster.ClusterSession.NetworkClusterSync"/>
/// <seealso cref="M:Garnet.cluster.ClusterSession.NetworkClusterSync"/>
public void SetClusterSyncHeader(string sourceNodeId)
{
// Unlike Migration, where we don't know at the time of header initialization if we have a record or not, in Replication
Expand Down
Loading
Loading