Skip to content

Commit 32d04e6

Browse files
authored
[C#] Replace LockingMode with ConcurrencyControlMode (#867)
* Replace LockingMode with ConcurrencyControlMode * Fix 'Remote' solution build
1 parent 4d5412b commit 32d04e6

38 files changed

+165
-165
lines changed

cs/benchmark/FasterSpanByteYcsbBenchmark.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ internal FasterSpanByteYcsbBenchmark(KeySpanByte[] i_keys_, KeySpanByte[] t_keys
8080
if (testLoader.Options.UseSmallMemoryLog)
8181
store = new FasterKV<SpanByte, SpanByte>
8282
(testLoader.MaxKey / testLoader.Options.HashPacking, new LogSettings { LogDevice = device, PreallocateLog = true, PageSizeBits = 22, SegmentSizeBits = 26, MemorySizeBits = 26 },
83-
new CheckpointSettings { CheckpointDir = testLoader.BackupPath }, lockingMode: testLoader.LockingMode);
83+
new CheckpointSettings { CheckpointDir = testLoader.BackupPath }, concurrencyControlMode: testLoader.ConcurrencyControlMode);
8484
else
8585
store = new FasterKV<SpanByte, SpanByte>
8686
(testLoader.MaxKey / testLoader.Options.HashPacking, new LogSettings { LogDevice = device, PreallocateLog = true, MemorySizeBits = 35 },
87-
new CheckpointSettings { CheckpointDir = testLoader.BackupPath }, lockingMode: testLoader.LockingMode);
87+
new CheckpointSettings { CheckpointDir = testLoader.BackupPath }, concurrencyControlMode: testLoader.ConcurrencyControlMode);
8888
}
8989

9090
internal void Dispose()

cs/benchmark/FasterYcsbBenchmark.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ internal FASTER_YcsbBenchmark(Key[] i_keys_, Key[] t_keys_, TestLoader testLoade
8080
if (testLoader.Options.UseSmallMemoryLog)
8181
store = new FasterKV<Key, Value>
8282
(testLoader.MaxKey / testLoader.Options.HashPacking, new LogSettings { LogDevice = device, PreallocateLog = true, PageSizeBits = 25, SegmentSizeBits = 30, MemorySizeBits = 28 },
83-
new CheckpointSettings { CheckpointDir = testLoader.BackupPath }, lockingMode: testLoader.LockingMode);
83+
new CheckpointSettings { CheckpointDir = testLoader.BackupPath }, concurrencyControlMode: testLoader.ConcurrencyControlMode);
8484
else
8585
store = new FasterKV<Key, Value>
8686
(testLoader.MaxKey / testLoader.Options.HashPacking, new LogSettings { LogDevice = device, PreallocateLog = true },
87-
new CheckpointSettings { CheckpointDir = testLoader.BackupPath }, lockingMode: testLoader.LockingMode);
87+
new CheckpointSettings { CheckpointDir = testLoader.BackupPath }, concurrencyControlMode: testLoader.ConcurrencyControlMode);
8888
}
8989

9090
internal void Dispose()

cs/benchmark/Options.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class Options
3636
[Option('z', "locking", Required = false, Default = 0,
3737
HelpText = "Locking Implementation:" +
3838
"\n 0 = None (default)" +
39-
"\n 1 = Mixed-mode locking using main HashTable buckets")]
40-
public int LockingMode { get; set; }
39+
"\n 1 = LockTable using main HashTable buckets")]
40+
public int ConcurrencyControlMode { get; set; }
4141

4242
[Option('i', "iterations", Required = false, Default = 1,
4343
HelpText = "Number of iterations of the test to run")]
@@ -100,7 +100,7 @@ class Options
100100
public string GetOptionsString()
101101
{
102102
static string boolStr(bool value) => value ? "y" : "n";
103-
return $"d: {DistributionName.ToLower()}; n: {NumaStyle}; rumd: {string.Join(',', RumdPercents)}; t: {ThreadCount}; z: {LockingMode}; i: {IterationCount}; hp: {HashPacking}"
103+
return $"d: {DistributionName.ToLower()}; n: {NumaStyle}; rumd: {string.Join(',', RumdPercents)}; t: {ThreadCount}; z: {ConcurrencyControlMode}; i: {IterationCount}; hp: {HashPacking}"
104104
+ $" sd: {boolStr(UseSmallData)}; sm: {boolStr(UseSmallMemoryLog)}; sy: {boolStr(this.UseSyntheticData)}; safectx: {boolStr(this.UseSafeContext)};"
105105
+ $" chkptms: {this.PeriodicCheckpointMilliseconds}; chkpttype: {(this.PeriodicCheckpointMilliseconds > 0 ? this.PeriodicCheckpointType.ToString() : "None")};"
106106
+ $" chkptincr: {boolStr(this.PeriodicCheckpointTryIncremental)}";

cs/benchmark/TestLoader.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class TestLoader
2828
internal KeySpanByte[] txn_span_keys = default;
2929

3030
internal readonly BenchmarkType BenchmarkType;
31-
internal readonly LockingMode LockingMode;
31+
internal readonly ConcurrencyControlMode ConcurrencyControlMode;
3232
internal readonly long InitCount;
3333
internal readonly long TxnCount;
3434
internal readonly int MaxKey;
@@ -61,13 +61,13 @@ static bool verifyOption(bool isValid, string name, string info = null)
6161
if (!verifyOption(Options.NumaStyle >= 0 && Options.NumaStyle <= 1, "NumaStyle"))
6262
return;
6363

64-
this.LockingMode = Options.LockingMode switch
64+
this.ConcurrencyControlMode = Options.ConcurrencyControlMode switch
6565
{
66-
0 => LockingMode.None,
67-
1 => LockingMode.Standard,
68-
_ => throw new InvalidOperationException($"Unknown Locking mode int: {Options.LockingMode}")
66+
0 => ConcurrencyControlMode.None,
67+
1 => ConcurrencyControlMode.LockTable,
68+
_ => throw new InvalidOperationException($"Unknown Locking mode int: {Options.ConcurrencyControlMode}")
6969
};
70-
if (!verifyOption(Enum.IsDefined(typeof(LockingMode), this.LockingMode), "LockingMode"))
70+
if (!verifyOption(Enum.IsDefined(typeof(ConcurrencyControlMode), this.ConcurrencyControlMode), "ConcurrencyControlMode"))
7171
return;
7272

7373
if (!verifyOption(Options.IterationCount > 0, "Iteration Count"))

cs/remote/samples/FixedLenServer/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static void Main(string[] args)
3939
builder.SetMinimumLevel(LogLevel.Error);
4040
});
4141

42-
using var server = new FixedLenServer<Key, Value, Input, Output, Functions>(opts.GetServerOptions(), () => new Functions(), lockingMode: LockingMode.Standard);
42+
using var server = new FixedLenServer<Key, Value, Input, Output, Functions>(opts.GetServerOptions(), () => new Functions(), concurrencyControlMode: ConcurrencyControlMode.LockTable);
4343
server.Start();
4444
Console.WriteLine("Started server");
4545

cs/remote/src/FASTER.server/Servers/FixedLenServer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ public sealed class FixedLenServer<Key, Value, Input, Output, Functions> : Gener
2323
/// </summary>
2424
/// <param name="opts"></param>
2525
/// <param name="functionsGen"></param>
26-
/// <param name="lockingMode"></param>
26+
/// <param name="concurrencyControlMode"></param>
2727
/// <param name="maxSizeSettings"></param>
2828
/// <param name="loggerFactory"></param>
29-
public FixedLenServer(ServerOptions opts, Func<Functions> functionsGen, LockingMode lockingMode, MaxSizeSettings maxSizeSettings = default, ILoggerFactory loggerFactory = null)
30-
: base(opts, functionsGen, new FixedLenSerializer<Key, Value, Input, Output>(), new FixedLenKeySerializer<Key, Input>(), lockingMode: lockingMode, maxSizeSettings, loggerFactory)
29+
public FixedLenServer(ServerOptions opts, Func<Functions> functionsGen, ConcurrencyControlMode concurrencyControlMode, MaxSizeSettings maxSizeSettings = default, ILoggerFactory loggerFactory = null)
30+
: base(opts, functionsGen, new FixedLenSerializer<Key, Value, Input, Output>(), new FixedLenKeySerializer<Key, Input>(), concurrencyControlMode: concurrencyControlMode, maxSizeSettings, loggerFactory)
3131
{
3232
}
3333
}

cs/remote/src/FASTER.server/Servers/GenericServer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ public class GenericServer<Key, Value, Input, Output, Functions, ParameterSerial
3131
/// <param name="functionsGen"></param>
3232
/// <param name="serializer"></param>
3333
/// <param name="keyInputSerializer"></param>
34-
/// <param name="lockingMode"></param>
34+
/// <param name="concurrencyControlMode"></param>
3535
/// <param name="maxSizeSettings"></param>
3636
/// <param name="loggerFactory"></param>
37-
public GenericServer(ServerOptions opts, Func<Functions> functionsGen, ParameterSerializer serializer, IKeyInputSerializer<Key, Input> keyInputSerializer,
38-
LockingMode lockingMode, MaxSizeSettings maxSizeSettings = default, ILoggerFactory loggerFactory = null)
37+
public GenericServer(ServerOptions opts, Func<Functions> functionsGen, ParameterSerializer serializer, IKeyInputSerializer<Key, Input> keyInputSerializer,
38+
ConcurrencyControlMode concurrencyControlMode, MaxSizeSettings maxSizeSettings = default, ILoggerFactory loggerFactory = null)
3939
{
4040
this.opts = opts;
4141

@@ -45,7 +45,7 @@ public GenericServer(ServerOptions opts, Func<Functions> functionsGen, Parameter
4545
if (!Directory.Exists(opts.CheckpointDir))
4646
Directory.CreateDirectory(opts.CheckpointDir);
4747

48-
store = new FasterKV<Key, Value>(indexSize, logSettings, checkpointSettings, lockingMode: lockingMode, loggerFactory: loggerFactory);
48+
store = new FasterKV<Key, Value>(indexSize, logSettings, checkpointSettings, concurrencyControlMode: concurrencyControlMode, loggerFactory: loggerFactory);
4949

5050
if (opts.Recover)
5151
{

cs/remote/src/FASTER.server/Servers/VarLenServer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public VarLenServer(ServerOptions opts, ILoggerFactory loggerFactory = null)
3737
if (!Directory.Exists(opts.CheckpointDir))
3838
Directory.CreateDirectory(opts.CheckpointDir);
3939

40-
store = new FasterKV<SpanByte, SpanByte>(indexSize, logSettings, checkpointSettings, lockingMode: LockingMode.Standard, loggerFactory: loggerFactory);
40+
store = new FasterKV<SpanByte, SpanByte>(indexSize, logSettings, checkpointSettings, concurrencyControlMode: ConcurrencyControlMode.LockTable, loggerFactory: loggerFactory);
4141

4242
if (!opts.DisablePubSub)
4343
{

cs/remote/test/FASTER.remote.test/TestUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static FixedLenServer<long, long, long, long, SimpleFunctions<long, long,
3434
Recover = tryRecover,
3535
IndexSize = "1m",
3636
};
37-
return new FixedLenServer<long, long, long, long, SimpleFunctions<long, long, long>>(opts, () => new SimpleFunctions<long, long, long>(merger), lockingMode: LockingMode.Standard);
37+
return new FixedLenServer<long, long, long, long, SimpleFunctions<long, long, long>>(opts, () => new SimpleFunctions<long, long, long>(merger), concurrencyControlMode: ConcurrencyControlMode.LockTable);
3838
}
3939

4040
/// <summary>

cs/samples/StoreVarLenTypes/AsciiSumSample.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static void Run()
2828
// For this test we require record-level locking
2929
using var store = new FasterKV<SpanByte, SpanByte>(
3030
size: 1L << 20,
31-
logSettings: new LogSettings { LogDevice = log, MemorySizeBits = 15, PageSizeBits = 12 }, lockingMode: LockingMode.Standard);
31+
logSettings: new LogSettings { LogDevice = log, MemorySizeBits = 15, PageSizeBits = 12 }, concurrencyControlMode: ConcurrencyControlMode.LockTable);
3232

3333
// Create session for ASCII sums. We require two callback function types to be provided:
3434
// AsciiSumSpanByteFunctions implements RMW callback functions

0 commit comments

Comments
 (0)