Skip to content

Commit

Permalink
Sync to most recent main
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenge committed Oct 18, 2024
2 parents 39b2e2c + a4b47b4 commit 8c321b5
Show file tree
Hide file tree
Showing 191 changed files with 10,579 additions and 6,752 deletions.
4 changes: 2 additions & 2 deletions .azure/pipelines/azure-pipelines-external-release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
######################################
# NOTE: Before running this pipeline to generate a new nuget package, update the version string in two places
# 1) update the name: string below (line 6) -- this is the version for the nuget package (e.g. 1.0.0)
# 2) update \libs\host\GarnetServer.cs readonly string version (~line 53) -- NOTE - these two values need to be the same
# 2) update \libs\host\GarnetServer.cs readonly string version (~line 32) -- NOTE - these two values need to be the same
######################################
name: 1.0.30
name: 1.0.33
trigger:
branches:
include:
Expand Down
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageVersion Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="8.0.1" />
<PackageVersion Include="Microsoft.IdentityModel.Validators" Version="8.0.1" />
<PackageVersion Include="StackExchange.Redis" Version="2.8.0" />
<PackageVersion Include="StackExchange.Redis" Version="2.8.16" />
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="8.0.1" />
<PackageVersion Include="System.Interactive.Async" Version="6.0.1" />
<PackageVersion Include="System.Text.Json" Version="8.0.4" />
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting.WindowsServices" Version="8.0.0" />
</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ COPY libs/cluster/*.csproj libs/cluster/
COPY libs/common/*.csproj libs/common/
COPY libs/host/*.csproj libs/host/
COPY libs/server/*.csproj libs/server/
COPY libs/resources/*.csproj libs/resources/
COPY libs/storage/Tsavorite/cs/src/core/*.csproj libs/storage/Tsavorite/cs/src/core/
COPY libs/storage/Tsavorite/cs/src/devices/AzureStorageDevice/*.csproj libs/storage/Tsavorite/cs/src/devices/AzureStorageDevice/
COPY main/GarnetServer/*.csproj main/GarnetServer/
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ COPY libs/cluster/*.csproj libs/cluster/
COPY libs/common/*.csproj libs/common/
COPY libs/host/*.csproj libs/host/
COPY libs/server/*.csproj libs/server/
COPY libs/resources/*.csproj libs/resources/
COPY libs/storage/Tsavorite/cs/src/core/*.csproj libs/storage/Tsavorite/cs/src/core/
COPY libs/storage/Tsavorite/cs/src/devices/AzureStorageDevice/*.csproj libs/storage/Tsavorite/cs/src/devices/AzureStorageDevice/
COPY main/GarnetServer/*.csproj main/GarnetServer/
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.cbl-mariner
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ COPY libs/cluster/*.csproj libs/cluster/
COPY libs/common/*.csproj libs/common/
COPY libs/host/*.csproj libs/host/
COPY libs/server/*.csproj libs/server/
COPY libs/resources/*.csproj libs/resources/
COPY libs/storage/Tsavorite/cs/src/core/*.csproj libs/storage/Tsavorite/cs/src/core/
COPY libs/storage/Tsavorite/cs/src/devices/AzureStorageDevice/*.csproj libs/storage/Tsavorite/cs/src/devices/AzureStorageDevice/
COPY main/GarnetServer/*.csproj main/GarnetServer/
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.chiseled
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ COPY libs/cluster/*.csproj libs/cluster/
COPY libs/common/*.csproj libs/common/
COPY libs/host/*.csproj libs/host/
COPY libs/server/*.csproj libs/server/
COPY libs/resources/*.csproj libs/resources/
COPY libs/storage/Tsavorite/cs/src/core/*.csproj libs/storage/Tsavorite/cs/src/core/
COPY libs/storage/Tsavorite/cs/src/devices/AzureStorageDevice/*.csproj libs/storage/Tsavorite/cs/src/devices/AzureStorageDevice/
COPY main/GarnetServer/*.csproj main/GarnetServer/
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ COPY libs/cluster/*.csproj libs/cluster/
COPY libs/common/*.csproj libs/common/
COPY libs/host/*.csproj libs/host/
COPY libs/server/*.csproj libs/server/
COPY libs/resources/*.csproj libs/resources/
COPY libs/storage/Tsavorite/cs/src/core/*.csproj libs/storage/Tsavorite/cs/src/core/
COPY libs/storage/Tsavorite/cs/src/devices/AzureStorageDevice/*.csproj libs/storage/Tsavorite/cs/src/devices/AzureStorageDevice/
COPY main/GarnetServer/*.csproj main/GarnetServer/
Expand Down
2 changes: 1 addition & 1 deletion Garnet.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<dependency id="Microsoft.IdentityModel.Validators" version="8.0.1" />
<dependency id="Azure.Storage.Blobs" version="12.21.2" />
<dependency id="NLua" version="1.7.3" />
<dependency id="System.Text.Json" version="8.0.4" />
<dependency id="System.Text.Json" version="8.0.5" />
</dependencies>
<readme>README.md</readme>
</metadata>
Expand Down
180 changes: 180 additions & 0 deletions benchmark/BDN.benchmark/Cluster/ClusterContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

using System.Runtime.CompilerServices;
using System.Text;
using Embedded.perftest;
using Garnet.common;
using Garnet.server;

namespace BDN.benchmark.Cluster
{
public unsafe struct Request
{
public byte[] buffer;
public byte* ptr;

public Request(int size)
{
buffer = GC.AllocateArray<byte>(size, pinned: true);
ptr = (byte*)Unsafe.AsPointer(ref buffer[0]);
}
}

public unsafe class ClusterContext
{
EmbeddedRespServer server;
RespServerSession session;
BenchUtils benchUtils = new();

private readonly int Port = 7000;

public ReadOnlySpan<byte> keyTag => "{0}"u8;
public Request[] singleGetSet;
public Request[] singleMGetMSet;
public Request singleCPBSET;

public void Dispose()
{
session.Dispose();
server.Dispose();
}

public void SetupSingleInstance(bool enableCluster = true)
{
var opt = new GarnetServerOptions
{
QuietMode = true,
EnableCluster = enableCluster,
Port = Port,
CleanClusterConfig = true,
};
server = new EmbeddedRespServer(opt);
session = server.GetRespSession();
server.Register.NewTransactionProc(CustomProcSetBench.CommandName, () => new CustomProcSetBench(), new RespCommandsInfo { Arity = CustomProcSetBench.Arity });
}

public void AddSlotRange(List<(int, int)> slotRanges)
{
foreach (var slotRange in slotRanges)
{
var clusterAddSlotsRange = Encoding.ASCII.GetBytes($"*4\r\n$7\r\nCLUSTER\r\n$13\r\nADDSLOTSRANGE\r\n" +
$"${NumUtils.NumDigits(slotRange.Item1)}\r\n{slotRange.Item1}\r\n" +
$"${NumUtils.NumDigits(slotRange.Item2)}\r\n{slotRange.Item2}\r\n");
fixed (byte* req = clusterAddSlotsRange)
_ = session.TryConsumeMessages(req, clusterAddSlotsRange.Length);
}
}

public void CreateGetSet(int keySize = 8, int valueSize = 32, int batchSize = 128)
{
var pairs = new (byte[], byte[])[batchSize];
for (var i = 0; i < batchSize; i++)
{
pairs[i] = (new byte[keySize], new byte[valueSize]);

keyTag.CopyTo(pairs[i].Item1.AsSpan());
benchUtils.RandomBytes(ref pairs[i].Item1, startOffset: keyTag.Length);
benchUtils.RandomBytes(ref pairs[i].Item2);
}

var setByteCount = batchSize * ("*2\r\n$3\r\nSET\r\n"u8.Length + (1 + NumUtils.NumDigits(keySize) + 2 + keySize + 2) + (1 + NumUtils.NumDigits(valueSize) + 2 + valueSize + 2));
var setReq = new Request(setByteCount);
var curr = setReq.ptr;
var end = curr + setReq.buffer.Length;
for (var i = 0; i < batchSize; i++)
{
_ = RespWriteUtils.WriteArrayLength(3, ref curr, end);
_ = RespWriteUtils.WriteBulkString("SET"u8, ref curr, end);
_ = RespWriteUtils.WriteBulkString(pairs[i].Item1, ref curr, end);
_ = RespWriteUtils.WriteBulkString(pairs[i].Item2, ref curr, end);
}

var getByteCount = batchSize * ("*2\r\n$3\r\nGET\r\n"u8.Length + 1 + NumUtils.NumDigits(keySize) + 2 + keySize + 2);
var getReq = new Request(getByteCount);
curr = getReq.ptr;
end = curr + getReq.buffer.Length;
for (var i = 0; i < batchSize; i++)
{
_ = RespWriteUtils.WriteArrayLength(2, ref curr, end);
_ = RespWriteUtils.WriteBulkString("GET"u8, ref curr, end);
_ = RespWriteUtils.WriteBulkString(pairs[i].Item1, ref curr, end);
}
singleGetSet = [getReq, setReq];
}

public void CreateMGetMSet(int keySize = 8, int valueSize = 32, int batchSize = 128)
{
var pairs = new (byte[], byte[])[batchSize];
for (var i = 0; i < batchSize; i++)
{
pairs[i] = (new byte[keySize], new byte[valueSize]);

keyTag.CopyTo(pairs[i].Item1.AsSpan());
benchUtils.RandomBytes(ref pairs[i].Item1, startOffset: keyTag.Length);
benchUtils.RandomBytes(ref pairs[i].Item2);
}

var mGetHeaderSize = 1 + NumUtils.NumDigits(1 + batchSize) + 2 + "$4\r\nMGET\r\n"u8.Length;
var getRespSize = 1 + NumUtils.NumDigits(keySize) + 2 + keySize + 2;
var mGetByteCount = mGetHeaderSize + (batchSize * getRespSize);
var mGetReq = new Request(mGetByteCount);

var curr = mGetReq.ptr;
var end = curr + mGetReq.buffer.Length;
_ = RespWriteUtils.WriteArrayLength(1 + batchSize, ref curr, end);
_ = RespWriteUtils.WriteBulkString("MGET"u8, ref curr, end);
for (var i = 0; i < batchSize; i++)
_ = RespWriteUtils.WriteBulkString(pairs[i].Item1, ref curr, end);

var mSetHeaderSize = 1 + NumUtils.NumDigits(1 + batchSize * 2) + 2 + "$4\r\nMSET\r\n"u8.Length;
var setRespSize = 1 + NumUtils.NumDigits(keySize) + 2 + keySize + 2 + 1 + NumUtils.NumDigits(valueSize) + 2 + valueSize + 2;
var mSetByteCount = mSetHeaderSize + (batchSize * setRespSize);
var mSetReq = new Request(mSetByteCount);

curr = mSetReq.ptr;
end = curr + mSetReq.buffer.Length;
_ = RespWriteUtils.WriteArrayLength(1 + batchSize * 2, ref curr, end);
_ = RespWriteUtils.WriteBulkString("MSET"u8, ref curr, end);
for (var i = 0; i < batchSize; i++)
{
_ = RespWriteUtils.WriteBulkString(pairs[i].Item1, ref curr, end);
_ = RespWriteUtils.WriteBulkString(pairs[i].Item2, ref curr, end);
}
singleMGetMSet = [mGetReq, mSetReq];
}

public void CreateCPBSET(int keySize = 8, int valueSize = 32, int batchSize = 128)
{
var keys = new byte[8][];
for (var i = 0; i < 8; i++)
{
keys[i] = new byte[keySize];

keyTag.CopyTo(keys[i].AsSpan());
benchUtils.RandomBytes(ref keys[i], startOffset: keyTag.Length);
}

var cpbsetByteCount = "*9\r\n$6\r\nCPBSET\r\n"u8.Length + (8 * (1 + NumUtils.NumDigits(keySize) + 2 + keySize + 2));
var cpbsetReq = new Request(batchSize * cpbsetByteCount);
var curr = cpbsetReq.ptr;
var end = curr + cpbsetReq.buffer.Length;

for (var i = 0; i < batchSize; i++)
{
_ = RespWriteUtils.WriteArrayLength(9, ref curr, end);
_ = RespWriteUtils.WriteBulkString("CPBSET"u8, ref curr, end);
for (var j = 0; j < 8; j++)
{
_ = RespWriteUtils.WriteBulkString(keys[j], ref curr, end);
}
}

singleCPBSET = cpbsetReq;
}

public void Consume(byte* ptr, int length)
=> session.TryConsumeMessages(ptr, length);
}

}
Loading

1 comment on commit 8c321b5

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.40.

Benchmark suite Current: 8c321b5 Previous: 39b2e2c Ratio
BDN.benchmark.Resp.RespParseStress.LPushPop 178064.0947091239 ns (± 710.4014803824243) 126875.54117838542 ns (± 311.95337725859986) 1.40

This comment was automatically generated by workflow using github-action-benchmark.

CC: @darrenge

Please sign in to comment.