Skip to content
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

Add Unix socket support #944

Merged
merged 30 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b2efbe0
Add Unix socket support
PaulusParssinen Jan 22, 2025
ac2bfd6
Merge branch 'main' into unixsockets
PaulusParssinen Jan 22, 2025
d03369a
More cluster test adjustments
PaulusParssinen Jan 23, 2025
db06909
Remove warnings
PaulusParssinen Jan 23, 2025
c9599c9
dotnet format whitespace
PaulusParssinen Jan 23, 2025
8d47871
Merge branch 'main' into unixsockets
PaulusParssinen Jan 23, 2025
a3f66fd
fix merge
PaulusParssinen Jan 23, 2025
266509a
Merge branch 'main' into unixsockets
PaulusParssinen Jan 24, 2025
e7735b4
fix merge
PaulusParssinen Jan 24, 2025
04d97df
Add very basic test for the unix socket support
PaulusParssinen Jan 25, 2025
1c0b04b
Merge branch 'main' into unixsockets
PaulusParssinen Jan 25, 2025
30c8478
Try fix long-path error & sync GarnetClientSession connection logic w…
PaulusParssinen Jan 25, 2025
e924eed
Dispose the GarnetClient objects in tests
PaulusParssinen Jan 25, 2025
c3b30b9
Sync LightClient connection logic with GarnetClient(Session)
PaulusParssinen Jan 25, 2025
360b681
Merge branch 'main' into unixsockets
PaulusParssinen Jan 25, 2025
a59f421
fix
PaulusParssinen Jan 25, 2025
28b55f4
Add exception message to StoreWrapper.GetIp
PaulusParssinen Jan 31, 2025
52951d5
Merge remote-tracking branch 'origin/main' into unixsockets
PaulusParssinen Jan 31, 2025
b63c2c2
Fix merge
PaulusParssinen Jan 31, 2025
a30b8c5
Add TLS test path
PaulusParssinen Jan 31, 2025
39e2481
Add more Unix socket tests with SE.Redis as client
PaulusParssinen Jan 31, 2025
ceea3fa
Add config parsing for --unixsocketperm and tests
PaulusParssinen Jan 31, 2025
882f925
attempt fix import ordering
PaulusParssinen Jan 31, 2025
f3d126b
Set unix socket permission after listener is bound
PaulusParssinen Jan 31, 2025
62f3451
attempt fix import ordering
PaulusParssinen Jan 31, 2025
ef6e7d2
attempt fix import ordering
PaulusParssinen Jan 31, 2025
ecd8419
attempt fix import ordering
PaulusParssinen Jan 31, 2025
e1aa090
use ILogger in LightClient
PaulusParssinen Jan 31, 2025
a98320b
Merge branch 'main' into unixsockets
vazois Feb 3, 2025
c82fcf5
Merge branch 'main' into unixsockets
vazois Feb 3, 2025
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
3 changes: 2 additions & 1 deletion benchmark/BDN.benchmark/Cluster/ClusterContext.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

using System.Net;
using System.Runtime.InteropServices;
using System.Text;
using BDN.benchmark.CustomProcs;
Expand Down Expand Up @@ -34,7 +35,7 @@ public void SetupSingleInstance(bool disableSlotVerification = false)
{
QuietMode = true,
EnableCluster = !disableSlotVerification,
Port = port,
EndPoint = new IPEndPoint(IPAddress.Loopback, port),
CleanClusterConfig = true,
};
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
Expand Down
7 changes: 4 additions & 3 deletions benchmark/BDN.benchmark/Embedded/GarnetServerEmbedded.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT license.

using System;
using System.Net;
using System.Net.Security;
using System.Threading;
using Garnet.common;
Expand All @@ -13,7 +14,7 @@ namespace Embedded.server
{
internal class GarnetServerEmbedded : GarnetServerBase, IServerHook
{
public GarnetServerEmbedded() : base("0.0.0.0", 0, 1 << 10)
public GarnetServerEmbedded() : base(new IPEndPoint(IPAddress.Loopback, 0), 1 << 10)
{
}

Expand All @@ -36,7 +37,7 @@ public EmbeddedNetworkHandler CreateNetworkHandler(SslClientAuthenticationOption
throw new Exception("Unable to add handler to dictionary");

handler.Start(tlsOptions, remoteEndpointName);
incr_conn_recv();
IncrementConnectionsReceived();
return handler;
}
catch (Exception ex)
Expand All @@ -59,7 +60,7 @@ public void DisposeMessageConsumer(INetworkHandler session)
if (activeHandlers.TryRemove(session, out _))
{
Interlocked.Decrement(ref activeHandlerCount);
incr_conn_disp();
IncrementConnectionsDisposed();
try
{
session.Session?.Dispose();
Expand Down
5 changes: 3 additions & 2 deletions benchmark/Resp.benchmark/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading;
using CommandLine;
using Garnet.client;
Expand Down Expand Up @@ -195,7 +196,7 @@ static void Main(string[] args)

static void WaitForServer(Options opts)
{
using var client = new GarnetClientSession(opts.Address, opts.Port, new(), tlsOptions: opts.EnableTLS ? BenchUtils.GetTlsOptions(opts.TlsHost, opts.CertFileName, opts.CertPassword) : null);
using var client = new GarnetClientSession(new IPEndPoint(IPAddress.Parse(opts.Address), opts.Port), new(), tlsOptions: opts.EnableTLS ? BenchUtils.GetTlsOptions(opts.TlsHost, opts.CertFileName, opts.CertPassword) : null);
while (true)
{
try
Expand Down Expand Up @@ -228,7 +229,7 @@ static void RunBasicCommandsBenchmark(Options opts)
unsafe
{
var onResponseDelegate = new LightClient.OnResponseDelegateUnsafe(ReqGen.OnResponse);
using var client = new LightClient(opts.Address, opts.Port, (int)OpType.GET, onResponseDelegate, opts.DbSize, opts.EnableTLS ? BenchUtils.GetTlsOptions(opts.TlsHost, opts.CertFileName, opts.CertPassword) : null);
using var client = new LightClient(new IPEndPoint(IPAddress.Parse(opts.Address), opts.Port), (int)OpType.GET, onResponseDelegate, opts.DbSize, opts.EnableTLS ? BenchUtils.GetTlsOptions(opts.TlsHost, opts.CertFileName, opts.CertPassword) : null);
client.Connect();
client.Authenticate(opts.Auth);
BenchUtils.LoadSetGetScripts(client, out BenchUtils.sha1SetScript, out BenchUtils.sha1GetScript);
Expand Down
21 changes: 9 additions & 12 deletions benchmark/Resp.benchmark/RespOnlineBench.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Buffers;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -33,8 +34,7 @@ internal class RespOnlineBench
static bool IsValidRange(long value)
=> value < HISTOGRAM_UPPER_BOUND && value > HISTOGRAM_LOWER_BOUND;

readonly string address;
readonly int port;
readonly EndPoint endpoint;
readonly int NumThreads;
readonly OpType op;
readonly Options opts;
Expand Down Expand Up @@ -71,8 +71,7 @@ public RespOnlineBench(Options opts, int resetInterval = 30, int runDuration = i
{
this.runDuration = runDuration;
this.resetInterval = resetInterval;
this.address = opts.Address;
this.port = opts.Port;
this.endpoint = new IPEndPoint(IPAddress.Parse(opts.Address), opts.Port);
this.op = opts.Op;
this.opts = opts;
this.auth = opts.Auth;
Expand Down Expand Up @@ -157,7 +156,7 @@ private void InitializeClients()
{
gcsPool = new AsyncPool<GarnetClientSession>(opts.NumThreads.First(), () =>
{
var c = new GarnetClientSession(address, port, new(), tlsOptions: opts.EnableTLS ? BenchUtils.GetTlsOptions(opts.TlsHost, opts.CertFileName, opts.CertPassword) : null);
var c = new GarnetClientSession(endpoint, new(), tlsOptions: opts.EnableTLS ? BenchUtils.GetTlsOptions(opts.TlsHost, opts.CertFileName, opts.CertPassword) : null);
c.Connect();
if (auth != null)
{
Expand All @@ -173,7 +172,7 @@ private void InitializeClients()
{
gdbPool = new AsyncPool<GarnetClient>(opts.NumThreads.First(), () =>
{
var gdb = new GarnetClient(address, port, opts.EnableTLS ? BenchUtils.GetTlsOptions(opts.TlsHost, opts.CertFileName, opts.CertPassword) : null, recordLatency: opts.ClientHistogram);
var gdb = new GarnetClient(endpoint, opts.EnableTLS ? BenchUtils.GetTlsOptions(opts.TlsHost, opts.CertFileName, opts.CertPassword) : null, recordLatency: opts.ClientHistogram);
gdb.Connect();
if (auth != null)
{
Expand All @@ -184,7 +183,7 @@ private void InitializeClients()
}
else
{
garnetClient = new GarnetClient(address, port, opts.EnableTLS ? BenchUtils.GetTlsOptions(opts.TlsHost, opts.CertFileName, opts.CertPassword) : null, recordLatency: opts.ClientHistogram);
garnetClient = new GarnetClient(endpoint, opts.EnableTLS ? BenchUtils.GetTlsOptions(opts.TlsHost, opts.CertFileName, opts.CertPassword) : null, recordLatency: opts.ClientHistogram);
garnetClient.Connect();
if (auth != null)
{
Expand Down Expand Up @@ -427,7 +426,7 @@ public unsafe void OpRunnerLightClient(int thread_id)

var onResponseDelegate = new LightClient.OnResponseDelegateUnsafe(ReqGen.OnResponse);

var client = new LightClient(address, port, (int)op, onResponseDelegate, size, opts.EnableTLS ? BenchUtils.GetTlsOptions(opts.TlsHost, opts.CertFileName, opts.CertPassword) : null);
var client = new LightClient(endpoint, (int)op, onResponseDelegate, size, opts.EnableTLS ? BenchUtils.GetTlsOptions(opts.TlsHost, opts.CertFileName, opts.CertPassword) : null);
client.Connect();
client.Authenticate(auth);

Expand Down Expand Up @@ -571,8 +570,7 @@ public async void OpRunnerGarnetClientSession(int thread_id)
if (!opts.Pool)
{
client = new GarnetClientSession(
address,
port,
endpoint,
new(Math.Max(bufferSizeValue, opts.ValueLength * opts.IntraThreadParallelism)),
tlsOptions: opts.EnableTLS ? BenchUtils.GetTlsOptions(opts.TlsHost, opts.CertFileName, opts.CertPassword) : null);
client.Connect();
Expand Down Expand Up @@ -671,8 +669,7 @@ public async void OpRunnerGarnetClientSessionParallel(int thread_id, int paralle
if (!opts.Pool)
{
client = new GarnetClientSession(
address,
port,
endpoint,
new NetworkBufferSettings(Math.Max(131072, opts.IntraThreadParallelism * opts.ValueLength)),
tlsOptions: opts.EnableTLS ? BenchUtils.GetTlsOptions(opts.TlsHost, opts.CertFileName, opts.CertPassword) : null);
client.Connect();
Expand Down
7 changes: 4 additions & 3 deletions benchmark/Resp.benchmark/RespPerfBench.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -86,7 +87,7 @@ private unsafe void GetDBSIZE(int loadDbThreads)
{
var req = Encoding.ASCII.GetBytes("*1\r\n$6\r\nDBSIZE\r\n");
var lighClientOnResponseDelegate = new LightClient.OnResponseDelegateUnsafe(ReqGen.OnResponse);
using LightClient client = new(opts.Address, opts.Port, (int)OpType.DBSIZE, lighClientOnResponseDelegate, 128, opts.EnableTLS ? BenchUtils.GetTlsOptions(opts.TlsHost, opts.CertFileName, opts.CertPassword) : null);
using LightClient client = new(new IPEndPoint(IPAddress.Parse(opts.Address), opts.Port), (int)OpType.DBSIZE, lighClientOnResponseDelegate, 128, opts.EnableTLS ? BenchUtils.GetTlsOptions(opts.TlsHost, opts.CertFileName, opts.CertPassword) : null);

client.Connect();
client.Authenticate(opts.Auth);
Expand Down Expand Up @@ -373,7 +374,7 @@ public ReqGen LightOperate(
private unsafe void LightOperateThreadRunner(int NumOps, OpType opType, ReqGen rg)
{
var lighClientOnResponseDelegate = new LightClient.OnResponseDelegateUnsafe(ReqGen.OnResponse);
using ClientBase client = new LightClient(opts.Address, opts.Port, (int)opType, lighClientOnResponseDelegate, rg.GetBufferSize(), opts.EnableTLS ? BenchUtils.GetTlsOptions(opts.TlsHost, opts.CertFileName, opts.CertPassword) : null);
using ClientBase client = new LightClient(new IPEndPoint(IPAddress.Parse(opts.Address), opts.Port), (int)opType, lighClientOnResponseDelegate, rg.GetBufferSize(), opts.EnableTLS ? BenchUtils.GetTlsOptions(opts.TlsHost, opts.CertFileName, opts.CertPassword) : null);

client.Connect();
client.Authenticate(opts.Auth);
Expand Down Expand Up @@ -407,7 +408,7 @@ private void GarnetClientSessionOperateThreadRunner(int NumOps, OpType opType, R
default:
throw new Exception($"opType: {opType} benchmark not supported with GarnetClientSession!");
}
var c = new GarnetClientSession(opts.Address, opts.Port, new(), tlsOptions: opts.EnableTLS ? BenchUtils.GetTlsOptions(opts.TlsHost, opts.CertFileName, opts.CertPassword) : null);
var c = new GarnetClientSession(new IPEndPoint(IPAddress.Parse(opts.Address), opts.Port), new(), tlsOptions: opts.EnableTLS ? BenchUtils.GetTlsOptions(opts.TlsHost, opts.CertFileName, opts.CertPassword) : null);
c.Connect();
if (opts.Auth != null)
{
Expand Down
5 changes: 3 additions & 2 deletions benchmark/Resp.benchmark/TxnPerfBench.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Threading;
using Garnet.client;
using Garnet.common;
Expand Down Expand Up @@ -107,7 +108,7 @@ public void Run()
{
gcsPool = new AsyncPool<GarnetClientSession>(opts.NumThreads.First(), () =>
{
var c = new GarnetClientSession(address, port, new(), tlsOptions: opts.EnableTLS ? BenchUtils.GetTlsOptions(opts.TlsHost, opts.CertFileName, opts.CertPassword) : null);
var c = new GarnetClientSession(new IPEndPoint(IPAddress.Parse(address), port), new(), tlsOptions: opts.EnableTLS ? BenchUtils.GetTlsOptions(opts.TlsHost, opts.CertFileName, opts.CertPassword) : null);
c.Connect();
if (auth != null)
{
Expand Down Expand Up @@ -325,7 +326,7 @@ public void OpRunnerSERedis(int thread_id)
public void LoadData()
{
var req = new OnlineReqGen(0, opts.DbSize, true, opts.Zipf, opts.KeyLength, opts.ValueLength);
GarnetClientSession client = new(address, port, new(), tlsOptions: opts.EnableTLS ? BenchUtils.GetTlsOptions(opts.TlsHost, opts.CertFileName, opts.CertPassword) : null);
GarnetClientSession client = new(new IPEndPoint(IPAddress.Parse(address), port), new(), tlsOptions: opts.EnableTLS ? BenchUtils.GetTlsOptions(opts.TlsHost, opts.CertFileName, opts.CertPassword) : null);
client.Connect();
if (auth != null)
{
Expand Down
Loading