Skip to content

Commit

Permalink
add redis-timeseries
Browse files Browse the repository at this point in the history
Signed-off-by: Jalal Mostafa <[email protected]>
  • Loading branch information
jalalmostafa committed Aug 27, 2024
1 parent 884ec29 commit 34b9758
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 11 deletions.
3 changes: 2 additions & 1 deletion BenchmarkTool/BenchmarkTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>preview</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
5 changes: 5 additions & 0 deletions BenchmarkTool/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,5 +324,10 @@ public static int GetRedisPort()
{
return GetInt(ConfigurationKeys.RedisPort);
}

internal static int GetRedisConnectionsPerWorker()
{
return GetInt(ConfigurationKeys.RedisConnectionsPerWorker);
}
}
}
1 change: 1 addition & 0 deletions BenchmarkTool/ConfigurationKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ static class ConfigurationKeys
public const string GlancesNIC = "GlancesNIC";
public const string RedisHost = "RedisHost";
public const string RedisPort = "RedisPort";
public const string RedisConnectionsPerWorker = "RedisConnectionPerWorkers";
}
}
7 changes: 5 additions & 2 deletions BenchmarkTool/Database/RedisTimeSeriesDB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace BenchmarkTool.Database
{
public class RedisTimeSeriesDB : IDatabase
{
private static bool _initialized = false;
private static volatile bool _initialized = false;

private static ConnectionMultiplexer _connection;
private SERedis.IDatabase _redisDB;
Expand All @@ -44,7 +44,10 @@ public void Close()
try
{
if (_connection != null)
_connection.Close();
{
_connection.Dispose();
_connection = null;
}
}
catch (Exception ex)
{
Expand Down
24 changes: 16 additions & 8 deletions Scripts/rdmabench.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
#! /bin/python3
import pandas as pd
import numpy as np
import os
import sys

def clean_results(file):
if not os.path.exists(file):
print(f'{file} does not exist!')
return pd.DataFrame()
results = pd.read_csv(file)
results['Date'] = pd.to_datetime(results['Date'], unit='ns')
results = results.sort_values(by=['TargetDatabase', 'Date'])
return results.set_index('Date')

def set_type(file, typ):
results = clean_results(file)
results['Type'] = typ
return results

def ingestion_rate(rmetrics='./Metrics-rdma.csv', metrics='./Metrics-sock.csv'):
def ingestion_rate(path='.', rmetrics='Metrics-rdma.csv', metrics='Metrics-sock.csv'):

def group_ingestion_rate(group):
dates = group.index
Expand All @@ -21,14 +30,13 @@ def group_ingestion_rate(group):
lat_sum = group['Latency'].sum() / 1e3
return pd.Series({ 'IngestionRateAll': all_values / time, 'TotalTime': time, 'TotalPoints': all_values, 'IngestionRateMean': group['IngestionRatePoint'].mean(), 'IngestionRateBySum': all_values / lat_sum })

rdma_results = clean_results(rmetrics)
rdma_results['Type'] = 'RDMA'
sock_results = clean_results(metrics)
sock_results['Type'] = 'SOCK'

rdma_results = set_type(f'{path}/{rmetrics}', 'RDMA')
sock_results = set_type(f'{path}/{metrics}', 'SOCK')
results = pd.concat([rdma_results, sock_results])
return results.groupby('Type').apply(group_ingestion_rate)
if len(results) == 0:
return pd.Series()
return results.groupby(['Type', 'ClientsNumber']).apply(group_ingestion_rate)

if __name__ == '__main__':
dfs = ingestion_rate()
dfs = ingestion_rate(path=os.path.abspath(sys.argv[1] if len(sys.argv) > 1 else '.'))
print(dfs.to_markdown())

0 comments on commit 34b9758

Please sign in to comment.