Skip to content

Commit

Permalink
[C#] Test suite for remote FASTER (microsoft#458)
Browse files Browse the repository at this point in the history
* Initial checkin of test suite for remote

* updated configs.

* fix sln

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update 50-remote-basics.md

* Update 50-remote-basics.md
  • Loading branch information
badrishc authored Apr 28, 2021
1 parent dde8943 commit 7fb595b
Show file tree
Hide file tree
Showing 7 changed files with 249 additions and 4 deletions.
11 changes: 11 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
variables:
solution: 'cs/FASTER.sln'
solutionRemote: 'cs/remote/FASTER.remote.sln'
RunAzureTests: 'yes'

jobs:
Expand Down Expand Up @@ -38,6 +39,16 @@ jobs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'

- task: NuGetCommand@2
inputs:
restoreSolution: '$(solutionRemote)'

- task: VSBuild@1
inputs:
solution: '$(solutionRemote)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'

- powershell: 'Invoke-WebRequest -OutFile azure-storage-emulator.msi -Uri "https://go.microsoft.com/fwlink/?LinkId=717179&clcid=0x409"'
displayName: 'Download Azure Storage Emulator'

Expand Down
13 changes: 13 additions & 0 deletions cs/remote/FASTER.remote.sln
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FixedLenServer", "samples\F
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FASTER.core", "..\src\core\FASTER.core.csproj", "{6A49ADD2-DC25-47E1-9D29-5DC6380E880A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{8CF11B91-A6B6-4B81-AD43-2B07CF60F8FF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FASTER.remote.test", "test\FASTER.remote.test\FASTER.remote.test.csproj", "{2238A430-8D61-40A3-A23B-B1163A4CCBC6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -111,6 +115,14 @@ Global
{6A49ADD2-DC25-47E1-9D29-5DC6380E880A}.Release|Any CPU.Build.0 = Release|Any CPU
{6A49ADD2-DC25-47E1-9D29-5DC6380E880A}.Release|x64.ActiveCfg = Release|x64
{6A49ADD2-DC25-47E1-9D29-5DC6380E880A}.Release|x64.Build.0 = Release|x64
{2238A430-8D61-40A3-A23B-B1163A4CCBC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2238A430-8D61-40A3-A23B-B1163A4CCBC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2238A430-8D61-40A3-A23B-B1163A4CCBC6}.Debug|x64.ActiveCfg = Debug|x64
{2238A430-8D61-40A3-A23B-B1163A4CCBC6}.Debug|x64.Build.0 = Debug|x64
{2238A430-8D61-40A3-A23B-B1163A4CCBC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2238A430-8D61-40A3-A23B-B1163A4CCBC6}.Release|Any CPU.Build.0 = Release|Any CPU
{2238A430-8D61-40A3-A23B-B1163A4CCBC6}.Release|x64.ActiveCfg = Release|x64
{2238A430-8D61-40A3-A23B-B1163A4CCBC6}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -125,6 +137,7 @@ Global
{0C52406C-09B3-47B9-BF85-B6490926DB73} = {1065AE7E-DEA5-4E21-AE39-95B93C074B17}
{4053EC35-77A5-4728-B16F-F4FDD1104CAF} = {1065AE7E-DEA5-4E21-AE39-95B93C074B17}
{6A49ADD2-DC25-47E1-9D29-5DC6380E880A} = {6B8D1038-C9D5-4111-B5CE-BF64E7D12AE1}
{2238A430-8D61-40A3-A23B-B1163A4CCBC6} = {8CF11B91-A6B6-4B81-AD43-2B07CF60F8FF}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FB603D60-F72D-4DAD-9349-442A45E20276}
Expand Down
55 changes: 55 additions & 0 deletions cs/remote/test/FASTER.remote.test/FASTER.remote.test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1;net461</TargetFrameworks>
<Platforms>AnyCPU;x64</Platforms>
<HighEntropyVA>true</HighEntropyVA>
<LangVersion>8</LangVersion>
</PropertyGroup>

<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<RootNamespace>FASTER.remote.test</RootNamespace>
<AssemblyName>FASTER.remote.test</AssemblyName>
<ErrorReport>prompt</ErrorReport>
<SignAssembly>true</SignAssembly>
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />
<AssemblyOriginatorKeyFile>../../../FASTER.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<DocumentationFile>bin\$(Platform)\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DebugType>full</DebugType>
<OutputPath>bin\$(Platform)\Debug\</OutputPath>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<DefineConstants>TRACE</DefineConstants>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\$(Platform)\Release\</OutputPath>
</PropertyGroup>

<PropertyGroup>
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\core\FASTER.core.csproj" />
<ProjectReference Include="..\..\src\FASTER.client\FASTER.client.csproj" />
<ProjectReference Include="..\..\src\FASTER.server\FASTER.server.csproj" />
</ItemGroup>
</Project>
45 changes: 45 additions & 0 deletions cs/remote/test/FASTER.remote.test/FixedLenBinaryTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using NUnit.Framework;
using FASTER.client;

namespace FASTER.remote.test
{
[TestFixture]
public class FixedLenBinaryTests
{
FixedLenServer<long, long> server;
FixedLenClient<long, long> client;
ClientSession<long, long, long, long, long, FixedLenClientFunctions, FixedLenSerializer<long, long, long, long>> session;

[SetUp]
public void Setup()
{
server = new FixedLenServer<long, long>(TestContext.CurrentContext.TestDirectory + "/FixedLenBinaryTests", (a, b) => a + b);
client = new FixedLenClient<long, long>();
session = client.GetSession();
}

[TearDown]
public void TearDown()
{
session.Dispose();
client.Dispose();
server.Dispose();
}

[Test]
public void UpsertReadTest()
{
session.Upsert(10, 23);
session.CompletePending();
session.Read(10, userContext: 23);
session.CompletePending();
session.RMW(20, 23);
session.RMW(20, 23);
session.RMW(20, 23);
session.CompletePending();
session.Read(20, userContext: 23 * 3);
session.CompletePending();
}
}
}
39 changes: 39 additions & 0 deletions cs/remote/test/FASTER.remote.test/FixedLenClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using FASTER.client;
using NUnit.Framework;
using System;

namespace FASTER.remote.test
{
class FixedLenClient<Key, Value> : IDisposable
where Key : unmanaged
where Value : unmanaged

{
readonly FasterKVClient<long, long> client;

public FixedLenClient(string address = "127.0.0.1", int port = 33278)
{
client = new FasterKVClient<long, long>(address, port);
}

public void Dispose()
{
client.Dispose();
}

public ClientSession<long, long, long, long, long, FixedLenClientFunctions, FixedLenSerializer<long, long, long, long>> GetSession()
=> client.NewSession<long, long, long, FixedLenClientFunctions, FixedLenSerializer<long, long, long, long>>(new FixedLenClientFunctions());
}

/// <summary>
/// Callback functions
/// </summary>
sealed class FixedLenClientFunctions : CallbackFunctionsBase<long, long, long, long, long>
{
public override void ReadCompletionCallback(ref long key, ref long input, ref long output, long ctx, Status status)
{
Assert.IsTrue(status == Status.OK);
Assert.IsTrue(output == ctx);
}
}
}
66 changes: 66 additions & 0 deletions cs/remote/test/FASTER.remote.test/FixedLenServer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using FASTER.core;
using FASTER.server;
using System;
using System.IO;

namespace FASTER.remote.test
{
class FixedLenServer<Key, Value> : IDisposable
where Key : unmanaged
where Value : unmanaged
{
readonly string folderName;
readonly FasterKVServer<Key, Value, Value, Value, FixedLenServerFunctions<Key, Value>, FixedLenSerializer<Key, Value, Value, Value>> server;

public FixedLenServer(string folderName, Func<Value, Value, Value> merger, string address = "127.0.0.1", int port = 33278)
{
this.folderName = folderName;
GetSettings(folderName, out var logSettings, out var checkpointSettings, out var indexSize);

// We use blittable structs Key and Value to construct a costomized server for fixed-length types
var store = new FasterKV<Key, Value>(indexSize, logSettings, checkpointSettings);

// We specify FixedLenSerializer as our in-built serializer for blittable (fixed length) types
// This server can be used with compatible clients such as FixedLenClient and FASTER.benchmark
server = new FasterKVServer<Key, Value, Value, Value, FixedLenServerFunctions<Key, Value>, FixedLenSerializer<Key, Value, Value, Value>>
(store, e => new FixedLenServerFunctions<Key, Value>(merger), address, port);
server.Start();
}

public void Dispose()
{
server.Dispose();
new DirectoryInfo(folderName).Delete(true);
}

private void GetSettings(string LogDir, out LogSettings logSettings, out CheckpointSettings checkpointSettings, out int indexSize)
{
logSettings = new LogSettings { PreallocateLog = false };

logSettings.PageSizeBits = 20;
logSettings.MemorySizeBits = 25;
logSettings.SegmentSizeBits = 30;
indexSize = 1 << 20;

var device = LogDir == "" ? new NullDevice() : Devices.CreateLogDevice(LogDir + "/hlog", preallocateFile: false);
logSettings.LogDevice = device;

string CheckpointDir = null;
if (CheckpointDir == null && LogDir == null)
checkpointSettings = null;
else
checkpointSettings = new CheckpointSettings
{
CheckPointType = CheckpointType.FoldOver,
CheckpointDir = CheckpointDir ?? (LogDir + "/checkpoints")
};
}
}

sealed class FixedLenServerFunctions<Key, Value> : SimpleFunctions<Key, Value, long>
{
public FixedLenServerFunctions(Func<Value, Value, Value> merger) : base(merger)
{
}
}
}
24 changes: 20 additions & 4 deletions docs/_docs/50-remote-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,30 @@ therefore instantiate a `FixedLenServer` and run the YCSB benchmark to communica
code is available at
[cs/remote/benchmark/FASTER.benchmark](https://github.com/microsoft/FASTER/tree/master/cs/remote/benchmark/FASTER.benchmark).
The benchmark takes several command-line parameters, similar to our embedded FasterKV benchmark, but including extra
necessary information such as server IP address and port. Here is a sample run that runs the benchark with one session (`-t 1`),
no NUMA sharding (`-n 0`), 50% reads (`-r 50`), uniform distribution (`-d uniform`), connecting to IP address 127.0.0.1
on port 3278 (`-i 127.0.0.1 -p 3278`). Make sure `FixedLenServer` is first listening on the same address and port.
necessary information such as server IP address and port.

Make sure `FixedLenServer` is first listening on the same address and port, and has been
instantiated with a sufficiently large hash table (8GB):

```
FixedLenServer -i 8g
```

Below is a sample benchmark run that runs the benchark with 8 sessions (`-t 8`), 50% reads (`-r 50`), Zipf
distribution (`-d zipf`), connecting to IP address 127.0.0.1 on port 3278 (`-i 127.0.0.1 -p 3278`).

```
FASTER.benchmark -b 0 -t 1 -n 0 -r 50 -d uniform -i 127.0.0.1 -p 3278
FASTER.benchmark -b 0 -t 8 -r 50 -d zipf -i 127.0.0.1 -p 3278
```

Since the server is now loaded with data, you can re-run the benchmark without the setup (loading) phase using the
`-s` option, as follows:

```
FASTER.benchmark -b 0 -t 8 -r 50 -d zipf -i 127.0.0.1 -p 3278 -s
```


## Variable-Length Server and Client

A more realistic and complex scenario is one where we want to store variable-length keys and values in FASTER, similar to
Expand Down

0 comments on commit 7fb595b

Please sign in to comment.