From 32d04e65633e0ad495b6e1292b93b084c68053f7 Mon Sep 17 00:00:00 2001 From: Ted Hart <15467143+TedHartMS@users.noreply.github.com> Date: Fri, 25 Aug 2023 14:28:33 -0700 Subject: [PATCH] [C#] Replace LockingMode with ConcurrencyControlMode (#867) * Replace LockingMode with ConcurrencyControlMode * Fix 'Remote' solution build --- cs/benchmark/FasterSpanByteYcsbBenchmark.cs | 4 +- cs/benchmark/FasterYcsbBenchmark.cs | 4 +- cs/benchmark/Options.cs | 6 +- cs/benchmark/TestLoader.cs | 12 +-- cs/remote/samples/FixedLenServer/Program.cs | 2 +- .../FASTER.server/Servers/FixedLenServer.cs | 6 +- .../FASTER.server/Servers/GenericServer.cs | 8 +- .../src/FASTER.server/Servers/VarLenServer.cs | 2 +- .../test/FASTER.remote.test/TestUtils.cs | 2 +- cs/samples/StoreVarLenTypes/AsciiSumSample.cs | 2 +- cs/src/core/ClientSession/ClientSession.cs | 4 +- cs/src/core/ClientSession/ILockableContext.cs | 2 +- cs/src/core/Index/Common/FasterKVSettings.cs | 4 +- cs/src/core/Index/FASTER/FASTER.cs | 12 +-- cs/src/core/Index/FASTER/FASTERIterator.cs | 2 +- .../Locking/OverflowBucketLockTable.cs | 6 +- cs/src/core/Utilities/LockType.cs | 10 +- cs/test/AdvancedLockTests.cs | 10 +- cs/test/BasicLockTests.cs | 2 +- cs/test/BlittableIterationTests.cs | 6 +- cs/test/BlittableLogCompactionTests.cs | 20 ++-- cs/test/BlittableLogScanTests.cs | 2 +- cs/test/DisposeTests.cs | 28 +++--- cs/test/EphemeralLockingTests.cs | 2 +- cs/test/GenericDiskDeleteTests.cs | 2 +- cs/test/GenericIterationTests.cs | 14 +-- cs/test/GenericLogScanTests.cs | 4 +- cs/test/LockableUnsafeContextTests.cs | 2 +- cs/test/MiscFASTERTests.cs | 4 +- cs/test/ModifiedBitTests.cs | 2 +- cs/test/OverflowBucketLockTableTests.cs | 2 +- cs/test/ReadAddressTests.cs | 92 +++++++++---------- cs/test/ReadCacheChainTests.cs | 30 +++--- cs/test/RecoveryChecks.cs | 2 +- cs/test/ReproReadCacheTest.cs | 10 +- cs/test/SpanByteLogScanTests.cs | 2 +- cs/test/VarLenBlittableIterationTests.cs | 4 +- cs/test/VariableLengthIteratorTests.cs | 2 +- 38 files changed, 165 insertions(+), 165 deletions(-) diff --git a/cs/benchmark/FasterSpanByteYcsbBenchmark.cs b/cs/benchmark/FasterSpanByteYcsbBenchmark.cs index 6287becd3..79921f1d1 100644 --- a/cs/benchmark/FasterSpanByteYcsbBenchmark.cs +++ b/cs/benchmark/FasterSpanByteYcsbBenchmark.cs @@ -80,11 +80,11 @@ internal FasterSpanByteYcsbBenchmark(KeySpanByte[] i_keys_, KeySpanByte[] t_keys if (testLoader.Options.UseSmallMemoryLog) store = new FasterKV (testLoader.MaxKey / testLoader.Options.HashPacking, new LogSettings { LogDevice = device, PreallocateLog = true, PageSizeBits = 22, SegmentSizeBits = 26, MemorySizeBits = 26 }, - new CheckpointSettings { CheckpointDir = testLoader.BackupPath }, lockingMode: testLoader.LockingMode); + new CheckpointSettings { CheckpointDir = testLoader.BackupPath }, concurrencyControlMode: testLoader.ConcurrencyControlMode); else store = new FasterKV (testLoader.MaxKey / testLoader.Options.HashPacking, new LogSettings { LogDevice = device, PreallocateLog = true, MemorySizeBits = 35 }, - new CheckpointSettings { CheckpointDir = testLoader.BackupPath }, lockingMode: testLoader.LockingMode); + new CheckpointSettings { CheckpointDir = testLoader.BackupPath }, concurrencyControlMode: testLoader.ConcurrencyControlMode); } internal void Dispose() diff --git a/cs/benchmark/FasterYcsbBenchmark.cs b/cs/benchmark/FasterYcsbBenchmark.cs index 4fa679087..9643bac17 100644 --- a/cs/benchmark/FasterYcsbBenchmark.cs +++ b/cs/benchmark/FasterYcsbBenchmark.cs @@ -80,11 +80,11 @@ internal FASTER_YcsbBenchmark(Key[] i_keys_, Key[] t_keys_, TestLoader testLoade if (testLoader.Options.UseSmallMemoryLog) store = new FasterKV (testLoader.MaxKey / testLoader.Options.HashPacking, new LogSettings { LogDevice = device, PreallocateLog = true, PageSizeBits = 25, SegmentSizeBits = 30, MemorySizeBits = 28 }, - new CheckpointSettings { CheckpointDir = testLoader.BackupPath }, lockingMode: testLoader.LockingMode); + new CheckpointSettings { CheckpointDir = testLoader.BackupPath }, concurrencyControlMode: testLoader.ConcurrencyControlMode); else store = new FasterKV (testLoader.MaxKey / testLoader.Options.HashPacking, new LogSettings { LogDevice = device, PreallocateLog = true }, - new CheckpointSettings { CheckpointDir = testLoader.BackupPath }, lockingMode: testLoader.LockingMode); + new CheckpointSettings { CheckpointDir = testLoader.BackupPath }, concurrencyControlMode: testLoader.ConcurrencyControlMode); } internal void Dispose() diff --git a/cs/benchmark/Options.cs b/cs/benchmark/Options.cs index 013edd6f0..99ba2c0d2 100644 --- a/cs/benchmark/Options.cs +++ b/cs/benchmark/Options.cs @@ -36,8 +36,8 @@ class Options [Option('z', "locking", Required = false, Default = 0, HelpText = "Locking Implementation:" + "\n 0 = None (default)" + - "\n 1 = Mixed-mode locking using main HashTable buckets")] - public int LockingMode { get; set; } + "\n 1 = LockTable using main HashTable buckets")] + public int ConcurrencyControlMode { get; set; } [Option('i', "iterations", Required = false, Default = 1, HelpText = "Number of iterations of the test to run")] @@ -100,7 +100,7 @@ class Options public string GetOptionsString() { static string boolStr(bool value) => value ? "y" : "n"; - return $"d: {DistributionName.ToLower()}; n: {NumaStyle}; rumd: {string.Join(',', RumdPercents)}; t: {ThreadCount}; z: {LockingMode}; i: {IterationCount}; hp: {HashPacking}" + return $"d: {DistributionName.ToLower()}; n: {NumaStyle}; rumd: {string.Join(',', RumdPercents)}; t: {ThreadCount}; z: {ConcurrencyControlMode}; i: {IterationCount}; hp: {HashPacking}" + $" sd: {boolStr(UseSmallData)}; sm: {boolStr(UseSmallMemoryLog)}; sy: {boolStr(this.UseSyntheticData)}; safectx: {boolStr(this.UseSafeContext)};" + $" chkptms: {this.PeriodicCheckpointMilliseconds}; chkpttype: {(this.PeriodicCheckpointMilliseconds > 0 ? this.PeriodicCheckpointType.ToString() : "None")};" + $" chkptincr: {boolStr(this.PeriodicCheckpointTryIncremental)}"; diff --git a/cs/benchmark/TestLoader.cs b/cs/benchmark/TestLoader.cs index 419d5dfa8..e7f6ae266 100644 --- a/cs/benchmark/TestLoader.cs +++ b/cs/benchmark/TestLoader.cs @@ -28,7 +28,7 @@ class TestLoader internal KeySpanByte[] txn_span_keys = default; internal readonly BenchmarkType BenchmarkType; - internal readonly LockingMode LockingMode; + internal readonly ConcurrencyControlMode ConcurrencyControlMode; internal readonly long InitCount; internal readonly long TxnCount; internal readonly int MaxKey; @@ -61,13 +61,13 @@ static bool verifyOption(bool isValid, string name, string info = null) if (!verifyOption(Options.NumaStyle >= 0 && Options.NumaStyle <= 1, "NumaStyle")) return; - this.LockingMode = Options.LockingMode switch + this.ConcurrencyControlMode = Options.ConcurrencyControlMode switch { - 0 => LockingMode.None, - 1 => LockingMode.Standard, - _ => throw new InvalidOperationException($"Unknown Locking mode int: {Options.LockingMode}") + 0 => ConcurrencyControlMode.None, + 1 => ConcurrencyControlMode.LockTable, + _ => throw new InvalidOperationException($"Unknown Locking mode int: {Options.ConcurrencyControlMode}") }; - if (!verifyOption(Enum.IsDefined(typeof(LockingMode), this.LockingMode), "LockingMode")) + if (!verifyOption(Enum.IsDefined(typeof(ConcurrencyControlMode), this.ConcurrencyControlMode), "ConcurrencyControlMode")) return; if (!verifyOption(Options.IterationCount > 0, "Iteration Count")) diff --git a/cs/remote/samples/FixedLenServer/Program.cs b/cs/remote/samples/FixedLenServer/Program.cs index 727dc8e7d..ec6d976bb 100644 --- a/cs/remote/samples/FixedLenServer/Program.cs +++ b/cs/remote/samples/FixedLenServer/Program.cs @@ -39,7 +39,7 @@ static void Main(string[] args) builder.SetMinimumLevel(LogLevel.Error); }); - using var server = new FixedLenServer(opts.GetServerOptions(), () => new Functions(), lockingMode: LockingMode.Standard); + using var server = new FixedLenServer(opts.GetServerOptions(), () => new Functions(), concurrencyControlMode: ConcurrencyControlMode.LockTable); server.Start(); Console.WriteLine("Started server"); diff --git a/cs/remote/src/FASTER.server/Servers/FixedLenServer.cs b/cs/remote/src/FASTER.server/Servers/FixedLenServer.cs index e535b8dac..f8001e04e 100644 --- a/cs/remote/src/FASTER.server/Servers/FixedLenServer.cs +++ b/cs/remote/src/FASTER.server/Servers/FixedLenServer.cs @@ -23,11 +23,11 @@ public sealed class FixedLenServer : Gener /// /// /// - /// + /// /// /// - public FixedLenServer(ServerOptions opts, Func functionsGen, LockingMode lockingMode, MaxSizeSettings maxSizeSettings = default, ILoggerFactory loggerFactory = null) - : base(opts, functionsGen, new FixedLenSerializer(), new FixedLenKeySerializer(), lockingMode: lockingMode, maxSizeSettings, loggerFactory) + public FixedLenServer(ServerOptions opts, Func functionsGen, ConcurrencyControlMode concurrencyControlMode, MaxSizeSettings maxSizeSettings = default, ILoggerFactory loggerFactory = null) + : base(opts, functionsGen, new FixedLenSerializer(), new FixedLenKeySerializer(), concurrencyControlMode: concurrencyControlMode, maxSizeSettings, loggerFactory) { } } diff --git a/cs/remote/src/FASTER.server/Servers/GenericServer.cs b/cs/remote/src/FASTER.server/Servers/GenericServer.cs index 89bfb6207..5c6acccdc 100644 --- a/cs/remote/src/FASTER.server/Servers/GenericServer.cs +++ b/cs/remote/src/FASTER.server/Servers/GenericServer.cs @@ -31,11 +31,11 @@ public class GenericServer /// /// - /// + /// /// /// - public GenericServer(ServerOptions opts, Func functionsGen, ParameterSerializer serializer, IKeyInputSerializer keyInputSerializer, - LockingMode lockingMode, MaxSizeSettings maxSizeSettings = default, ILoggerFactory loggerFactory = null) + public GenericServer(ServerOptions opts, Func functionsGen, ParameterSerializer serializer, IKeyInputSerializer keyInputSerializer, + ConcurrencyControlMode concurrencyControlMode, MaxSizeSettings maxSizeSettings = default, ILoggerFactory loggerFactory = null) { this.opts = opts; @@ -45,7 +45,7 @@ public GenericServer(ServerOptions opts, Func functionsGen, Parameter if (!Directory.Exists(opts.CheckpointDir)) Directory.CreateDirectory(opts.CheckpointDir); - store = new FasterKV(indexSize, logSettings, checkpointSettings, lockingMode: lockingMode, loggerFactory: loggerFactory); + store = new FasterKV(indexSize, logSettings, checkpointSettings, concurrencyControlMode: concurrencyControlMode, loggerFactory: loggerFactory); if (opts.Recover) { diff --git a/cs/remote/src/FASTER.server/Servers/VarLenServer.cs b/cs/remote/src/FASTER.server/Servers/VarLenServer.cs index 2c12b374c..b85a1fe0a 100644 --- a/cs/remote/src/FASTER.server/Servers/VarLenServer.cs +++ b/cs/remote/src/FASTER.server/Servers/VarLenServer.cs @@ -37,7 +37,7 @@ public VarLenServer(ServerOptions opts, ILoggerFactory loggerFactory = null) if (!Directory.Exists(opts.CheckpointDir)) Directory.CreateDirectory(opts.CheckpointDir); - store = new FasterKV(indexSize, logSettings, checkpointSettings, lockingMode: LockingMode.Standard, loggerFactory: loggerFactory); + store = new FasterKV(indexSize, logSettings, checkpointSettings, concurrencyControlMode: ConcurrencyControlMode.LockTable, loggerFactory: loggerFactory); if (!opts.DisablePubSub) { diff --git a/cs/remote/test/FASTER.remote.test/TestUtils.cs b/cs/remote/test/FASTER.remote.test/TestUtils.cs index de8126a63..e20bbb381 100644 --- a/cs/remote/test/FASTER.remote.test/TestUtils.cs +++ b/cs/remote/test/FASTER.remote.test/TestUtils.cs @@ -34,7 +34,7 @@ public static FixedLenServer>(opts, () => new SimpleFunctions(merger), lockingMode: LockingMode.Standard); + return new FixedLenServer>(opts, () => new SimpleFunctions(merger), concurrencyControlMode: ConcurrencyControlMode.LockTable); } /// diff --git a/cs/samples/StoreVarLenTypes/AsciiSumSample.cs b/cs/samples/StoreVarLenTypes/AsciiSumSample.cs index 31788e995..fc83993f4 100644 --- a/cs/samples/StoreVarLenTypes/AsciiSumSample.cs +++ b/cs/samples/StoreVarLenTypes/AsciiSumSample.cs @@ -28,7 +28,7 @@ public static void Run() // For this test we require record-level locking using var store = new FasterKV( size: 1L << 20, - logSettings: new LogSettings { LogDevice = log, MemorySizeBits = 15, PageSizeBits = 12 }, lockingMode: LockingMode.Standard); + logSettings: new LogSettings { LogDevice = log, MemorySizeBits = 15, PageSizeBits = 12 }, concurrencyControlMode: ConcurrencyControlMode.LockTable); // Create session for ASCII sums. We require two callback function types to be provided: // AsciiSumSpanByteFunctions implements RMW callback functions diff --git a/cs/src/core/ClientSession/ClientSession.cs b/cs/src/core/ClientSession/ClientSession.cs index 9121b3382..78015abef 100644 --- a/cs/src/core/ClientSession/ClientSession.cs +++ b/cs/src/core/ClientSession/ClientSession.cs @@ -241,7 +241,7 @@ public LockableUnsafeContext Lock get { if (!this.fht.LockTable.IsEnabled) - throw new FasterException($"LockableUnsafeContext requires {nameof(LockingMode.Standard)}"); + throw new FasterException($"LockableUnsafeContext requires {nameof(ConcurrencyControlMode.LockTable)}"); return luContext; } } @@ -254,7 +254,7 @@ public LockableContext LockableCo get { if (!this.fht.LockTable.IsEnabled) - throw new FasterException($"LockableContext requires {nameof(LockingMode.Standard)}"); + throw new FasterException($"LockableContext requires {nameof(ConcurrencyControlMode.LockTable)}"); return lContext; } } diff --git a/cs/src/core/ClientSession/ILockableContext.cs b/cs/src/core/ClientSession/ILockableContext.cs index 87b0a606e..d1cf76789 100644 --- a/cs/src/core/ClientSession/ILockableContext.cs +++ b/cs/src/core/ClientSession/ILockableContext.cs @@ -25,7 +25,7 @@ public interface ILockableContext /// /// If true, then keys must use one of the overloads to obtain a code by which groups of keys will be sorted for manual locking, to avoid deadlocks. /// - /// Whether this returns true depends on the on , or passed to the FasterKV constructor. + /// Whether this returns true depends on the on , or passed to the FasterKV constructor. bool NeedKeyHash { get; } /// diff --git a/cs/src/core/Index/Common/FasterKVSettings.cs b/cs/src/core/Index/Common/FasterKVSettings.cs index 9940f86d4..0a01bc931 100644 --- a/cs/src/core/Index/Common/FasterKVSettings.cs +++ b/cs/src/core/Index/Common/FasterKVSettings.cs @@ -24,7 +24,7 @@ public sealed class FasterKVSettings : IDisposable /// /// How FASTER should do record locking /// - public LockingMode LockingMode; + public ConcurrencyControlMode ConcurrencyControlMode; /// /// Device used for main hybrid log @@ -199,7 +199,7 @@ public override string ToString() var retStr = $"index: {Utility.PrettySize(IndexSize)}; log memory: {Utility.PrettySize(MemorySize)}; log page: {Utility.PrettySize(PageSize)}; log segment: {Utility.PrettySize(SegmentSize)}"; retStr += $"; log device: {(LogDevice == null ? "null" : LogDevice.GetType().Name)}"; retStr += $"; obj log device: {(ObjectLogDevice == null ? "null" : ObjectLogDevice.GetType().Name)}"; - retStr += $"; mutable fraction: {MutableFraction}; locking mode: {this.LockingMode}"; + retStr += $"; mutable fraction: {MutableFraction}; locking mode: {this.ConcurrencyControlMode}"; retStr += $"; read cache (rc): {(ReadCacheEnabled ? "yes" : "no")}"; retStr += $"; read copy options: {ReadCopyOptions}"; if (ReadCacheEnabled) diff --git a/cs/src/core/Index/FASTER/FASTER.cs b/cs/src/core/Index/FASTER/FASTER.cs index 8d6c5f13a..849ed36dc 100644 --- a/cs/src/core/Index/FASTER/FASTER.cs +++ b/cs/src/core/Index/FASTER/FASTER.cs @@ -87,7 +87,7 @@ public FasterKV(FasterKVSettings fasterKVSettings) : fasterKVSettings.GetIndexSizeCacheLines(), fasterKVSettings.GetLogSettings(), fasterKVSettings.GetCheckpointSettings(), fasterKVSettings.GetSerializerSettings(), fasterKVSettings.EqualityComparer, fasterKVSettings.GetVariableLengthStructSettings(), - fasterKVSettings.TryRecoverLatest, fasterKVSettings.LockingMode, null, fasterKVSettings.logger) + fasterKVSettings.TryRecoverLatest, fasterKVSettings.ConcurrencyControlMode, null, fasterKVSettings.logger) { } /// @@ -100,14 +100,14 @@ public FasterKV(FasterKVSettings fasterKVSettings) : /// FASTER equality comparer for key /// /// Try to recover from latest checkpoint, if any - /// How FASTER should do record locking + /// How FASTER should do record locking /// Logger factory to create an ILogger, if one is not passed in (e.g. from ). /// Logger to use. /// Number of buckets in the lock table public FasterKV(long size, LogSettings logSettings, CheckpointSettings checkpointSettings = null, SerializerSettings serializerSettings = null, IFasterEqualityComparer comparer = null, - VariableLengthStructSettings variableLengthStructSettings = null, bool tryRecoverLatest = false, LockingMode lockingMode = LockingMode.Standard, + VariableLengthStructSettings variableLengthStructSettings = null, bool tryRecoverLatest = false, ConcurrencyControlMode concurrencyControlMode = ConcurrencyControlMode.LockTable, ILoggerFactory loggerFactory = null, ILogger logger = null, int lockTableSize = Constants.kDefaultLockTableSize) { this.loggerFactory = loggerFactory; @@ -134,8 +134,8 @@ public FasterKV(long size, LogSettings logSettings, } } - this.DoTransientLocking = lockingMode == LockingMode.Standard; - this.DoEphemeralLocking = lockingMode == LockingMode.Ephemeral; + this.DoTransientLocking = concurrencyControlMode == ConcurrencyControlMode.LockTable; + this.DoEphemeralLocking = concurrencyControlMode == ConcurrencyControlMode.RecordIsolation; if (checkpointSettings is null) checkpointSettings = new CheckpointSettings(); @@ -238,7 +238,7 @@ public FasterKV(long size, LogSettings logSettings, sectorSize = (int)logSettings.LogDevice.SectorSize; Initialize(size, sectorSize); - this.LockTable = new OverflowBucketLockTable(lockingMode == LockingMode.Standard ? this : null); + this.LockTable = new OverflowBucketLockTable(concurrencyControlMode == ConcurrencyControlMode.LockTable ? this : null); systemState = SystemState.Make(Phase.REST, 1); diff --git a/cs/src/core/Index/FASTER/FASTERIterator.cs b/cs/src/core/Index/FASTER/FASTERIterator.cs index ff86e4df6..823de9451 100644 --- a/cs/src/core/Index/FASTER/FASTERIterator.cs +++ b/cs/src/core/Index/FASTER/FASTERIterator.cs @@ -104,7 +104,7 @@ public FasterKVIterator(FasterKV fht, Functions functions, long unti } tempKv = new FasterKV(fht.IndexSize, new LogSettings { LogDevice = new NullDevice(), ObjectLogDevice = new NullDevice(), MutableFraction = 1 }, comparer: fht.Comparer, - variableLengthStructSettings: variableLengthStructSettings, loggerFactory: loggerFactory, lockingMode: LockingMode.None); + variableLengthStructSettings: variableLengthStructSettings, loggerFactory: loggerFactory, concurrencyControlMode: ConcurrencyControlMode.None); tempKvSession = tempKv.NewSession(functions); mainKvIter = fht.Log.Scan(fht.Log.BeginAddress, untilAddress); pushScanIterator = mainKvIter as IPushScanIterator; diff --git a/cs/src/core/Index/FASTER/Implementation/Locking/OverflowBucketLockTable.cs b/cs/src/core/Index/FASTER/Implementation/Locking/OverflowBucketLockTable.cs index 516617429..afb9c3eb3 100644 --- a/cs/src/core/Index/FASTER/Implementation/Locking/OverflowBucketLockTable.cs +++ b/cs/src/core/Index/FASTER/Implementation/Locking/OverflowBucketLockTable.cs @@ -19,13 +19,13 @@ internal struct OverflowBucketLockTable : ILockTable internal OverflowBucketLockTable(FasterKV f) => this.fht = f; [Conditional("DEBUG")] - void AssertLockAllowed() => Debug.Assert(IsEnabled, $"Attempt to do Manual-locking lock when locking mode is not {LockingMode.Standard}"); + void AssertLockAllowed() => Debug.Assert(IsEnabled, $"Attempt to do Manual-locking lock when locking mode is not {ConcurrencyControlMode.LockTable}"); [Conditional("DEBUG")] - void AssertUnlockAllowed() => Debug.Assert(IsEnabled, $"Attempt to do Manual-locking unlock when locking mode is not {LockingMode.Standard}"); + void AssertUnlockAllowed() => Debug.Assert(IsEnabled, $"Attempt to do Manual-locking unlock when locking mode is not {ConcurrencyControlMode.LockTable}"); [Conditional("DEBUG")] - void AssertQueryAllowed() => Debug.Assert(IsEnabled, $"Attempt to do Manual-locking query when locking mode is not {LockingMode.Standard}"); + void AssertQueryAllowed() => Debug.Assert(IsEnabled, $"Attempt to do Manual-locking query when locking mode is not {ConcurrencyControlMode.LockTable}"); internal long GetSize() => fht.state[fht.resizeInfo.version].size_mask; diff --git a/cs/src/core/Utilities/LockType.cs b/cs/src/core/Utilities/LockType.cs index 488bef285..fba83a2be 100644 --- a/cs/src/core/Utilities/LockType.cs +++ b/cs/src/core/Utilities/LockType.cs @@ -27,17 +27,17 @@ public enum LockType : byte /// /// How FASTER should do record locking /// - public enum LockingMode : byte + public enum ConcurrencyControlMode : byte { /// - /// Keys are locked based upon the session type, using hash buckets, and support manual locking. + /// Keys are locked using a LockTable. Currently the implementation latches the hash index buckets. Supports manual and transient locking, based on the session type. /// - Standard, + LockTable, /// - /// Keys are locked only for the duration of a concurrent IFunctions call (one that operates on data in the mutable region of the log). + /// Records are locked only for the duration of a concurrent IFunctions call (one that operates on data in the mutable region of the log), using the RecordInfo header. /// - Ephemeral, + RecordIsolation, /// /// Locking is not done in FASTER. diff --git a/cs/test/AdvancedLockTests.cs b/cs/test/AdvancedLockTests.cs index c121f77cb..e53d1265e 100644 --- a/cs/test/AdvancedLockTests.cs +++ b/cs/test/AdvancedLockTests.cs @@ -101,18 +101,18 @@ public void Setup() log = Devices.CreateLogDevice(MethodTestDir + "/GenericStringTests.log", deleteOnClose: true); var readCacheSettings = new ReadCacheSettings { MemorySizeBits = 15, PageSizeBits = 9 }; - var lockingMode = LockingMode.None; + var concurrencyControlMode = ConcurrencyControlMode.None; foreach (var arg in TestContext.CurrentContext.Test.Arguments) { - if (arg is LockingMode lm) + if (arg is ConcurrencyControlMode lm) { - lockingMode = lm; + concurrencyControlMode = lm; continue; } } fkv = new FasterKV(1L << 20, new LogSettings { LogDevice = log, ObjectLogDevice = null, ReadCacheSettings = readCacheSettings }, - comparer: new ChainComparer(mod), lockingMode: lockingMode); + comparer: new ChainComparer(mod), concurrencyControlMode: concurrencyControlMode); session = fkv.For(new Functions()).NewSession(); } @@ -144,7 +144,7 @@ void Populate(bool evict = false) [Category(FasterKVTestCategory)] [Category(LockTestCategory)] //[Repeat(100)] - public async ValueTask SameKeyInsertAndCTTTest([Values(LockingMode.None, LockingMode.Ephemeral /* Standard will hang */)] LockingMode lockingMode, + public async ValueTask SameKeyInsertAndCTTTest([Values(ConcurrencyControlMode.None, ConcurrencyControlMode.RecordIsolation /* Standard will hang */)] ConcurrencyControlMode concurrencyControlMode, [Values(ReadCopyTo.ReadCache, ReadCopyTo.MainLog)] ReadCopyTo readCopyTo) { if (TestContext.CurrentContext.CurrentRepeatCount > 0) diff --git a/cs/test/BasicLockTests.cs b/cs/test/BasicLockTests.cs index 308c5c689..627125887 100644 --- a/cs/test/BasicLockTests.cs +++ b/cs/test/BasicLockTests.cs @@ -82,7 +82,7 @@ public void Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); log = Devices.CreateLogDevice(TestUtils.MethodTestDir + "/GenericStringTests.log", deleteOnClose: true); - fkv = new FasterKV(1L << 20, new LogSettings { LogDevice = log, ObjectLogDevice = null }, comparer: new LocalComparer(), lockingMode: LockingMode.Ephemeral); + fkv = new FasterKV(1L << 20, new LogSettings { LogDevice = log, ObjectLogDevice = null }, comparer: new LocalComparer(), concurrencyControlMode: ConcurrencyControlMode.RecordIsolation); session = fkv.For(new Functions()).NewSession(); } diff --git a/cs/test/BlittableIterationTests.cs b/cs/test/BlittableIterationTests.cs index f47e70906..a9c965d07 100644 --- a/cs/test/BlittableIterationTests.cs +++ b/cs/test/BlittableIterationTests.cs @@ -64,7 +64,7 @@ public void BlittableIterationBasicTest([Values] DeviceType deviceType, [Values] log = CreateTestDevice(deviceType, $"{path}{deviceType}.log"); fht = new FasterKV (1L << 20, new LogSettings { LogDevice = log, MemorySizeBits = 15, PageSizeBits = 9, SegmentSizeBits = 22 }, - lockingMode: scanIteratorType == ScanIteratorType.Pull ? LockingMode.None : LockingMode.Standard); + concurrencyControlMode: scanIteratorType == ScanIteratorType.Pull ? ConcurrencyControlMode.None : ConcurrencyControlMode.LockTable); using var session = fht.For(new FunctionsCompaction()).NewSession(); BlittablePushIterationTestFunctions scanIteratorFunctions = new(); @@ -181,13 +181,13 @@ void scanAndVerify(int stopAt, bool useScan) [Test] [Category(FasterKVTestCategory)] [Category(SmokeTestCategory)] - public unsafe void BlittableIterationPushLockTest([Values(1, 4)] int scanThreads, [Values(1, 4)] int updateThreads, [Values] LockingMode lockingMode, [Values] ScanMode scanMode) + public unsafe void BlittableIterationPushLockTest([Values(1, 4)] int scanThreads, [Values(1, 4)] int updateThreads, [Values] ConcurrencyControlMode concurrencyControlMode, [Values] ScanMode scanMode) { log = Devices.CreateLogDevice($"{path}lock_test.log"); fht = new FasterKV(1L << 20, // Must be large enough to contain all records in memory to exercise locking new LogSettings { LogDevice = log, MemorySizeBits = 25, PageSizeBits = 20, SegmentSizeBits = 22 }, - lockingMode: lockingMode); + concurrencyControlMode: concurrencyControlMode); const int totalRecords = 2000; var start = fht.Log.TailAddress; diff --git a/cs/test/BlittableLogCompactionTests.cs b/cs/test/BlittableLogCompactionTests.cs index 76bd5287e..adc356b87 100644 --- a/cs/test/BlittableLogCompactionTests.cs +++ b/cs/test/BlittableLogCompactionTests.cs @@ -39,13 +39,13 @@ public void Setup() TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait:true); log = Devices.CreateLogDevice(TestUtils.MethodTestDir + "/BlittableLogCompactionTests.log", deleteOnClose: true); - var lockingMode = LockingMode.Standard; + var concurrencyControlMode = ConcurrencyControlMode.LockTable; var hashMod = HashModulo.NoMod; foreach (var arg in TestContext.CurrentContext.Test.Arguments) { - if (arg is LockingMode locking_mode) + if (arg is ConcurrencyControlMode locking_mode) { - lockingMode = locking_mode; + concurrencyControlMode = locking_mode; continue; } if (arg is HashModulo mod) @@ -56,7 +56,7 @@ public void Setup() } fht = new FasterKV - (1L << 20, new LogSettings { LogDevice = log, MemorySizeBits = 15, PageSizeBits = 9 }, comparer: new HashModuloComparer(hashMod), lockingMode: lockingMode);; + (1L << 20, new LogSettings { LogDevice = log, MemorySizeBits = 15, PageSizeBits = 9 }, comparer: new HashModuloComparer(hashMod), concurrencyControlMode: concurrencyControlMode);; } [TearDown] @@ -125,7 +125,7 @@ void drainPending() [Category("Compaction")] [Category("Smoke")] - public void BlittableLogCompactionTest1([Values] CompactionType compactionType, [Values(LockingMode.Standard)] LockingMode lockingMode) + public void BlittableLogCompactionTest1([Values] CompactionType compactionType, [Values(ConcurrencyControlMode.LockTable)] ConcurrencyControlMode concurrencyControlMode) { using var session = fht.For(new FunctionsCompaction()).NewSession(); @@ -156,7 +156,7 @@ public void BlittableLogCompactionTest1([Values] CompactionType compactionType, [Test] [Category("FasterKV")] [Category("Compaction")] - public void BlittableLogCompactionTest2([Values] CompactionType compactionType, [Values(LockingMode.Standard)] LockingMode lockingMode, + public void BlittableLogCompactionTest2([Values] CompactionType compactionType, [Values(ConcurrencyControlMode.LockTable)] ConcurrencyControlMode concurrencyControlMode, [Values(HashModulo.NoMod, HashModulo.Hundred)] HashModulo hashMod) { using var session = fht.For(new FunctionsCompaction()).NewSession(); @@ -204,7 +204,7 @@ public void BlittableLogCompactionTest2([Values] CompactionType compactionType, [Test] [Category("FasterKV")] [Category("Compaction")] - public void BlittableLogCompactionTest3([Values] CompactionType compactionType, [Values(LockingMode.Standard)] LockingMode lockingMode) + public void BlittableLogCompactionTest3([Values] CompactionType compactionType, [Values(ConcurrencyControlMode.LockTable)] ConcurrencyControlMode concurrencyControlMode) { using var session = fht.For(new FunctionsCompaction()).NewSession(); @@ -243,7 +243,7 @@ public void BlittableLogCompactionTest3([Values] CompactionType compactionType, [Category("Compaction")] [Category("Smoke")] - public void BlittableLogCompactionCustomFunctionsTest1([Values] CompactionType compactionType, [Values(LockingMode.Standard)] LockingMode lockingMode) + public void BlittableLogCompactionCustomFunctionsTest1([Values] CompactionType compactionType, [Values(ConcurrencyControlMode.LockTable)] ConcurrencyControlMode concurrencyControlMode) { using var session = fht.For(new FunctionsCompaction()).NewSession(); @@ -302,9 +302,9 @@ public void BlittableLogCompactionCustomFunctionsTest1([Values] CompactionType c [Test] [Category("FasterKV")] [Category("Compaction")] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "lockingMode is used by Setup")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "concurrencyControlMode is used by Setup")] public void BlittableLogCompactionCustomFunctionsTest2([Values] CompactionType compactionType, [Values]bool flushAndEvict, - [Values(LockingMode.Standard)] LockingMode lockingMode) + [Values(ConcurrencyControlMode.LockTable)] ConcurrencyControlMode concurrencyControlMode) { // Update: irrelevant as session compaction no longer uses Copy/CopyInPlace // This test checks if CopyInPlace returning false triggers call to Copy diff --git a/cs/test/BlittableLogScanTests.cs b/cs/test/BlittableLogScanTests.cs index 78209b709..663ac78bc 100644 --- a/cs/test/BlittableLogScanTests.cs +++ b/cs/test/BlittableLogScanTests.cs @@ -21,7 +21,7 @@ public void Setup() DeleteDirectory(MethodTestDir, wait:true); log = Devices.CreateLogDevice(MethodTestDir + "/test.log", deleteOnClose: true); fht = new FasterKV - (1L << 20, new LogSettings { LogDevice = log, MemorySizeBits = 15, PageSizeBits = 9 }, lockingMode: LockingMode.None); + (1L << 20, new LogSettings { LogDevice = log, MemorySizeBits = 15, PageSizeBits = 9 }, concurrencyControlMode: ConcurrencyControlMode.None); } [TearDown] diff --git a/cs/test/DisposeTests.cs b/cs/test/DisposeTests.cs index 3de2dc012..589eac172 100644 --- a/cs/test/DisposeTests.cs +++ b/cs/test/DisposeTests.cs @@ -38,7 +38,7 @@ public void Setup() objlog = Devices.CreateLogDevice(MethodTestDir + "/ObjectFASTERTests.obj.log", deleteOnClose: true); LogSettings logSettings = new () { LogDevice = log, ObjectLogDevice = objlog, MutableFraction = 0.1, MemorySizeBits = 15, PageSizeBits = 10 }; - var lockingMode = LockingMode.None; + var concurrencyControlMode = ConcurrencyControlMode.None; foreach (var arg in TestContext.CurrentContext.Test.Arguments) { if (arg is ReadCopyDestination dest) @@ -47,16 +47,16 @@ public void Setup() logSettings.ReadCacheSettings = new() { PageSizeBits = 12, MemorySizeBits = 22 }; continue; } - if (arg is LockingMode lm) + if (arg is ConcurrencyControlMode lm) { - lockingMode = lm; + concurrencyControlMode = lm; continue; } } fht = new FasterKV(128, logSettings: logSettings, comparer: new MyKeyComparer(), serializerSettings: new SerializerSettings { keySerializer = () => new MyKeySerializer(), valueSerializer = () => new MyValueSerializer() }, - lockingMode: lockingMode // Warning: LockingMode.Standard will deadlock with X locks as both keys map to the same keyHash + concurrencyControlMode: concurrencyControlMode // Warning: ConcurrencyControlMode.LockTable will deadlock with X locks as both keys map to the same keyHash ); } @@ -363,7 +363,7 @@ void DoFlush(FlushMode flushMode) [Test] [Category("FasterKV")] [Category("Smoke")] - public void DisposeSingleWriter2Threads([Values(LockingMode.Ephemeral, LockingMode.None)] LockingMode lockingMode) + public void DisposeSingleWriter2Threads([Values(ConcurrencyControlMode.RecordIsolation, ConcurrencyControlMode.None)] ConcurrencyControlMode concurrencyControlMode) { var functions1 = new DisposeFunctions(this, sut: true); var functions2 = new DisposeFunctions(this, sut: false); @@ -401,7 +401,7 @@ void DoUpsert(DisposeFunctions functions) [Category("FasterKV")] [Category("Smoke")] public void DisposeInitialUpdater2Threads([Values(FlushMode.NoFlush, FlushMode.OnDisk)] FlushMode flushMode, - [Values(LockingMode.Ephemeral, LockingMode.None)] LockingMode lockingMode) + [Values(ConcurrencyControlMode.RecordIsolation, ConcurrencyControlMode.None)] ConcurrencyControlMode concurrencyControlMode) { var functions1 = new DisposeFunctions(this, sut: true); var functions2 = new DisposeFunctions(this, sut: false); @@ -440,7 +440,7 @@ void DoInsert(DisposeFunctions functions) [Category("FasterKV")] [Category("Smoke")] public void DisposeCopyUpdater2Threads([Values(FlushMode.ReadOnly, FlushMode.OnDisk)] FlushMode flushMode, - [Values(LockingMode.Ephemeral, LockingMode.None)] LockingMode lockingMode) + [Values(ConcurrencyControlMode.RecordIsolation, ConcurrencyControlMode.None)] ConcurrencyControlMode concurrencyControlMode) { var functions1 = new DisposeFunctions(this, sut: true); var functions2 = new DisposeFunctions(this, sut: false); @@ -504,7 +504,7 @@ void DoUpdate(DisposeFunctions functions) [Category("FasterKV")] [Category("Smoke")] public void DisposeSingleDeleter2Threads([Values(FlushMode.ReadOnly, FlushMode.OnDisk)] FlushMode flushMode, - [Values(LockingMode.Ephemeral, LockingMode.None)] LockingMode lockingMode) + [Values(ConcurrencyControlMode.RecordIsolation, ConcurrencyControlMode.None)] ConcurrencyControlMode concurrencyControlMode) { var functions1 = new DisposeFunctions(this, sut: true); var functions2 = new DisposeFunctions(this, sut: false); @@ -550,7 +550,7 @@ void DoDelete(DisposeFunctions functions) [Test] [Category("FasterKV")] [Category("Smoke")] - public void PendingRead([Values] ReadCopyDestination copyDest, [Values(LockingMode.Ephemeral, LockingMode.None)] LockingMode lockingMode) + public void PendingRead([Values] ReadCopyDestination copyDest, [Values(ConcurrencyControlMode.RecordIsolation, ConcurrencyControlMode.None)] ConcurrencyControlMode concurrencyControlMode) { DoPendingReadInsertTest(copyDest, initialReadCacheInsert: false); @@ -560,7 +560,7 @@ public void PendingRead([Values] ReadCopyDestination copyDest, [Values(LockingMo [Category("FasterKV")] [Category("Smoke")] public void CopyToTailWithInitialReadCache([Values(ReadCopyDestination.ReadCache)] ReadCopyDestination copyDest, - [Values(LockingMode.Ephemeral, LockingMode.None)] LockingMode lockingMode) + [Values(ConcurrencyControlMode.RecordIsolation, ConcurrencyControlMode.None)] ConcurrencyControlMode concurrencyControlMode) { // We use the ReadCopyDestination.ReadCache parameter so Setup() knows to set up the readcache, but // for the actual test it is used only for setup; we execute CopyToTail. @@ -608,7 +608,7 @@ void DoPendingReadInsertTest(ReadCopyDestination copyDest, bool initialReadCache [Test] [Category("FasterKV")] [Category("Smoke")] - public void DisposePendingRead2Threads([Values] ReadCopyDestination copyDest, [Values] LockingMode lockingMode) + public void DisposePendingRead2Threads([Values] ReadCopyDestination copyDest, [Values] ConcurrencyControlMode concurrencyControlMode) { DoDisposePendingReadInsertTest2Threads(copyDest, initialReadCacheInsert: false); } @@ -616,7 +616,7 @@ public void DisposePendingRead2Threads([Values] ReadCopyDestination copyDest, [V [Test] [Category("FasterKV")] [Category("Smoke")] - public void DisposeCopyToTailWithInitialReadCache2Threads([Values(ReadCopyDestination.ReadCache)] ReadCopyDestination copyDest, [Values] LockingMode lockingMode) + public void DisposeCopyToTailWithInitialReadCache2Threads([Values(ReadCopyDestination.ReadCache)] ReadCopyDestination copyDest, [Values] ConcurrencyControlMode concurrencyControlMode) { // We use the ReadCopyDestination.ReadCache parameter so Setup() knows to set up the readcache, but // for the actual test it is used only for setup; we execute CopyToTail. @@ -703,7 +703,7 @@ void DoRead(DisposeFunctions functions) [Test] [Category("FasterKV")] [Category("Smoke")] - public void DisposePendingReadWithNoInsertTest([Values(LockingMode.Ephemeral, LockingMode.None)] LockingMode lockingMode) + public void DisposePendingReadWithNoInsertTest([Values(ConcurrencyControlMode.RecordIsolation, ConcurrencyControlMode.None)] ConcurrencyControlMode concurrencyControlMode) { var functions = new DisposeFunctionsNoSync(); @@ -730,7 +730,7 @@ public void DisposePendingReadWithNoInsertTest([Values(LockingMode.Ephemeral, Lo [Test] [Category("FasterKV")] [Category("Smoke")] - public void DisposePendingRmwWithNoConflictTest([Values(LockingMode.Ephemeral, LockingMode.None)] LockingMode lockingMode) + public void DisposePendingRmwWithNoConflictTest([Values(ConcurrencyControlMode.RecordIsolation, ConcurrencyControlMode.None)] ConcurrencyControlMode concurrencyControlMode) { var functions = new DisposeFunctionsNoSync(); diff --git a/cs/test/EphemeralLockingTests.cs b/cs/test/EphemeralLockingTests.cs index 543bd56e1..febacc559 100644 --- a/cs/test/EphemeralLockingTests.cs +++ b/cs/test/EphemeralLockingTests.cs @@ -68,7 +68,7 @@ public void Setup(bool forRecovery) functions = new EphemeralLockingTestFunctions(); fht = new FasterKV(1L << 20, new LogSettings { LogDevice = log, ObjectLogDevice = null, PageSizeBits = 12, MemorySizeBits = 22, ReadCacheSettings = readCacheSettings }, - checkpointSettings: checkpointSettings, comparer: comparer, lockingMode: LockingMode.Ephemeral); + checkpointSettings: checkpointSettings, comparer: comparer, concurrencyControlMode: ConcurrencyControlMode.RecordIsolation); session = fht.For(functions).NewSession(); } diff --git a/cs/test/GenericDiskDeleteTests.cs b/cs/test/GenericDiskDeleteTests.cs index e11c26e4e..fd42bcdba 100644 --- a/cs/test/GenericDiskDeleteTests.cs +++ b/cs/test/GenericDiskDeleteTests.cs @@ -25,7 +25,7 @@ public void Setup() (128, logSettings: new LogSettings { LogDevice = log, ObjectLogDevice = objlog, MutableFraction = 0.1, MemorySizeBits = 14, PageSizeBits = 9 }, serializerSettings: new SerializerSettings { keySerializer = () => new MyKeySerializer(), valueSerializer = () => new MyValueSerializer() }, - lockingMode: LockingMode.None); + concurrencyControlMode: ConcurrencyControlMode.None); session = fht.For(new MyFunctionsDelete()).NewSession(); } diff --git a/cs/test/GenericIterationTests.cs b/cs/test/GenericIterationTests.cs index 24050aa3c..9d85edd52 100644 --- a/cs/test/GenericIterationTests.cs +++ b/cs/test/GenericIterationTests.cs @@ -26,12 +26,12 @@ public void Setup() private void InternalSetup(ScanIteratorType scanIteratorType, bool largeMemory) { - // Default lockingMode for this iterator type. - var lockingMode = scanIteratorType == ScanIteratorType.Pull ? LockingMode.None : LockingMode.Standard; - InternalSetup(lockingMode, largeMemory); + // Default ConcurrencyControlMode for this iterator type. + var concurrencyControlMode = scanIteratorType == ScanIteratorType.Pull ? ConcurrencyControlMode.None : ConcurrencyControlMode.LockTable; + InternalSetup(concurrencyControlMode, largeMemory); } - private void InternalSetup(LockingMode lockingMode, bool largeMemory) + private void InternalSetup(ConcurrencyControlMode concurrencyControlMode, bool largeMemory) { // Broke this out as we have different requirements by test. log = Devices.CreateLogDevice(MethodTestDir + "/GenericIterationTests.log", deleteOnClose: true); @@ -41,7 +41,7 @@ private void InternalSetup(LockingMode lockingMode, bool largeMemory) (128, logSettings: new LogSettings { LogDevice = log, ObjectLogDevice = objlog, MutableFraction = 0.1, MemorySizeBits = largeMemory ? 25 : 14, PageSizeBits = largeMemory ? 20 : 9 }, serializerSettings: new SerializerSettings { keySerializer = () => new MyKeySerializer(), valueSerializer = () => new MyValueSerializer() }, - lockingMode: lockingMode); + concurrencyControlMode: concurrencyControlMode); session = fht.For(new MyFunctionsDelete()).NewSession(); } @@ -198,9 +198,9 @@ void scanAndVerify(int stopAt, bool useScan) [Test] [Category(FasterKVTestCategory)] [Category(SmokeTestCategory)] - public unsafe void GenericIterationPushLockTest([Values(1, 4)] int scanThreads, [Values(1, 4)] int updateThreads, [Values] LockingMode lockingMode, [Values] ScanMode scanMode) + public unsafe void GenericIterationPushLockTest([Values(1, 4)] int scanThreads, [Values(1, 4)] int updateThreads, [Values] ConcurrencyControlMode concurrencyControlMode, [Values] ScanMode scanMode) { - InternalSetup(lockingMode, largeMemory: true); + InternalSetup(concurrencyControlMode, largeMemory: true); const int totalRecords = 2000; var start = fht.Log.TailAddress; diff --git a/cs/test/GenericLogScanTests.cs b/cs/test/GenericLogScanTests.cs index d61d482a9..cfcd7e7d3 100644 --- a/cs/test/GenericLogScanTests.cs +++ b/cs/test/GenericLogScanTests.cs @@ -72,7 +72,7 @@ public void DiskWriteScanBasicTest([Values] DeviceType deviceType, [Values] Scan fht = new (128, logSettings: new LogSettings { LogDevice = log, ObjectLogDevice = objlog, MutableFraction = 0.1, MemorySizeBits = 15, PageSizeBits = 9, SegmentSizeBits = 22 }, serializerSettings: new SerializerSettings { keySerializer = () => new MyKeySerializer(), valueSerializer = () => new MyValueSerializer() }, - lockingMode: scanIteratorType == ScanIteratorType.Pull ? LockingMode.None : LockingMode.Standard + concurrencyControlMode: scanIteratorType == ScanIteratorType.Pull ? ConcurrencyControlMode.None : ConcurrencyControlMode.LockTable ); using var session = fht.For(new MyFunctions()).NewSession(); @@ -146,7 +146,7 @@ public void BlittableScanJumpToBeginAddressTest() fht = new(128, logSettings: new LogSettings { LogDevice = log, ObjectLogDevice = objlog, MutableFraction = 0.1, MemorySizeBits = 20, PageSizeBits = 15, SegmentSizeBits = 18 }, serializerSettings: new SerializerSettings { keySerializer = () => new MyKeySerializer(), valueSerializer = () => new MyValueSerializer() }, - lockingMode: LockingMode.None); + concurrencyControlMode: ConcurrencyControlMode.None); using var session = fht.For(new MyFunctions()).NewSession(); diff --git a/cs/test/LockableUnsafeContextTests.cs b/cs/test/LockableUnsafeContextTests.cs index 52c846fed..eef723c5c 100644 --- a/cs/test/LockableUnsafeContextTests.cs +++ b/cs/test/LockableUnsafeContextTests.cs @@ -182,7 +182,7 @@ public void Setup(bool forRecovery) fht = new FasterKV(1L << 20, new LogSettings { LogDevice = log, ObjectLogDevice = null, PageSizeBits = 12, MemorySizeBits = 22, ReadCacheSettings = readCacheSettings }, checkpointSettings: checkpointSettings, comparer: comparer, - lockingMode: LockingMode.Standard); + concurrencyControlMode: ConcurrencyControlMode.LockTable); session = fht.For(functions).NewSession(); } diff --git a/cs/test/MiscFASTERTests.cs b/cs/test/MiscFASTERTests.cs index a79e3dcdd..2f7c2bef2 100644 --- a/cs/test/MiscFASTERTests.cs +++ b/cs/test/MiscFASTERTests.cs @@ -119,7 +119,7 @@ public void ForceRCUAndRecover([Values(UpdateOp.Upsert, UpdateOp.Delete)] Update fht = new FasterKV (128, new LogSettings { LogDevice = log, MemorySizeBits = 29 }, checkpointSettings: new CheckpointSettings { CheckpointDir = checkpointDir }, - lockingMode: LockingMode.None); + concurrencyControlMode: ConcurrencyControlMode.None); session = fht.NewSession(copyOnWrite); @@ -168,7 +168,7 @@ public void ForceRCUAndRecover([Values(UpdateOp.Upsert, UpdateOp.Delete)] Update fht = new FasterKV (128, new LogSettings { LogDevice = log, MemorySizeBits = 29 }, checkpointSettings: new CheckpointSettings { CheckpointDir = checkpointDir }, - lockingMode: LockingMode.None); + concurrencyControlMode: ConcurrencyControlMode.None); fht.Recover(token); session = fht.NewSession(copyOnWrite); diff --git a/cs/test/ModifiedBitTests.cs b/cs/test/ModifiedBitTests.cs index 77237e369..df9e8b9a5 100644 --- a/cs/test/ModifiedBitTests.cs +++ b/cs/test/ModifiedBitTests.cs @@ -35,7 +35,7 @@ public void Setup() { log = Devices.CreateLogDevice(Path.Combine(MethodTestDir, "test.log"), deleteOnClose: false); comparer = new ModifiedBitTestComparer(); - fht = new FasterKV(1L << 20, new LogSettings { LogDevice = log, ObjectLogDevice = null, PageSizeBits = 12, MemorySizeBits = 22 }, comparer: comparer, lockingMode: LockingMode.Standard); + fht = new FasterKV(1L << 20, new LogSettings { LogDevice = log, ObjectLogDevice = null, PageSizeBits = 12, MemorySizeBits = 22 }, comparer: comparer, concurrencyControlMode: ConcurrencyControlMode.LockTable); session = fht.For(new SimpleFunctions()).NewSession>(); } diff --git a/cs/test/OverflowBucketLockTableTests.cs b/cs/test/OverflowBucketLockTableTests.cs index ebbf5fd3f..521d8223e 100644 --- a/cs/test/OverflowBucketLockTableTests.cs +++ b/cs/test/OverflowBucketLockTableTests.cs @@ -50,7 +50,7 @@ public void Setup() comparer ??= new LongFasterEqualityComparer(); fht = new FasterKV(1L << 20, new LogSettings { LogDevice = log, ObjectLogDevice = null, PageSizeBits = 12, MemorySizeBits = 22 }, - comparer: comparer, lockingMode: LockingMode.Standard); + comparer: comparer, concurrencyControlMode: ConcurrencyControlMode.LockTable); } [TearDown] diff --git a/cs/test/ReadAddressTests.cs b/cs/test/ReadAddressTests.cs index da64c08c1..1f74cc39a 100644 --- a/cs/test/ReadAddressTests.cs +++ b/cs/test/ReadAddressTests.cs @@ -146,7 +146,7 @@ private class TestStore : IDisposable internal long[] InsertAddresses = new long[numKeys]; - internal TestStore(bool useReadCache, ReadCopyOptions readCopyOptions, bool flush, LockingMode lockingMode) + internal TestStore(bool useReadCache, ReadCopyOptions readCopyOptions, bool flush, ConcurrencyControlMode concurrencyControlMode) { this.testDir = TestUtils.MethodTestDir; TestUtils.DeleteDirectory(this.testDir, wait:true); @@ -170,7 +170,7 @@ internal TestStore(bool useReadCache, ReadCopyOptions readCopyOptions, bool flus checkpointSettings: new CheckpointSettings { CheckpointDir = $"{this.testDir}/CheckpointDir" }, serializerSettings: null, comparer: new Key.Comparer(), - lockingMode: lockingMode + concurrencyControlMode: concurrencyControlMode ); } @@ -260,15 +260,15 @@ public void Dispose() } // readCache and copyReadsToTail are mutually exclusive and orthogonal to populating by RMW vs. Upsert. - [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, false, LockingMode.None)] - [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.Device, ReadCopyTo.MainLog, true, true, LockingMode.Standard)] - [TestCase(UseReadCache.ReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, true, LockingMode.Ephemeral)] + [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, false, ConcurrencyControlMode.None)] + [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.Device, ReadCopyTo.MainLog, true, true, ConcurrencyControlMode.LockTable)] + [TestCase(UseReadCache.ReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, true, ConcurrencyControlMode.RecordIsolation)] [Category("FasterKV"), Category("Read")] - public void VersionedReadSyncTests(UseReadCache urc, ReadCopyFrom readCopyFrom, ReadCopyTo readCopyTo, bool useRMW, bool flush, [Values] LockingMode lockingMode) + public void VersionedReadSyncTests(UseReadCache urc, ReadCopyFrom readCopyFrom, ReadCopyTo readCopyTo, bool useRMW, bool flush, [Values] ConcurrencyControlMode concurrencyControlMode) { var useReadCache = urc == UseReadCache.ReadCache; var readCopyOptions = new ReadCopyOptions(readCopyFrom, readCopyTo); - using var testStore = new TestStore(useReadCache, readCopyOptions, flush, lockingMode); + using var testStore = new TestStore(useReadCache, readCopyOptions, flush, concurrencyControlMode); testStore.Populate(useRMW, useAsync:false).GetAwaiter().GetResult(); using var session = testStore.fkv.For(new Functions()).NewSession(); @@ -326,9 +326,9 @@ public void OnStop(bool completed, long numberOfRecords) { } } [Test, Category(FasterKVTestCategory), Category(ReadTestCategory)] - public void IterateKeyTests([Values(FlushMode.NoFlush, FlushMode.OnDisk)] FlushMode flushMode, [Values] LockingMode lockingMode) + public void IterateKeyTests([Values(FlushMode.NoFlush, FlushMode.OnDisk)] FlushMode flushMode, [Values] ConcurrencyControlMode concurrencyControlMode) { - using var testStore = new TestStore(useReadCache:false, ReadCopyOptions.None, flushMode != FlushMode.NoFlush, lockingMode); + using var testStore = new TestStore(useReadCache:false, ReadCopyOptions.None, flushMode != FlushMode.NoFlush, concurrencyControlMode); testStore.Populate(useRMW: true, useAsync: false).GetAwaiter().GetResult(); for (int iteration = 0; iteration < 2; ++iteration) @@ -341,9 +341,9 @@ public void IterateKeyTests([Values(FlushMode.NoFlush, FlushMode.OnDisk)] FlushM } [Test, Category(FasterKVTestCategory), Category(ReadTestCategory)] - public void IterateKeyStopTests([Values(FlushMode.NoFlush, FlushMode.OnDisk)] FlushMode flushMode, [Values] LockingMode lockingMode) + public void IterateKeyStopTests([Values(FlushMode.NoFlush, FlushMode.OnDisk)] FlushMode flushMode, [Values] ConcurrencyControlMode concurrencyControlMode) { - using var testStore = new TestStore(useReadCache: false, ReadCopyOptions.None, flushMode != FlushMode.NoFlush, lockingMode); + using var testStore = new TestStore(useReadCache: false, ReadCopyOptions.None, flushMode != FlushMode.NoFlush, concurrencyControlMode); testStore.Populate(useRMW: false, useAsync: false).GetAwaiter().GetResult(); for (int iteration = 0; iteration < 2; ++iteration) @@ -356,15 +356,15 @@ public void IterateKeyStopTests([Values(FlushMode.NoFlush, FlushMode.OnDisk)] Fl } // readCache and copyReadsToTail are mutually exclusive and orthogonal to populating by RMW vs. Upsert. - [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, false, LockingMode.None)] - [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.Device, ReadCopyTo.MainLog, true, true, LockingMode.Standard)] - [TestCase(UseReadCache.ReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, true, LockingMode.Ephemeral)] + [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, false, ConcurrencyControlMode.None)] + [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.Device, ReadCopyTo.MainLog, true, true, ConcurrencyControlMode.LockTable)] + [TestCase(UseReadCache.ReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, true, ConcurrencyControlMode.RecordIsolation)] [Category("FasterKV"), Category("Read")] - public async Task VersionedReadAsyncTests(UseReadCache urc, ReadCopyFrom readCopyFrom, ReadCopyTo readCopyTo, bool useRMW, bool flush, [Values] LockingMode lockingMode) + public async Task VersionedReadAsyncTests(UseReadCache urc, ReadCopyFrom readCopyFrom, ReadCopyTo readCopyTo, bool useRMW, bool flush, [Values] ConcurrencyControlMode concurrencyControlMode) { var useReadCache = urc == UseReadCache.ReadCache; var readCopyOptions = new ReadCopyOptions(readCopyFrom, readCopyTo); - using var testStore = new TestStore(useReadCache, readCopyOptions, flush, lockingMode); + using var testStore = new TestStore(useReadCache, readCopyOptions, flush, concurrencyControlMode); await testStore.Populate(useRMW, useAsync: true); using var session = testStore.fkv.For(new Functions()).NewSession(); @@ -389,15 +389,15 @@ public async Task VersionedReadAsyncTests(UseReadCache urc, ReadCopyFrom readCop } // readCache and copyReadsToTail are mutually exclusive and orthogonal to populating by RMW vs. Upsert. - [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, false, LockingMode.None)] - [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.Device, ReadCopyTo.MainLog, true, true, LockingMode.Standard)] - [TestCase(UseReadCache.ReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, true, LockingMode.Ephemeral)] + [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, false, ConcurrencyControlMode.None)] + [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.Device, ReadCopyTo.MainLog, true, true, ConcurrencyControlMode.LockTable)] + [TestCase(UseReadCache.ReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, true, ConcurrencyControlMode.RecordIsolation)] [Category("FasterKV"), Category("Read")] - public void ReadAtAddressSyncTests(UseReadCache urc, ReadCopyFrom readCopyFrom, ReadCopyTo readCopyTo, bool useRMW, bool flush, [Values] LockingMode lockingMode) + public void ReadAtAddressSyncTests(UseReadCache urc, ReadCopyFrom readCopyFrom, ReadCopyTo readCopyTo, bool useRMW, bool flush, [Values] ConcurrencyControlMode concurrencyControlMode) { var useReadCache = urc == UseReadCache.ReadCache; var readCopyOptions = new ReadCopyOptions(readCopyFrom, readCopyTo); - using var testStore = new TestStore(useReadCache, readCopyOptions, flush, lockingMode); + using var testStore = new TestStore(useReadCache, readCopyOptions, flush, concurrencyControlMode); testStore.Populate(useRMW, useAsync: false).GetAwaiter().GetResult(); using var session = testStore.fkv.For(new Functions()).NewSession(); @@ -445,15 +445,15 @@ public void ReadAtAddressSyncTests(UseReadCache urc, ReadCopyFrom readCopyFrom, } // readCache and copyReadsToTail are mutually exclusive and orthogonal to populating by RMW vs. Upsert. - [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, false, LockingMode.None)] - [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.Device, ReadCopyTo.MainLog, true, true, LockingMode.Standard)] - [TestCase(UseReadCache.ReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, true, LockingMode.Ephemeral)] + [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, false, ConcurrencyControlMode.None)] + [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.Device, ReadCopyTo.MainLog, true, true, ConcurrencyControlMode.LockTable)] + [TestCase(UseReadCache.ReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, true, ConcurrencyControlMode.RecordIsolation)] [Category("FasterKV"), Category("Read")] - public async Task ReadAtAddressAsyncTests(UseReadCache urc, ReadCopyFrom readCopyFrom, ReadCopyTo readCopyTo, bool useRMW, bool flush, [Values] LockingMode lockingMode) + public async Task ReadAtAddressAsyncTests(UseReadCache urc, ReadCopyFrom readCopyFrom, ReadCopyTo readCopyTo, bool useRMW, bool flush, [Values] ConcurrencyControlMode concurrencyControlMode) { var useReadCache = urc == UseReadCache.ReadCache; var readCopyOptions = new ReadCopyOptions(readCopyFrom, readCopyTo); - using var testStore = new TestStore(useReadCache, readCopyOptions, flush, lockingMode); + using var testStore = new TestStore(useReadCache, readCopyOptions, flush, concurrencyControlMode); await testStore.Populate(useRMW, useAsync: true); using var session = testStore.fkv.For(new Functions()).NewSession(); @@ -491,15 +491,15 @@ public async Task ReadAtAddressAsyncTests(UseReadCache urc, ReadCopyFrom readCop } // Test is similar to others but tests the Overload where RadFlag.none is set -- probably don't need all combinations of test but doesn't hurt - [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, false, LockingMode.None)] - [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.Device, ReadCopyTo.MainLog, true, true, LockingMode.Standard)] - [TestCase(UseReadCache.ReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, true, LockingMode.Ephemeral)] + [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, false, ConcurrencyControlMode.None)] + [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.Device, ReadCopyTo.MainLog, true, true, ConcurrencyControlMode.LockTable)] + [TestCase(UseReadCache.ReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, true, ConcurrencyControlMode.RecordIsolation)] [Category("FasterKV"), Category("Read")] - public async Task ReadAtAddressAsyncCopyOptionsNoReadCacheTests(UseReadCache urc, ReadCopyFrom readCopyFrom, ReadCopyTo readCopyTo, bool useRMW, bool flush, [Values] LockingMode lockingMode) + public async Task ReadAtAddressAsyncCopyOptionsNoReadCacheTests(UseReadCache urc, ReadCopyFrom readCopyFrom, ReadCopyTo readCopyTo, bool useRMW, bool flush, [Values] ConcurrencyControlMode concurrencyControlMode) { var useReadCache = urc == UseReadCache.ReadCache; var readCopyOptions = new ReadCopyOptions(readCopyFrom, readCopyTo); - using var testStore = new TestStore(useReadCache, readCopyOptions, flush, lockingMode); + using var testStore = new TestStore(useReadCache, readCopyOptions, flush, concurrencyControlMode); await testStore.Populate(useRMW, useAsync: true); using var session = testStore.fkv.For(new Functions()).NewSession(); @@ -537,15 +537,15 @@ public async Task ReadAtAddressAsyncCopyOptionsNoReadCacheTests(UseReadCache urc } // readCache and copyReadsToTail are mutually exclusive and orthogonal to populating by RMW vs. Upsert. - [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, false, LockingMode.None)] - [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.Device, ReadCopyTo.MainLog, true, true, LockingMode.Standard)] - [TestCase(UseReadCache.ReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, true, LockingMode.Ephemeral)] + [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, false, ConcurrencyControlMode.None)] + [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.Device, ReadCopyTo.MainLog, true, true, ConcurrencyControlMode.LockTable)] + [TestCase(UseReadCache.ReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, true, ConcurrencyControlMode.RecordIsolation)] [Category("FasterKV"), Category("Read")] - public void ReadNoKeySyncTests(UseReadCache urc, ReadCopyFrom readCopyFrom, ReadCopyTo readCopyTo, bool useRMW, bool flush, [Values] LockingMode lockingMode) // readCache and copyReadsToTail are mutually exclusive and orthogonal to populating by RMW vs. Upsert. + public void ReadNoKeySyncTests(UseReadCache urc, ReadCopyFrom readCopyFrom, ReadCopyTo readCopyTo, bool useRMW, bool flush, [Values] ConcurrencyControlMode concurrencyControlMode) // readCache and copyReadsToTail are mutually exclusive and orthogonal to populating by RMW vs. Upsert. { var useReadCache = urc == UseReadCache.ReadCache; var readCopyOptions = new ReadCopyOptions(readCopyFrom, readCopyTo); - using var testStore = new TestStore(useReadCache, readCopyOptions, flush, lockingMode); + using var testStore = new TestStore(useReadCache, readCopyOptions, flush, concurrencyControlMode); testStore.Populate(useRMW, useAsync: false).GetAwaiter().GetResult(); using var session = testStore.fkv.For(new Functions()).NewSession(); @@ -581,15 +581,15 @@ public void ReadNoKeySyncTests(UseReadCache urc, ReadCopyFrom readCopyFrom, Read } // readCache and copyReadsToTail are mutually exclusive and orthogonal to populating by RMW vs. Upsert. - [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, false, LockingMode.None)] - [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.Device, ReadCopyTo.MainLog, true, true, LockingMode.Standard)] - [TestCase(UseReadCache.ReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, true, LockingMode.Ephemeral)] + [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, false, ConcurrencyControlMode.None)] + [TestCase(UseReadCache.NoReadCache, ReadCopyFrom.Device, ReadCopyTo.MainLog, true, true, ConcurrencyControlMode.LockTable)] + [TestCase(UseReadCache.ReadCache, ReadCopyFrom.None, ReadCopyTo.None, false, true, ConcurrencyControlMode.RecordIsolation)] [Category("FasterKV"), Category("Read")] - public async Task ReadNoKeyAsyncTests(UseReadCache urc, ReadCopyFrom readCopyFrom, ReadCopyTo readCopyTo, bool useRMW, bool flush, LockingMode lockingMode) + public async Task ReadNoKeyAsyncTests(UseReadCache urc, ReadCopyFrom readCopyFrom, ReadCopyTo readCopyTo, bool useRMW, bool flush, ConcurrencyControlMode concurrencyControlMode) { var useReadCache = urc == UseReadCache.ReadCache; var readCopyOptions = new ReadCopyOptions(readCopyFrom, readCopyTo); - using var testStore = new TestStore(useReadCache, readCopyOptions, flush, lockingMode); + using var testStore = new TestStore(useReadCache, readCopyOptions, flush, concurrencyControlMode); await testStore.Populate(useRMW, useAsync: true); using var session = testStore.fkv.For(new Functions()).NewSession(); @@ -707,19 +707,19 @@ public void Setup() log = Devices.CreateLogDevice(MethodTestDir + "/SimpleRecoveryTest1.log", deleteOnClose: true); - var lockingMode = LockingMode.Standard; + var concurrencyControlMode = ConcurrencyControlMode.LockTable; foreach (var arg in TestContext.CurrentContext.Test.Arguments) { - if (arg is LockingMode locking_mode) + if (arg is ConcurrencyControlMode locking_mode) { - lockingMode = locking_mode; + concurrencyControlMode = locking_mode; break; } } fht = new FasterKV(128, logSettings: new LogSettings { LogDevice = log, MutableFraction = 0.1, MemorySizeBits = 29 }, - lockingMode: lockingMode + concurrencyControlMode: concurrencyControlMode ); session = fht.NewSession(new SimpleFunctions()); @@ -740,7 +740,7 @@ public void TearDown() [Test] [Category("FasterKV"), Category("Read")] - public async ValueTask ReadMinAddressTest([Values] SyncMode syncMode, [Values] LockingMode lockingMode) + public async ValueTask ReadMinAddressTest([Values] SyncMode syncMode, [Values] ConcurrencyControlMode concurrencyControlMode) { long minAddress = core.Constants.kInvalidAddress; var pivotKey = numOps / 2; diff --git a/cs/test/ReadCacheChainTests.cs b/cs/test/ReadCacheChainTests.cs index ef1198d06..370eee2be 100644 --- a/cs/test/ReadCacheChainTests.cs +++ b/cs/test/ReadCacheChainTests.cs @@ -57,19 +57,19 @@ public void Setup() var readCacheSettings = new ReadCacheSettings { MemorySizeBits = 15, PageSizeBits = 9 }; log = Devices.CreateLogDevice(MethodTestDir + "/NativeReadCacheTests.log", deleteOnClose: true); - var lockingMode = LockingMode.None; + var concurrencyControlMode = ConcurrencyControlMode.None; foreach (var arg in TestContext.CurrentContext.Test.Arguments) { - if (arg is LockingMode lm) + if (arg is ConcurrencyControlMode lm) { - lockingMode = lm; + concurrencyControlMode = lm; continue; } } fht = new FasterKV (1L << 20, new LogSettings { LogDevice = log, MemorySizeBits = 15, PageSizeBits = 10, ReadCacheSettings = readCacheSettings }, - comparer: new ChainComparer(mod), lockingMode: lockingMode); + comparer: new ChainComparer(mod), concurrencyControlMode: concurrencyControlMode); } [TearDown] @@ -291,7 +291,7 @@ public void ChainVerificationTest() [Category(FasterKVTestCategory)] [Category(ReadCacheTestCategory)] [Category(SmokeTestCategory)] - public void DeleteCacheRecordTest([Values] LockingMode lockingMode) + public void DeleteCacheRecordTest([Values] ConcurrencyControlMode concurrencyControlMode) { PopulateAndEvict(); CreateChain(); @@ -319,7 +319,7 @@ void doTest(long key) [Category(FasterKVTestCategory)] [Category(ReadCacheTestCategory)] [Category(SmokeTestCategory)] - public void DeleteHalfOfAllCacheRecordsTest([Values] LockingMode lockingMode) + public void DeleteHalfOfAllCacheRecordsTest([Values] ConcurrencyControlMode concurrencyControlMode) { PopulateAndEvict(); CreateChain(); @@ -371,7 +371,7 @@ void doTest(long key) [Category(FasterKVTestCategory)] [Category(ReadCacheTestCategory)] [Category(SmokeTestCategory)] - public void UpsertCacheRecordTest([Values] LockingMode lockingMode) + public void UpsertCacheRecordTest([Values] ConcurrencyControlMode concurrencyControlMode) { DoUpdateTest(useRMW: false); } @@ -380,7 +380,7 @@ public void UpsertCacheRecordTest([Values] LockingMode lockingMode) [Category(FasterKVTestCategory)] [Category(ReadCacheTestCategory)] [Category(SmokeTestCategory)] - public void RMWCacheRecordTest([Values] LockingMode lockingMode) + public void RMWCacheRecordTest([Values] ConcurrencyControlMode concurrencyControlMode) { DoUpdateTest(useRMW: true); } @@ -429,7 +429,7 @@ void doTest(long key) [Category(FasterKVTestCategory)] [Category(ReadCacheTestCategory)] [Category(SmokeTestCategory)] - public void SpliceInFromCTTTest([Values] LockingMode lockingMode) + public void SpliceInFromCTTTest([Values] ConcurrencyControlMode concurrencyControlMode) { PopulateAndEvict(); CreateChain(); @@ -449,7 +449,7 @@ public void SpliceInFromCTTTest([Values] LockingMode lockingMode) [Category(FasterKVTestCategory)] [Category(ReadCacheTestCategory)] [Category(SmokeTestCategory)] - public void SpliceInFromUpsertTest([Values] RecordRegion recordRegion, [Values] LockingMode lockingMode) + public void SpliceInFromUpsertTest([Values] RecordRegion recordRegion, [Values] ConcurrencyControlMode concurrencyControlMode) { PopulateAndEvict(recordRegion); CreateChain(recordRegion); @@ -477,7 +477,7 @@ public void SpliceInFromUpsertTest([Values] RecordRegion recordRegion, [Values] [Category(FasterKVTestCategory)] [Category(ReadCacheTestCategory)] [Category(SmokeTestCategory)] - public void SpliceInFromRMWTest([Values] RecordRegion recordRegion, [Values] LockingMode lockingMode) + public void SpliceInFromRMWTest([Values] RecordRegion recordRegion, [Values] ConcurrencyControlMode concurrencyControlMode) { PopulateAndEvict(recordRegion); CreateChain(recordRegion); @@ -524,7 +524,7 @@ public void SpliceInFromRMWTest([Values] RecordRegion recordRegion, [Values] Loc [Category(FasterKVTestCategory)] [Category(ReadCacheTestCategory)] [Category(SmokeTestCategory)] - public void SpliceInFromDeleteTest([Values] RecordRegion recordRegion, [Values] LockingMode lockingMode) + public void SpliceInFromDeleteTest([Values] RecordRegion recordRegion, [Values] ConcurrencyControlMode concurrencyControlMode) { PopulateAndEvict(recordRegion); CreateChain(recordRegion); @@ -552,7 +552,7 @@ public void SpliceInFromDeleteTest([Values] RecordRegion recordRegion, [Values] [Category(FasterKVTestCategory)] [Category(ReadCacheTestCategory)] [Category(SmokeTestCategory)] - public void VerifyLockCountsAfterReadCacheEvict([Values(LockingMode.Standard)] LockingMode lockingMode) + public void VerifyLockCountsAfterReadCacheEvict([Values(ConcurrencyControlMode.LockTable)] ConcurrencyControlMode concurrencyControlMode) { PopulateAndEvict(); CreateChain(); @@ -677,7 +677,7 @@ public void Setup() } fht = new FasterKV(1L << 20, logSettings, comparer: new LongComparerModulo(modRange), - lockingMode: LockingMode.Ephemeral); + concurrencyControlMode: ConcurrencyControlMode.RecordIsolation); } [TearDown] @@ -891,7 +891,7 @@ public void Setup() } fht = new FasterKV(1L << 20, logSettings, comparer: new SpanByteComparerModulo(modRange), - lockingMode: LockingMode.Standard); + concurrencyControlMode: ConcurrencyControlMode.LockTable); } [TearDown] diff --git a/cs/test/RecoveryChecks.cs b/cs/test/RecoveryChecks.cs index d716e1a16..8879f4f4f 100644 --- a/cs/test/RecoveryChecks.cs +++ b/cs/test/RecoveryChecks.cs @@ -612,7 +612,7 @@ public async ValueTask RecoveryCheck5([Values] CheckpointType checkpointType, [V (size, logSettings: new LogSettings { LogDevice = log, MutableFraction = 1, PageSizeBits = 10, MemorySizeBits = 14, ReadCacheSettings = useReadCache ? new ReadCacheSettings() : null }, checkpointSettings: new CheckpointSettings { CheckpointDir = path }, - lockingMode : LockingMode.Ephemeral + concurrencyControlMode : ConcurrencyControlMode.RecordIsolation ); using var s1 = fht1.NewSession(new MyFunctions()); diff --git a/cs/test/ReproReadCacheTest.cs b/cs/test/ReproReadCacheTest.cs index c751084fe..a0fa33a23 100644 --- a/cs/test/ReproReadCacheTest.cs +++ b/cs/test/ReproReadCacheTest.cs @@ -53,7 +53,7 @@ public void Setup() ReadCacheSettings readCacheSettings = default; string filename = MethodTestDir + "/BasicFasterTests.log"; - var lockingMode = LockingMode.None; + var concurrencyControlMode = ConcurrencyControlMode.None; foreach (var arg in TestContext.CurrentContext.Test.Arguments) { if (arg is ReadCacheMode rcm) @@ -67,9 +67,9 @@ public void Setup() }; continue; } - if (arg is LockingMode lm) + if (arg is ConcurrencyControlMode lm) { - lockingMode = lm; + concurrencyControlMode = lm; continue; } if (arg is DeviceType deviceType) @@ -88,7 +88,7 @@ public void Setup() MemorySizeBits = 15, PageSizeBits = 12, ReadCacheSettings = readCacheSettings, - }, lockingMode: lockingMode); + }, concurrencyControlMode: concurrencyControlMode); } [TearDown] @@ -107,7 +107,7 @@ public void TearDown() [Category(StressTestCategory)] //[Repeat(300)] public unsafe void RandomReadCacheTest([Values(1, 2, 8)] int numThreads, [Values] KeyContentionMode keyContentionMode, - [Values] LockingMode lockingMode, [Values] ReadCacheMode readCacheMode, + [Values] ConcurrencyControlMode concurrencyControlMode, [Values] ReadCacheMode readCacheMode, #if WINDOWS [Values(DeviceType.LSD #else diff --git a/cs/test/SpanByteLogScanTests.cs b/cs/test/SpanByteLogScanTests.cs index 794c1f6e7..69dd51945 100644 --- a/cs/test/SpanByteLogScanTests.cs +++ b/cs/test/SpanByteLogScanTests.cs @@ -22,7 +22,7 @@ public void Setup() DeleteDirectory(MethodTestDir, wait: true); log = Devices.CreateLogDevice(MethodTestDir + "/test.log", deleteOnClose: true); fht = new FasterKV - (1L << 20, new LogSettings { LogDevice = log, MemorySizeBits = 20, PageSizeBits = 15 }, lockingMode: LockingMode.None); + (1L << 20, new LogSettings { LogDevice = log, MemorySizeBits = 20, PageSizeBits = 15 }, concurrencyControlMode: ConcurrencyControlMode.None); } [TearDown] diff --git a/cs/test/VarLenBlittableIterationTests.cs b/cs/test/VarLenBlittableIterationTests.cs index 9686ab256..0e9dd911a 100644 --- a/cs/test/VarLenBlittableIterationTests.cs +++ b/cs/test/VarLenBlittableIterationTests.cs @@ -67,7 +67,7 @@ public void VarLenBlittableIterationBasicTest([Values] DeviceType deviceType, [V log = CreateTestDevice(deviceType, $"{path}{deviceType}.log"); fht = new FasterKV (1L << 20, new LogSettings { LogDevice = log, MemorySizeBits = 15, PageSizeBits = 9, SegmentSizeBits = 22 }, - lockingMode: scanIteratorType == ScanIteratorType.Pull ? LockingMode.None : LockingMode.Standard); + concurrencyControlMode: scanIteratorType == ScanIteratorType.Pull ? ConcurrencyControlMode.None : ConcurrencyControlMode.LockTable); using var session = fht.NewSession(new VLFunctions()); VarLenBlittablePushIterationTestFunctions scanIteratorFunctions = new(); @@ -186,7 +186,7 @@ void scanAndVerify(int stopAt, bool useScan) [Test] [Category(FasterKVTestCategory)] [Category(SmokeTestCategory)] - public unsafe void VarLenBlittableIterationPushLockTest([Values(1, 4)] int scanThreads, [Values(1, 4)] int updateThreads, [Values] LockingMode lockingMode, [Values] ScanMode scanMode) + public unsafe void VarLenBlittableIterationPushLockTest([Values(1, 4)] int scanThreads, [Values(1, 4)] int updateThreads, [Values] ConcurrencyControlMode concurrencyControlMode, [Values] ScanMode scanMode) { log = Devices.CreateLogDevice($"{path}lock_test.log"); fht = new FasterKV diff --git a/cs/test/VariableLengthIteratorTests.cs b/cs/test/VariableLengthIteratorTests.cs index ae9de0f89..928d14907 100644 --- a/cs/test/VariableLengthIteratorTests.cs +++ b/cs/test/VariableLengthIteratorTests.cs @@ -24,7 +24,7 @@ public void ShouldSkipEmptySpaceAtEndOfPage() (128, new LogSettings { LogDevice = log, MemorySizeBits = 17, PageSizeBits = 10 }, // 1KB page null, null, null, new VariableLengthStructSettings { valueLength = vlLength }, - lockingMode: LockingMode.None); + concurrencyControlMode: ConcurrencyControlMode.None); var session = fht.NewSession(new VLFunctions());