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

First implementation of new SI API #2

Open
wants to merge 48 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
3aa431d
First implementation of new SI API
TedHartMS Feb 17, 2021
97bcf90
Add I(Advanced)Functions.Lock/Unlock and minimize SI-related locking
TedHartMS Feb 19, 2021
1b10d64
some experimental stuff to test
TedHartMS Feb 21, 2021
d9db397
Experiment with SupportsLocks
TedHartMS Feb 21, 2021
c54018c
Change to new locking scheme; update test Functions to derive from Fu…
TedHartMS Feb 24, 2021
047e27d
Additional locking work:
TedHartMS Feb 25, 2021
85c54a4
Update YCSB benchmark to separate locking and indexing parameters and…
TedHartMS Feb 25, 2021
11c0289
updates
badrishc Feb 26, 2021
ac12836
Improvments to multi-iteration runs
TedHartMS Feb 26, 2021
2c94bd7
Remove FKV.SupportsMutableIndexes; change benchmark to resuse loaded …
TedHartMS Feb 27, 2021
e340da7
Benchmark: remove interface and make store, device, keys readonly
TedHartMS Feb 27, 2021
a094f81
distinct delimiter on last and trimmed stats summary
TedHartMS Feb 27, 2021
3b118b8
More YCSB benchmark updates:
TedHartMS Mar 1, 2021
ab625ac
Update benchmark to start in unison.
badrishc Mar 3, 2021
5ac4a8c
Refactor YCSB to clean up program.cs and duplicate LoadData and impro…
TedHartMS Mar 3, 2021
e6baec2
Fix UpdateSIForIPU return; fix latchDest in InternalRMW; tweak addres…
TedHartMS Mar 4, 2021
b922709
turn off smalldata for Release
TedHartMS Mar 4, 2021
1874a7c
YCSB changes:
TedHartMS Mar 5, 2021
eb59000
YCSB: change --backup to --recover and remove BackupMode; add --runsec
TedHartMS Mar 9, 2021
664e7dc
a few minor tweaks made while doing PRs
TedHartMS Mar 10, 2021
d15c6c6
Add Powershell scripts to run the benchmark performance suite and com…
TedHartMS Mar 17, 2021
3bb74ad
Merge upstream master
TedHartMS Mar 17, 2021
ef80838
updates to benchmark scripts
TedHartMS Mar 17, 2021
b12d4d6
Merge remote-tracking branch 'origin/master' into SecondaryIndex
TedHartMS Mar 27, 2021
2ce51aa
Add SubsetIndexSessionBroker; add SimpleIndex tests
TedHartMS Mar 28, 2021
c179dc8
Implement ReadOnlyObserver for SI; add Immutable and Mixed index test…
TedHartMS Mar 29, 2021
42619d7
Support multiple ReadOnly and Eviction Observers
TedHartMS Mar 31, 2021
25730b9
Merge upstream master
TedHartMS Apr 14, 2021
01220cf
more files from merge
TedHartMS Apr 14, 2021
e30da07
Merge remote-tracking branch 'origin/master' into SecondaryIndex
TedHartMS Apr 15, 2021
ab1c815
Add RecordId struct; move QueryRecord into SI from HVI; remove record…
TedHartMS Apr 16, 2021
8c88c1a
Add QueryRecord.RecordId
TedHartMS Apr 17, 2021
3b57ef1
RecordId changes from HVI
TedHartMS Apr 17, 2021
f024f3a
QueryRecord changes from HVI
TedHartMS Apr 18, 2021
074028b
Fixes to multi-observer cleanup; fix recordInfo setting in ReadAsyncI…
TedHartMS May 5, 2021
5bf46d9
merge upstream master
TedHartMS May 5, 2021
4458616
Modify Secondary Index interfaces:
TedHartMS May 5, 2021
881f4bd
Merge upstream master
TedHartMS May 26, 2021
32320de
Merge upstream master; backport from HVI branch
TedHartMS Jun 14, 2021
f6a9603
Merge remote-tracking branch 'origin/master' into SecondaryIndex
TedHartMS Jun 14, 2021
101aff6
allow deltaFileDevice == null
TedHartMS Jun 15, 2021
8a321d9
Additional changes for C#9
TedHartMS Jun 15, 2021
d380af8
Backport a few changes from HVI in preparation to merge master
TedHartMS Jul 21, 2021
5a40baa
Merge upstream master
TedHartMS Jul 21, 2021
a2a55ac
merge upstream master
TedHartMS Sep 24, 2021
7917538
add missing OnRecovery to InternalRecoverAsync
TedHartMS Sep 24, 2021
25f310f
Add default values for scanDelta, recoverTo args
TedHartMS Sep 24, 2021
c4b0781
backport mostly doc-related changes from HVI
TedHartMS Sep 29, 2021
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
5 changes: 5 additions & 0 deletions cs/benchmark/FasterSpanByteYcsbBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ internal FasterSpanByteYcsbBenchmark(KeySpanByte[] i_keys_, KeySpanByte[] t_keys
store = new FasterKV<SpanByte, SpanByte>
(testLoader.MaxKey / 2, new LogSettings { LogDevice = device, PreallocateLog = true, MemorySizeBits = 35 },
new CheckpointSettings { CheckPointType = CheckpointType.Snapshot, CheckpointDir = testLoader.BackupPath });

if (testLoader.SecondaryIndexType.HasFlag(SecondaryIndexType.Key))
store.SecondaryIndexBroker.AddIndex(new NullKeyIndex<Key>());
if (testLoader.SecondaryIndexType.HasFlag(SecondaryIndexType.Value))
store.SecondaryIndexBroker.AddIndex(new NullValueIndex<Key, Value>());
}

internal void Dispose()
Expand Down
5 changes: 5 additions & 0 deletions cs/benchmark/FasterYcsbBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ internal FASTER_YcsbBenchmark(Key[] i_keys_, Key[] t_keys_, TestLoader testLoade
store = new FasterKV<Key, Value>
(testLoader.MaxKey / 2, new LogSettings { LogDevice = device, PreallocateLog = true },
new CheckpointSettings { CheckPointType = CheckpointType.Snapshot, CheckpointDir = testLoader.BackupPath });

if (testLoader.SecondaryIndexType.HasFlag(SecondaryIndexType.Key))
store.SecondaryIndexBroker.AddIndex(new NullKeyIndex<Key>());
if (testLoader.SecondaryIndexType.HasFlag(SecondaryIndexType.Value))
store.SecondaryIndexBroker.AddIndex(new NullValueIndex<Key, Value>());
}

internal void Dispose()
Expand Down
10 changes: 9 additions & 1 deletion cs/benchmark/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ class Options
"\n 1 = RecordInfo.SpinLock()")]
public int LockImpl { get; set; }

[Option('x', "index", Required = false, Default = 0,
HelpText = "Secondary index type(s); these implement a no-op index to test the overhead on FasterKV operations:" +
"\n 0 = None (default)" +
"\n 1 = Key-based index" +
"\n 2 = Value-based index" +
"\n 3 = Both index types")]
public int SecondaryIndexType { get; set; }

[Option('i', "iterations", Required = false, Default = 1,
HelpText = "Number of iterations of the test to run")]
public int IterationCount { get; set; }
Expand Down Expand Up @@ -95,7 +103,7 @@ class Options
public string GetOptionsString()
{
static string boolStr(bool value) => value ? "y" : "n";
return $"d: {DistributionName.ToLower()}; n: {NumaStyle}; r: {ReadPercent}; t: {ThreadCount}; z: {LockImpl}; i: {IterationCount};"
return $"d: {DistributionName.ToLower()}; n: {NumaStyle}; r: {ReadPercent}; t: {ThreadCount}; x: {SecondaryIndexType}; z: {LockImpl}; i: {IterationCount};"
+ $" sd: {boolStr(UseSmallData)}; sm: {boolStr(UseSmallMemoryLog)}; sy: {boolStr(this.UseSyntheticData)}; noaff: {boolStr(this.NoThreadAffinity)};"
+ $" chkptms: {this.PeriodicCheckpointMilliseconds}; chkpttype: {(this.PeriodicCheckpointMilliseconds > 0 ? this.PeriodicCheckpointType.ToString() : "None")}; chkptincr: {boolStr(this.PeriodicCheckpointTryIncremental)}";
}
Expand Down
67 changes: 67 additions & 0 deletions cs/benchmark/SecondaryIndexes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using FASTER.core;
using System.Threading;
using System.Threading.Tasks;

namespace FASTER.benchmark
{
class NullKeyIndex<Key> : ISecondaryKeyIndex<Key>
{
public string Name => "KeyIndex";

public bool IsMutable => true;

public void SetSessionSlot(long slot) { }

public void Delete(ref Key key, RecordId recordId, SecondaryIndexSessionBroker indexSessionBroker) { }

public void Insert(ref Key key, RecordId recordId, SecondaryIndexSessionBroker indexSessionBroker) { }

public void Upsert(ref Key key, RecordId recordId, bool isMutableRecord, SecondaryIndexSessionBroker indexSessionBroker) { }

public void OnPrimaryTruncate(long newBeginAddress) { }

public void ScanReadOnlyPages<TScanValue>(IFasterScanIterator<Key, TScanValue> iter, SecondaryIndexSessionBroker indexSessionBroker) { }

public void OnPrimaryCheckpointInitiated(PrimaryCheckpointInfo recoveredPci) { }

public void OnPrimaryCheckpointCompleted(PrimaryCheckpointInfo primaryCheckpointInfo) { }

public PrimaryCheckpointInfo Recover(PrimaryCheckpointInfo recoveredPci, bool undoNextVersion) => default;

public Task<PrimaryCheckpointInfo> RecoverAsync(PrimaryCheckpointInfo recoveredPci, bool undoNextVersion, CancellationToken cancellationToken = default) => default;

public void RecoveryReplay<TScanValue>(IFasterScanIterator<Key, TScanValue> iter, SecondaryIndexSessionBroker indexSessionBroker) { }
}

class NullValueIndex<Key, Value> : ISecondaryValueIndex<Key, Value>
{
public string Name => "ValueIndex";

public bool IsMutable => true;

public void SetSessionSlot(long slot) { }

public void Delete(ref Key key, RecordId recordId, SecondaryIndexSessionBroker indexSessionBroker) { }

public void Insert(ref Key key, ref Value value, RecordId recordId, SecondaryIndexSessionBroker indexSessionBroker) { }

public void Upsert(ref Key key, ref Value value, RecordId recordId, bool isMutableRecord, SecondaryIndexSessionBroker indexSessionBroker) { }

public void OnPrimaryTruncate(long newBeginAddress) { }

public void ScanReadOnlyPages(IFasterScanIterator<Key, Value> iter, SecondaryIndexSessionBroker indexSessionBroker) { }

public void OnPrimaryCheckpointInitiated(PrimaryCheckpointInfo recoveredPci) { }

public void OnPrimaryCheckpointCompleted(PrimaryCheckpointInfo primaryCheckpointInfo) { }

public PrimaryCheckpointInfo Recover(PrimaryCheckpointInfo recoveredPci, bool undoNextVersion) => default;

public Task<PrimaryCheckpointInfo> RecoverAsync(PrimaryCheckpointInfo recoveredPci, bool undoNextVersion, CancellationToken cancellationToken = default) => default; // Not used for this class

public void RecoveryReplay(IFasterScanIterator<Key, Value> iter, SecondaryIndexSessionBroker indexSessionBroker) { }
}
}
8 changes: 7 additions & 1 deletion cs/benchmark/TestLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class TestLoader

internal BenchmarkType BenchmarkType;
internal LockImpl LockImpl;
internal SecondaryIndexType SecondaryIndexType;
internal string Distribution;

internal Key[] init_keys = default;
Expand Down Expand Up @@ -63,6 +64,10 @@ static bool verifyOption(bool isValid, string name)
if (!verifyOption(Enum.IsDefined(typeof(LockImpl), this.LockImpl), "Lock Implementation"))
return false;

this.SecondaryIndexType = (SecondaryIndexType)Options.SecondaryIndexType;
if (!verifyOption(Enum.IsDefined(typeof(SecondaryIndexType), this.SecondaryIndexType), "Secondary Index Type"))
return false;

if (!verifyOption(Options.IterationCount > 0, "Iteration Count"))
return false;

Expand All @@ -80,6 +85,7 @@ static bool verifyOption(bool isValid, string name)
this.TxnCount = this.Options.UseSmallData ? 10000000 : 1000000000;
this.MaxKey = this.Options.UseSmallData ? 1 << 22 : 1 << 28;

Console.WriteLine($"Scenario: {this.BenchmarkType}, Locking: {(LockImpl)Options.LockImpl}, Indexing: {(SecondaryIndexType)Options.SecondaryIndexType}");
return true;
}

Expand Down Expand Up @@ -355,7 +361,7 @@ internal bool MaybeRecoverStore<K, V>(FasterKV<K, V> store)
catch (Exception ex)
{
var suffix = Directory.Exists(this.BackupPath) ? "" : " (directory does not exist)";
Console.WriteLine($"Unable to recover prior store: {ex.Message}{suffix}");
Console.WriteLine($" Unable to recover prior store: {ex.Message}{suffix}");
}
}
return false;
Expand Down
10 changes: 10 additions & 0 deletions cs/benchmark/YcsbConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT license.

using FASTER.core;
using System;

namespace FASTER.benchmark
{
Expand All @@ -18,6 +19,15 @@ enum LockImpl : int
RecordInfo
};

[Flags]
enum SecondaryIndexType : int
{
None = 0,
Key = 1,
Value = 2,
Both = 3
};

enum AddressLineNum : int
{
Before = 1,
Expand Down
8 changes: 6 additions & 2 deletions cs/benchmark/scripts/compare_runs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ param (
)

class Result : System.IComparable, System.IEquatable[Object] {
# To make things work in one class, name the properties "Left", "Right", and "Diff"--they aren't displayed until the Diff is calculated.
# To make things work in one class, name the properties "Baseline", "Current", and "Diff"--they aren't displayed until the Diff is calculated.
[double]$BaselineMean
[double]$BaselineStdDev
[double]$CurrentMean
Expand All @@ -56,6 +56,7 @@ class Result : System.IComparable, System.IEquatable[Object] {
[string]$Distribution
[int]$ReadPercent
[uint]$ThreadCount
[uint]$IndexMode
[uint]$LockMode
[uint]$Iterations
[bool]$SmallData
Expand All @@ -80,6 +81,7 @@ class Result : System.IComparable, System.IEquatable[Object] {
"d" { $this.Distribution = $value }
"r" { $this.ReadPercent = $value }
"t" { $this.ThreadCount = $value }
"x" { $this.IndexMode = $value }
"z" { $this.LockMode = $value }
"i" { $this.Iterations = $value }
"sd" { $this.SmallData = $value -eq "y" }
Expand All @@ -98,6 +100,7 @@ class Result : System.IComparable, System.IEquatable[Object] {
$this.Distribution = $other.Distribution
$this.ReadPercent = $other.ReadPercent
$this.ThreadCount = $other.ThreadCount
$this.IndexMode = $other.IndexMode
$this.LockMode = $other.LockMode
$this.Iterations = $other.Iterations
$this.SmallData = $other.SmallData
Expand Down Expand Up @@ -165,6 +168,7 @@ class Result : System.IComparable, System.IEquatable[Object] {
-and $this.Distribution -eq $other.Distribution
-and $this.ReadPercent -eq $other.ReadPercent
-and $this.ThreadCount -eq $other.ThreadCount
-and $this.IndexMode -eq $other.IndexMode
-and $this.LockMode -eq $other.LockMode
-and $this.Iterations -eq $other.Iterations
-and $this.SmallData -eq $other.SmallData
Expand All @@ -177,7 +181,7 @@ class Result : System.IComparable, System.IEquatable[Object] {
}

[int] GetHashCode() {
return ($this.Numa, $this.Distribution, $this.ReadPercent, $this.ThreadCount, $this.LockMode,
return ($this.Numa, $this.Distribution, $this.ReadPercent, $this.ThreadCount, $this.IndexMode, $this.LockMode,
$this.Iterations, $this.SmallData, $this.SmallMemory, $this.SyntheticData,
$this.NoAff, $this.ChkptMs, $this.ChkptType, $this.ChkptIncr).GetHashCode();
}
Expand Down
44 changes: 28 additions & 16 deletions cs/benchmark/scripts/run_benchmark.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
Number of threads to use.
Used primarily to debug changes to this script or do a quick one-off run; the default is multiple counts as defined in the script.

.PARAMETER IndexMode
Indexing mode to use: 0 = None, 1 = Key, 2 = Value, 3 = both.
Used primarily to debug changes to this script or do a quick one-off run; the default is multiple counts as defined in the script.

.PARAMETER LockMode
Locking mode to use: 0 = No locking, 1 = RecordInfo locking
Used primarily to debug changes to this script or do a quick one-off run; the default is multiple counts as defined in the script.
Expand Down Expand Up @@ -83,6 +87,7 @@ param (
[Parameter(Mandatory=$true)] [string[]]$ExeDirs,
[Parameter(Mandatory=$false)] [int]$RunSeconds = 30,
[Parameter(Mandatory=$false)] [int]$ThreadCount = -1,
[Parameter(Mandatory=$false)] [int]$IndexMode = -1,
[Parameter(Mandatory=$false)] [int]$LockMode = -1,
[Parameter(Mandatory=$false)] [int[]]$ReadPercentages,
[Parameter(Mandatory=$false)] [switch]$UseRecover,
Expand Down Expand Up @@ -132,6 +137,7 @@ $iterations = 7
$distributions = ("uniform", "zipf")
$readPercents = (0, 100)
$threadCounts = (1, 20, 40, 60, 80)
$indexModes = (0, 1, 2) #, 3)
$lockModes = (0, 1)
$smallDatas = (0) #, 1)
$smallMemories = (0) #, 1)
Expand All @@ -141,6 +147,9 @@ $k = ""
if ($ThreadCount -ge 0) {
$threadCounts = ($ThreadCount)
}
if ($IndexMode -ge 0) {
$indexModes = ($IndexMode)
}
if ($LockMode -ge 0) {
$lockModes = ($LockMode)
}
Expand All @@ -155,6 +164,7 @@ if ($UseRecover) {
$permutations = $distributions.Count *
$readPercents.Count *
$threadCounts.Count *
$indexModes.Count *
$lockModes.Count *
$smallDatas.Count *
$smallMemories.Count *
Expand All @@ -164,27 +174,29 @@ $permutation = 1
foreach ($d in $distributions) {
foreach ($r in $readPercents) {
foreach ($t in $threadCounts) {
foreach ($z in $lockModes) {
foreach ($sd in $smallDatas) {
foreach ($sm in $smallMemories) {
foreach ($sy in $syntheticDatas) {
Write-Host
Write-Host "Permutation $permutation of $permutations"
foreach ($x in $indexModes) {
foreach ($z in $lockModes) {
foreach ($sd in $smallDatas) {
foreach ($sm in $smallMemories) {
foreach ($sy in $syntheticDatas) {
Write-Host
Write-Host "Permutation $permutation of $permutations"

# Only certain combinations of Numa/Threads are supported
$n = ($t -lt 48) ? 0 : 1;
# Only certain combinations of Numa/Threads are supported
$n = ($t -lt 48) ? 0 : 1;

for($ii = 0; $ii -lt $exeNames.Count; ++$ii) {
$exeName = $exeNames[$ii]
$resultDir = $resultDirs[$ii]
for($ii = 0; $ii -lt $exeNames.Count; ++$ii) {
$exeName = $exeNames[$ii]
$resultDir = $resultDirs[$ii]

Write-Host
Write-Host "Permutation $permutation/$permutations generating results $($ii + 1)/$($exeNames.Count) to $resultDir for: -n $n -d $d -r $r -t $t -z $z -i $iterations --runsec $RunSeconds $k"
Write-Host
Write-Host "Permutation $permutation/$permutations generating results $($ii + 1)/$($exeNames.Count) to $resultDir for: -n $n -d $d -r $r -t $t -z $z -i $iterations --runsec $RunSeconds $k"

# RunSec and Recover are for one-off operations and are not recorded in the filenames.
& "$exeName" -b 0 -n $n -d $d -r $r -t $t -z $z -i $iterations --runsec $RunSeconds $k | Tee-Object "$resultDir/results_n-$($n)_d-$($d)_r-$($r)_t-$($t)_z-$($z).txt"
# RunSec and Recover are for one-off operations and are not recorded in the filenames.
& "$exeName" -b 0 -n $n -d $d -r $r -t $t -x $x -z $z -i $iterations --runsec $RunSeconds $k | Tee-Object "$resultDir/results_n-$($n)_d-$($d)_r-$($r)_t-$($t)_x-$($x)_z-$($z).txt"
}
++$permutation
}
++$permutation
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion cs/samples/ReadAddress/Types.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class Functions : AdvancedSimpleFunctions<Key, Value, Context>
// Track the recordInfo for its PreviousAddress.
public override void ReadCompletionCallback(ref Key key, ref Value input, ref Value output, Context ctx, Status status, RecordInfo recordInfo)
{
if (!(ctx is null))
if (ctx is not null)
{
ctx.recordInfo = recordInfo;
ctx.status = status;
Expand Down
Loading