diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6efd7dafd..63d378ddf 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -27,28 +27,6 @@ jobs: buildConfiguration: 'Release' steps: - - task: NuGetToolInstaller@1 - - - task: NuGetCommand@2 - inputs: - restoreSolution: '$(solution)' - - - task: VSBuild@1 - inputs: - solution: '$(solution)' - platform: '$(buildPlatform)' - configuration: '$(buildConfiguration)' - - - task: NuGetCommand@2 - inputs: - restoreSolution: '$(solutionRemote)' - - - task: VSBuild@1 - inputs: - solution: '$(solutionRemote)' - platform: '$(buildPlatform)' - configuration: '$(buildConfiguration)' - - powershell: 'Invoke-WebRequest -OutFile azure-storage-emulator.msi -Uri "https://go.microsoft.com/fwlink/?LinkId=717179&clcid=0x409"' displayName: 'Download Azure Storage Emulator' @@ -61,43 +39,22 @@ jobs: - script: '"C:\storage-emulator\root\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe" start' displayName: 'Start Storage Emulator' - - task: VSTest@2 - inputs: - testAssemblyVer2: | - **\$(BuildConfiguration)\net46*\*test.dll - **\$(BuildConfiguration)\**\net46*\*test.dll - !**\*Microsoft.VisualStudio.TestPlatform* - !**\obj\** - !**\*TestAdapter.dll - platform: '$(buildPlatform)' - configuration: '$(buildConfiguration)' - otherConsoleOptions: '/Framework:.NETFramework,Version=v4.0' - - - task: VSTest@2 - inputs: - testAssemblyVer2: | - **\$(BuildConfiguration)\netcoreapp2*\*test.dll - **\$(BuildConfiguration)\**\netcoreapp2*\*test.dll - !**\*Microsoft.VisualStudio.TestPlatform* - !**\obj\** - !**\*TestAdapter.dll - platform: '$(buildPlatform)' - configuration: '$(buildConfiguration)' - otherConsoleOptions: '/Framework:.NETCoreApp,Version=v2.2' - - - task: VSTest@2 + - task: DotNetCoreCLI@2 + displayName: 'dotnet build $(buildConfiguration)' inputs: - testAssemblyVer2: | - **\$(BuildConfiguration)\netcoreapp3*\*test.dll - **\$(BuildConfiguration)\**\netcoreapp3*\*test.dll - !**\*Microsoft.VisualStudio.TestPlatform* - !**\obj\** - !**\*TestAdapter.dll - platform: '$(buildPlatform)' - configuration: '$(buildConfiguration)' - otherConsoleOptions: '/Framework:.NETCoreApp,Version=v3.1' + command: 'build' + projects: '**/*.test.csproj' + arguments: '--configuration $(buildConfiguration)' + - task: DotNetCoreCLI@2 + displayName: 'dotnet test $(buildConfiguration)' + inputs: + command: test + projects: '**/*.test.csproj' + arguments: '--configuration $(buildConfiguration) -l "console;verbosity=detailed"' + - task: PublishTestResults@2 + displayName: 'Publish Test Results' inputs: testRunner: VSTest testResultsFiles: '**/*.trx' @@ -137,7 +94,7 @@ jobs: - job: 'cppLinux' pool: - vmImage: ubuntu-16.04 + vmImage: ubuntu-18.04 displayName: 'C++ (Linux)' steps: @@ -166,35 +123,33 @@ jobs: - job: 'csharpLinux' pool: - vmImage: ubuntu-16.04 + vmImage: ubuntu-18.04 displayName: 'C# (Linux)' - steps: - - task: NuGetToolInstaller@1 - inputs: - versionSpec: '5.5.0' - - - task: NuGetCommand@2 - inputs: - restoreSolution: '$(solution)' + strategy: + maxParallel: 2 + matrix: + AnyCPU-Debug: + buildPlatform: 'Any CPU' + buildConfiguration: 'Debug' + AnyCPU-Release: + buildPlatform: 'Any CPU' + buildConfiguration: 'Release' - - task: UseDotNet@2 + steps: + - task: DotNetCoreCLI@2 + displayName: 'dotnet build $(buildConfiguration)' inputs: - packageType: 'sdk' - version: '3.1.201' - - - script: | - mono --version - msbuild /version - msbuild /t:restore $(solution) - msbuild /p:Configuration=Release $(solution) - displayName: 'Build' + command: 'build' + projects: '**/*.test.csproj' + arguments: '--configuration $(buildConfiguration)' - task: DotNetCoreCLI@2 + displayName: 'dotnet test $(buildConfiguration)' inputs: command: test - projects: '**/test/*.csproj' - arguments: '--configuration $(buildConfiguration) --framework netcoreapp3.1 -l "console;verbosity=detailed"' + projects: '**/*.test.csproj' + arguments: '--configuration $(buildConfiguration) -l "console;verbosity=detailed"' - task: PublishTestResults@2 displayName: 'Publish Test Results' diff --git a/cs/benchmark/ConcurrentDictionaryBenchmark.cs b/cs/benchmark/ConcurrentDictionaryBenchmark.cs index ef301f470..0b624a2d8 100644 --- a/cs/benchmark/ConcurrentDictionaryBenchmark.cs +++ b/cs/benchmark/ConcurrentDictionaryBenchmark.cs @@ -69,7 +69,7 @@ internal ConcurrentDictionary_YcsbBenchmark(Key[] i_keys_, Key[] t_keys_, TestLo for (int i = 0; i < 8; i++) input_[i].value = i; - store = new ConcurrentDictionary(testLoader.Options.ThreadCount, testLoader.MaxKey, new KeyComparer()); + store = new (testLoader.Options.ThreadCount, testLoader.MaxKey, new KeyComparer()); } internal void Dispose() @@ -79,15 +79,14 @@ internal void Dispose() private void RunYcsb(int thread_idx) { - RandomGenerator rng = new RandomGenerator((uint)(1 + thread_idx)); + RandomGenerator rng = new ((uint)(1 + thread_idx)); if (numaStyle == 0) Native32.AffinitizeThreadRoundRobin((uint)thread_idx); else Native32.AffinitizeThreadShardedNuma((uint)thread_idx, 2); // assuming two NUMA sockets - Stopwatch sw = new Stopwatch(); - sw.Start(); + var sw = Stopwatch.StartNew(); Value value = default; long reads_done = 0; @@ -174,7 +173,7 @@ private void RunYcsb(int thread_idx) internal unsafe (double, double) Run(TestLoader testLoader) { - RandomGenerator rng = new RandomGenerator(); + RandomGenerator rng = new (); GCHandle handle = GCHandle.Alloc(input_, GCHandleType.Pinned); input_ptr = (Input*)handle.AddrOfPinnedObject(); @@ -194,8 +193,7 @@ internal unsafe (double, double) Run(TestLoader testLoader) int x = idx; workers[idx] = new Thread(() => SetupYcsb(x)); } - Stopwatch sw = new Stopwatch(); - sw.Start(); + var sw = Stopwatch.StartNew(); // Start threads. foreach (Thread worker in workers) { @@ -226,8 +224,7 @@ internal unsafe (double, double) Run(TestLoader testLoader) worker.Start(); } - Stopwatch swatch = new Stopwatch(); - swatch.Start(); + var swatch = Stopwatch.StartNew(); if (testLoader.Options.PeriodicCheckpointMilliseconds <= 0) { diff --git a/cs/benchmark/FASTER.benchmark.csproj b/cs/benchmark/FASTER.benchmark.csproj index a3abf52e8..d3e70ecd0 100644 --- a/cs/benchmark/FASTER.benchmark.csproj +++ b/cs/benchmark/FASTER.benchmark.csproj @@ -1,9 +1,9 @@  - netcoreapp3.1 + net5.0;netcoreapp3.1 x64 - win7-x64 + latest diff --git a/cs/benchmark/FasterSpanByteYcsbBenchmark.cs b/cs/benchmark/FasterSpanByteYcsbBenchmark.cs index 124a7ccea..2a101b7b3 100644 --- a/cs/benchmark/FasterSpanByteYcsbBenchmark.cs +++ b/cs/benchmark/FasterSpanByteYcsbBenchmark.cs @@ -20,7 +20,7 @@ internal class FasterSpanByteYcsbBenchmark static long TxnCount; readonly TestLoader testLoader; - readonly ManualResetEventSlim waiter = new ManualResetEventSlim(); + readonly ManualResetEventSlim waiter = new(); readonly int numaStyle; readonly int readPercent; readonly FunctionsSB functions; @@ -93,7 +93,7 @@ internal void Dispose() private void RunYcsb(int thread_idx) { - RandomGenerator rng = new RandomGenerator((uint)(1 + thread_idx)); + RandomGenerator rng = new((uint)(1 + thread_idx)); if (numaStyle == 0) Native32.AffinitizeThreadRoundRobin((uint)thread_idx); @@ -102,8 +102,7 @@ private void RunYcsb(int thread_idx) waiter.Wait(); - Stopwatch sw = new Stopwatch(); - sw.Start(); + var sw = Stopwatch.StartNew(); Span value = stackalloc byte[kValueSize]; Span input = stackalloc byte[kValueSize]; @@ -282,8 +281,7 @@ internal unsafe (double, double) Run(TestLoader testLoader) } waiter.Set(); - Stopwatch swatch = new Stopwatch(); - swatch.Start(); + var swatch = Stopwatch.StartNew(); if (testLoader.Options.PeriodicCheckpointMilliseconds <= 0) { diff --git a/cs/benchmark/FasterYcsbBenchmark.cs b/cs/benchmark/FasterYcsbBenchmark.cs index da68c15fb..9e8380079 100644 --- a/cs/benchmark/FasterYcsbBenchmark.cs +++ b/cs/benchmark/FasterYcsbBenchmark.cs @@ -20,7 +20,7 @@ internal class FASTER_YcsbBenchmark static long TxnCount; readonly TestLoader testLoader; - readonly ManualResetEventSlim waiter = new ManualResetEventSlim(); + readonly ManualResetEventSlim waiter = new(); readonly int numaStyle; readonly int readPercent; readonly Functions functions; @@ -93,7 +93,7 @@ internal void Dispose() private void RunYcsb(int thread_idx) { - RandomGenerator rng = new RandomGenerator((uint)(1 + thread_idx)); + RandomGenerator rng = new((uint)(1 + thread_idx)); if (numaStyle == 0) Native32.AffinitizeThreadRoundRobin((uint)thread_idx); @@ -102,8 +102,7 @@ private void RunYcsb(int thread_idx) waiter.Wait(); - Stopwatch sw = new Stopwatch(); - sw.Start(); + var sw = Stopwatch.StartNew(); Value value = default; Input input = default; @@ -277,8 +276,7 @@ internal unsafe (double, double) Run(TestLoader testLoader) } waiter.Set(); - Stopwatch swatch = new Stopwatch(); - swatch.Start(); + var swatch = Stopwatch.StartNew(); if (testLoader.Options.PeriodicCheckpointMilliseconds <= 0) { diff --git a/cs/benchmark/Program.cs b/cs/benchmark/Program.cs index 1bbee71b2..3d45a2353 100644 --- a/cs/benchmark/Program.cs +++ b/cs/benchmark/Program.cs @@ -12,11 +12,11 @@ public class Program public static void Main(string[] args) { - var testLoader = new TestLoader(); + TestLoader testLoader = new(); if (!testLoader.Parse(args)) return; - var testStats = new TestStats(testLoader.Options); + TestStats testStats = new(testLoader.Options); testLoader.LoadData(); var options = testLoader.Options; // shortcut diff --git a/cs/benchmark/TestLoader.cs b/cs/benchmark/TestLoader.cs index 6f9057b17..72501a1bb 100644 --- a/cs/benchmark/TestLoader.cs +++ b/cs/benchmark/TestLoader.cs @@ -85,7 +85,7 @@ static bool verifyOption(bool isValid, string name) internal void LoadData() { - var worker = new Thread(LoadDataThreadProc); + Thread worker = new(LoadDataThreadProc); worker.Start(); worker.Join(); } @@ -218,8 +218,7 @@ private unsafe void LoadDataFromFile(string filePath, string d Console.WriteLine($"loading all keys from {init_filename} into memory..."); long count = 0; - using (FileStream stream = File.Open(init_filename, FileMode.Open, FileAccess.Read, - FileShare.Read)) + using (FileStream stream = File.Open(init_filename, FileMode.Open, FileAccess.Read, FileShare.Read)) { byte[] chunk = new byte[YcsbConstants.kFileChunkSize]; GCHandle chunk_handle = GCHandle.Alloc(chunk, GCHandleType.Pinned); @@ -313,8 +312,8 @@ private static void LoadSyntheticData(string distribution, uin sw.Stop(); Console.WriteLine($"loaded {init_keys.Length:N0} keys in {(double)sw.ElapsedMilliseconds / 1000:N3} seconds"); - RandomGenerator generator = new RandomGenerator(seed); - var zipf = new ZipfGenerator(generator, (int)init_keys.Length, theta: YcsbConstants.SyntheticZipfTheta); + RandomGenerator generator = new(seed); + ZipfGenerator zipf = new(generator, (int)init_keys.Length, theta: YcsbConstants.SyntheticZipfTheta); sw.Restart(); for (int idx = 0; idx < txn_keys.Length; idx++) @@ -368,7 +367,7 @@ internal void MaybeCheckpointStore(FasterKV store) if (this.Options.BackupAndRestore && this.Options.PeriodicCheckpointMilliseconds <= 0) { Console.WriteLine($"Checkpointing FasterKV to {this.BackupPath} for fast restart"); - Stopwatch sw = Stopwatch.StartNew(); + var sw = Stopwatch.StartNew(); store.TakeFullCheckpoint(out _, CheckpointType.Snapshot); store.CompleteCheckpointAsync().GetAwaiter().GetResult(); sw.Stop(); diff --git a/cs/benchmark/TestStats.cs b/cs/benchmark/TestStats.cs index 3c814e40e..2dc305162 100644 --- a/cs/benchmark/TestStats.cs +++ b/cs/benchmark/TestStats.cs @@ -10,8 +10,8 @@ namespace FASTER.benchmark { class TestStats { - private readonly List initsPerRun = new List(); - private readonly List opsPerRun = new List(); + private readonly List initsPerRun = new(); + private readonly List opsPerRun = new(); private Options options; internal static string OptionsString; diff --git a/cs/benchmark/scripts/run_benchmark.ps1 b/cs/benchmark/scripts/run_benchmark.ps1 index a900bdb39..475fbf368 100644 --- a/cs/benchmark/scripts/run_benchmark.ps1 +++ b/cs/benchmark/scripts/run_benchmark.ps1 @@ -41,6 +41,9 @@ .PARAMETER CloneAndBuild Clone the repo and switch to the branches in ExeDirs, then build these. +.PARAMETER NetCore31 + Use the netcoreapp3.1 instead of net5.0 version of FASTER.benchmark.exe + .EXAMPLE pwsh -c "./run_benchmark.ps1 './baseline','./refactor_FASTERImpl'" @@ -59,6 +62,11 @@ Runs 3 directories. +.EXAMPLE + pwsh -c "./run_benchmark.ps1 master,branch_with_my_changes -CloneAndBuild " + + Clones the master branch to the .\master folder, the branch_with_my_changes to the branch_with_my_changes folder, and runs those with any specified. + .EXAMPLE pwsh -c "./run_benchmark.ps1 master,branch_with_my_changes -CloneAndBuild " @@ -70,14 +78,16 @@ param ( [Parameter(Mandatory=$false)] [int]$ThreadCount = -1, [Parameter(Mandatory=$false)] [int]$lockMode = -1, [Parameter(Mandatory=$false)] [switch]$UseRecover, - [Parameter(Mandatory=$false)] [switch]$CloneAndBuild + [Parameter(Mandatory=$false)] [switch]$CloneAndBuild. + [Parameter(Mandatory=$false)] [switch]$NetCore31 ) if (-not(Test-Path d:/data)) { throw "Cannot find d:/data" } -$benchmarkExe = "netcoreapp3.1/win7-x64/FASTER.benchmark.exe" +$framework = $NetCore31 ? "netcoreapp3.1" : "net5.0" +$benchmarkExe = "$framework/FASTER.benchmark.exe" if ($CloneAndBuild) { $exeNames = [String[]]($ExeDirs | ForEach-Object{"$_/cs/benchmark/bin/x64/Release/$benchmarkExe"}) @@ -101,7 +111,7 @@ Foreach ($exeName in $exeNames) { throw "Cannot find: $exeName" } -$resultDirs = [String[]]($ExeDirs | ForEach-Object{"./results/" + (Get-Item $_).Name}) +$resultDirs = [String[]]($ExeDirs | ForEach-Object{"./results_$framework/" + (Get-Item $_).Name}) Foreach ($resultDir in $resultDirs) { Write-Host $resultDir if (Test-Path $resultDir) { diff --git a/cs/playground/AsyncStress/AsyncStress.csproj b/cs/playground/AsyncStress/AsyncStress.csproj index 45846211f..8630886df 100644 --- a/cs/playground/AsyncStress/AsyncStress.csproj +++ b/cs/playground/AsyncStress/AsyncStress.csproj @@ -2,8 +2,9 @@ Exe - netcoreapp3.1 - x64 + net5.0 + x64 + latest true diff --git a/cs/playground/CacheStoreConcurrent/CacheStoreConcurrent.csproj b/cs/playground/CacheStoreConcurrent/CacheStoreConcurrent.csproj index 0d269e4a0..867b88216 100644 --- a/cs/playground/CacheStoreConcurrent/CacheStoreConcurrent.csproj +++ b/cs/playground/CacheStoreConcurrent/CacheStoreConcurrent.csproj @@ -3,9 +3,9 @@ Exe true - netcoreapp3.1 + net5.0 x64 - win7-x64 + latest diff --git a/cs/playground/ClassRecoveryDurability/ClassRecoveryDurability.csproj b/cs/playground/ClassRecoveryDurability/ClassRecoveryDurability.csproj index c7c5ededb..7a07e85b2 100644 --- a/cs/playground/ClassRecoveryDurability/ClassRecoveryDurability.csproj +++ b/cs/playground/ClassRecoveryDurability/ClassRecoveryDurability.csproj @@ -2,8 +2,9 @@ Exe - netcoreapp3.1 + net5.0 AnyCPU;x64 + latest diff --git a/cs/playground/FasterLogMLSDTest/FasterLogStress.csproj b/cs/playground/FasterLogMLSDTest/FasterLogStress.csproj index 06558597b..c7d150044 100644 --- a/cs/playground/FasterLogMLSDTest/FasterLogStress.csproj +++ b/cs/playground/FasterLogMLSDTest/FasterLogStress.csproj @@ -2,8 +2,9 @@ Exe - netcoreapp3.1 - x64 + net5.0 + x64 + latest true diff --git a/cs/playground/SumStore/SumStore.csproj b/cs/playground/SumStore/SumStore.csproj index 530fbf9dc..163d90e33 100644 --- a/cs/playground/SumStore/SumStore.csproj +++ b/cs/playground/SumStore/SumStore.csproj @@ -1,9 +1,9 @@  - netcoreapp3.1 + net5.0 x64 - win7-x64 + latest diff --git a/cs/playground/TstRunner/TstRunner.csproj b/cs/playground/TstRunner/TstRunner.csproj index 3b7b751f4..aca9a871e 100644 --- a/cs/playground/TstRunner/TstRunner.csproj +++ b/cs/playground/TstRunner/TstRunner.csproj @@ -2,8 +2,9 @@ Exe - netcoreapp3.1 - x64 + net5.0 + x64 + latest true diff --git a/cs/remote/benchmark/FASTER.benchmark/FASTER.benchmark.csproj b/cs/remote/benchmark/FASTER.benchmark/FASTER.benchmark.csproj index 199d820cf..ce58c2798 100644 --- a/cs/remote/benchmark/FASTER.benchmark/FASTER.benchmark.csproj +++ b/cs/remote/benchmark/FASTER.benchmark/FASTER.benchmark.csproj @@ -2,24 +2,25 @@ Exe - netcoreapp3.1 - true - AnyCPU;x64 + net5.0 + true + AnyCPU;x64 + latest - - TRACE;DEBUG - full - bin\$(Platform)\Debug\ - + + TRACE;DEBUG + full + bin\$(Platform)\Debug\ + - - TRACE - true - bin\$(Platform)\Release\ - + + TRACE + true + bin\$(Platform)\Release\ + - + diff --git a/cs/remote/samples/FixedLenClient/FixedLenClient.csproj b/cs/remote/samples/FixedLenClient/FixedLenClient.csproj index 199d820cf..ce58c2798 100644 --- a/cs/remote/samples/FixedLenClient/FixedLenClient.csproj +++ b/cs/remote/samples/FixedLenClient/FixedLenClient.csproj @@ -2,24 +2,25 @@ Exe - netcoreapp3.1 - true - AnyCPU;x64 + net5.0 + true + AnyCPU;x64 + latest - - TRACE;DEBUG - full - bin\$(Platform)\Debug\ - + + TRACE;DEBUG + full + bin\$(Platform)\Debug\ + - - TRACE - true - bin\$(Platform)\Release\ - + + TRACE + true + bin\$(Platform)\Release\ + - + diff --git a/cs/remote/samples/FixedLenServer/FixedLenServer.csproj b/cs/remote/samples/FixedLenServer/FixedLenServer.csproj index 663509644..c205d6c8e 100644 --- a/cs/remote/samples/FixedLenServer/FixedLenServer.csproj +++ b/cs/remote/samples/FixedLenServer/FixedLenServer.csproj @@ -2,24 +2,25 @@ Exe - netcoreapp3.1 - true - AnyCPU;x64 + net5.0 + true + AnyCPU;x64 + latest - - TRACE;DEBUG - full - bin\$(Platform)\Debug\ - + + TRACE;DEBUG + full + bin\$(Platform)\Debug\ + - - TRACE - true - bin\$(Platform)\Release\ - + + TRACE + true + bin\$(Platform)\Release\ + - + diff --git a/cs/remote/samples/VarLenClient/VarLenClient.csproj b/cs/remote/samples/VarLenClient/VarLenClient.csproj index 199d820cf..ce58c2798 100644 --- a/cs/remote/samples/VarLenClient/VarLenClient.csproj +++ b/cs/remote/samples/VarLenClient/VarLenClient.csproj @@ -2,24 +2,25 @@ Exe - netcoreapp3.1 - true - AnyCPU;x64 + net5.0 + true + AnyCPU;x64 + latest - - TRACE;DEBUG - full - bin\$(Platform)\Debug\ - + + TRACE;DEBUG + full + bin\$(Platform)\Debug\ + - - TRACE - true - bin\$(Platform)\Release\ - + + TRACE + true + bin\$(Platform)\Release\ + - + diff --git a/cs/remote/samples/VarLenServer/VarLenServer.csproj b/cs/remote/samples/VarLenServer/VarLenServer.csproj index 8bd8ce6d3..9ea260135 100644 --- a/cs/remote/samples/VarLenServer/VarLenServer.csproj +++ b/cs/remote/samples/VarLenServer/VarLenServer.csproj @@ -2,24 +2,25 @@ Exe - netcoreapp3.1 - true - AnyCPU;x64 + net5.0 + true + AnyCPU;x64 + latest - - TRACE;DEBUG - full - bin\$(Platform)\Debug\ - + + TRACE;DEBUG + full + bin\$(Platform)\Debug\ + - - TRACE - true - bin\$(Platform)\Release\ - + + TRACE + true + bin\$(Platform)\Release\ + - + diff --git a/cs/remote/src/FASTER.client/FASTER.client.csproj b/cs/remote/src/FASTER.client/FASTER.client.csproj index f7ed572ff..7e38c45b1 100644 --- a/cs/remote/src/FASTER.client/FASTER.client.csproj +++ b/cs/remote/src/FASTER.client/FASTER.client.csproj @@ -1,39 +1,40 @@  - netstandard2.1;netstandard2.0;net461 - true - AnyCPU - true - ../../../FASTER.snk - false - true - bin\$(Platform)\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml + net5.0;netstandard2.1;netstandard2.0;net461 + true + AnyCPU + latest + true + ../../../FASTER.snk + false + true + bin\$(Platform)\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml - - TRACE;DEBUG - full - bin\$(Platform)\Debug\ - + + TRACE;DEBUG + full + bin\$(Platform)\Debug\ + - - TRACE - true - bin\$(Platform)\Release\ - + + TRACE + true + bin\$(Platform)\Release\ + - - - + + + - - - + + + - + - + diff --git a/cs/remote/src/FASTER.common/FASTER.common.csproj b/cs/remote/src/FASTER.common/FASTER.common.csproj index 4daf072e9..a9964a0ca 100644 --- a/cs/remote/src/FASTER.common/FASTER.common.csproj +++ b/cs/remote/src/FASTER.common/FASTER.common.csproj @@ -1,17 +1,18 @@  - netstandard2.1;netstandard2.0;net461 - true - AnyCPU - true - ../../../FASTER.snk - false - true - bin\$(Platform)\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml + net5.0;netstandard2.1;netstandard2.0;net461 + true + AnyCPU + latest + true + ../../../FASTER.snk + false + true + bin\$(Platform)\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml - + TRACE;DEBUG full bin\$(Platform)\Debug\ @@ -25,11 +26,11 @@ - + - + diff --git a/cs/remote/src/FASTER.server/FASTER.server.csproj b/cs/remote/src/FASTER.server/FASTER.server.csproj index 54716f640..b5088cf9b 100644 --- a/cs/remote/src/FASTER.server/FASTER.server.csproj +++ b/cs/remote/src/FASTER.server/FASTER.server.csproj @@ -1,32 +1,33 @@  - netstandard2.1;netstandard2.0;net461 - true - AnyCPU - true - ../../../FASTER.snk - false - true - bin\$(Platform)\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml + net5.0;netstandard2.1;netstandard2.0;net461 + true + AnyCPU + latest + true + ../../../FASTER.snk + false + true + bin\$(Platform)\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml - - TRACE;DEBUG - full - bin\$(Platform)\Debug\ - + + TRACE;DEBUG + full + bin\$(Platform)\Debug\ + - - TRACE - true - bin\$(Platform)\Release\ - + + TRACE + true + bin\$(Platform)\Release\ + - + diff --git a/cs/remote/test/FASTER.remote.test/FASTER.remote.test.csproj b/cs/remote/test/FASTER.remote.test/FASTER.remote.test.csproj index 6c5ec9e45..c37a138a0 100644 --- a/cs/remote/test/FASTER.remote.test/FASTER.remote.test.csproj +++ b/cs/remote/test/FASTER.remote.test/FASTER.remote.test.csproj @@ -1,55 +1,56 @@ - - netcoreapp3.1;netcoreapp2.1;net461 - AnyCPU;x64 - true - 8 - + + net5.0;netcoreapp3.1;netcoreapp2.1;net461 + net5.0;netcoreapp3.1 + AnyCPU;x64 + latest + true + - - true - FASTER.remote.test - FASTER.remote.test - prompt - true - - Library - - ../../../FASTER.snk - false - bin\$(Platform)\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml - + + true + FASTER.remote.test + FASTER.remote.test + prompt + true + + Library + + ../../../FASTER.snk + false + bin\$(Platform)\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml + - - TRACE;DEBUG - full - bin\$(Platform)\Debug\ - + + TRACE;DEBUG + full + bin\$(Platform)\Debug\ + - - TRACE - pdbonly - true - bin\$(Platform)\Release\ - + + TRACE + pdbonly + true + bin\$(Platform)\Release\ + - - 1701;1702;1591 - + + 1701;1702;1591 + - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + - - - - - + + + + + diff --git a/cs/samples/AzureBackedStore/AzureBackedStore.csproj b/cs/samples/AzureBackedStore/AzureBackedStore.csproj index 69c918781..d235ec0ea 100644 --- a/cs/samples/AzureBackedStore/AzureBackedStore.csproj +++ b/cs/samples/AzureBackedStore/AzureBackedStore.csproj @@ -1,9 +1,9 @@  - netcoreapp3.1 + net5.0 x64 - win7-x64 + latest diff --git a/cs/samples/CacheStore/CacheStore.csproj b/cs/samples/CacheStore/CacheStore.csproj index 0d269e4a0..867b88216 100644 --- a/cs/samples/CacheStore/CacheStore.csproj +++ b/cs/samples/CacheStore/CacheStore.csproj @@ -3,9 +3,9 @@ Exe true - netcoreapp3.1 + net5.0 x64 - win7-x64 + latest diff --git a/cs/samples/FasterLogPubSub/FasterLogPubSub.csproj b/cs/samples/FasterLogPubSub/FasterLogPubSub.csproj index 63a53f3c2..a91b1e251 100644 --- a/cs/samples/FasterLogPubSub/FasterLogPubSub.csproj +++ b/cs/samples/FasterLogPubSub/FasterLogPubSub.csproj @@ -1,9 +1,9 @@  - netcoreapp3.1 + net5.0 x64 - win7-x64;linux-x64 + latest diff --git a/cs/samples/FasterLogSample/FasterLogSample.csproj b/cs/samples/FasterLogSample/FasterLogSample.csproj index 633eae992..16c5ba627 100644 --- a/cs/samples/FasterLogSample/FasterLogSample.csproj +++ b/cs/samples/FasterLogSample/FasterLogSample.csproj @@ -1,9 +1,9 @@  - netcoreapp3.1 + net5.0 x64 - win7-x64;linux-x64 + latest diff --git a/cs/samples/HelloWorld/HelloWorld.csproj b/cs/samples/HelloWorld/HelloWorld.csproj index 9e310cf54..89457b100 100644 --- a/cs/samples/HelloWorld/HelloWorld.csproj +++ b/cs/samples/HelloWorld/HelloWorld.csproj @@ -1,9 +1,9 @@  - netcoreapp3.1 + net5.0 x64 - win7-x64 + latest diff --git a/cs/samples/MemOnlyCache/MemOnlyCache.csproj b/cs/samples/MemOnlyCache/MemOnlyCache.csproj index 0d269e4a0..867b88216 100644 --- a/cs/samples/MemOnlyCache/MemOnlyCache.csproj +++ b/cs/samples/MemOnlyCache/MemOnlyCache.csproj @@ -3,9 +3,9 @@ Exe true - netcoreapp3.1 + net5.0 x64 - win7-x64 + latest diff --git a/cs/samples/ReadAddress/VersionedRead.csproj b/cs/samples/ReadAddress/VersionedRead.csproj index 9a5aee079..7862e4287 100644 --- a/cs/samples/ReadAddress/VersionedRead.csproj +++ b/cs/samples/ReadAddress/VersionedRead.csproj @@ -2,8 +2,9 @@ Exe - netcoreapp3.1 + net5.0 x64 + latest diff --git a/cs/samples/SecondaryReaderStore/SecondaryReaderStore.csproj b/cs/samples/SecondaryReaderStore/SecondaryReaderStore.csproj index 0d269e4a0..867b88216 100644 --- a/cs/samples/SecondaryReaderStore/SecondaryReaderStore.csproj +++ b/cs/samples/SecondaryReaderStore/SecondaryReaderStore.csproj @@ -3,9 +3,9 @@ Exe true - netcoreapp3.1 + net5.0 x64 - win7-x64 + latest diff --git a/cs/samples/StoreAsyncApi/StoreAsyncApi.csproj b/cs/samples/StoreAsyncApi/StoreAsyncApi.csproj index 6c4acb70c..47259b5c8 100644 --- a/cs/samples/StoreAsyncApi/StoreAsyncApi.csproj +++ b/cs/samples/StoreAsyncApi/StoreAsyncApi.csproj @@ -1,9 +1,9 @@  - netcoreapp3.1 + net5.0 x64 - win7-x64;linux-x64 + latest diff --git a/cs/samples/StoreCheckpointRecover/StoreCheckpointRecover.csproj b/cs/samples/StoreCheckpointRecover/StoreCheckpointRecover.csproj index 4fbaa1e1d..fe4b1e7d6 100644 --- a/cs/samples/StoreCheckpointRecover/StoreCheckpointRecover.csproj +++ b/cs/samples/StoreCheckpointRecover/StoreCheckpointRecover.csproj @@ -1,9 +1,9 @@  - netcoreapp3.1 + net5.0 x64 - win7-x64 + latest diff --git a/cs/samples/StoreCustomTypes/StoreCustomTypes.csproj b/cs/samples/StoreCustomTypes/StoreCustomTypes.csproj index 21f4b4085..7dded3fe4 100644 --- a/cs/samples/StoreCustomTypes/StoreCustomTypes.csproj +++ b/cs/samples/StoreCustomTypes/StoreCustomTypes.csproj @@ -1,9 +1,9 @@  - netcoreapp3.1 + net5.0 x64 - win7-x64 + latest diff --git a/cs/samples/StoreDiskReadBenchmark/StoreDiskReadBenchmark.csproj b/cs/samples/StoreDiskReadBenchmark/StoreDiskReadBenchmark.csproj index 5202719d9..1bcabd6f4 100644 --- a/cs/samples/StoreDiskReadBenchmark/StoreDiskReadBenchmark.csproj +++ b/cs/samples/StoreDiskReadBenchmark/StoreDiskReadBenchmark.csproj @@ -1,9 +1,9 @@  - netcoreapp3.1 + net5.0 x64 - win7-x64;linux-x64 + latest diff --git a/cs/samples/StoreLogCompaction/StoreLogCompaction.csproj b/cs/samples/StoreLogCompaction/StoreLogCompaction.csproj index 0d269e4a0..867b88216 100644 --- a/cs/samples/StoreLogCompaction/StoreLogCompaction.csproj +++ b/cs/samples/StoreLogCompaction/StoreLogCompaction.csproj @@ -3,9 +3,9 @@ Exe true - netcoreapp3.1 + net5.0 x64 - win7-x64 + latest diff --git a/cs/samples/StoreVarLenTypes/StoreVarLenTypes.csproj b/cs/samples/StoreVarLenTypes/StoreVarLenTypes.csproj index fe98b2a62..c1922111a 100644 --- a/cs/samples/StoreVarLenTypes/StoreVarLenTypes.csproj +++ b/cs/samples/StoreVarLenTypes/StoreVarLenTypes.csproj @@ -1,9 +1,9 @@  - netcoreapp3.1 + net5.0 x64 - win7-x64 + latest diff --git a/cs/src/core/Allocator/AllocatorBase.cs b/cs/src/core/Allocator/AllocatorBase.cs index 1ea9a9c57..105178234 100644 --- a/cs/src/core/Allocator/AllocatorBase.cs +++ b/cs/src/core/Allocator/AllocatorBase.cs @@ -224,7 +224,7 @@ public abstract partial class AllocatorBase : IDisposable /// /// Error handling /// - private readonly ErrorList errorList = new ErrorList(); + private readonly ErrorList errorList = new(); /// /// Observer for records entering read-only region diff --git a/cs/src/core/Allocator/GenericAllocator.cs b/cs/src/core/Allocator/GenericAllocator.cs index 7f50cf5a5..ffa13e010 100644 --- a/cs/src/core/Allocator/GenericAllocator.cs +++ b/cs/src/core/Allocator/GenericAllocator.cs @@ -395,7 +395,7 @@ private void WriteAsync(long flushPage, ulong alignedDestinationAddres List addr = new List(); asyncResult.freeBuffer1 = buffer; - MemoryStream ms = new MemoryStream(); + MemoryStream ms = new(); IObjectSerializer keySerializer = null; IObjectSerializer valueSerializer = null; @@ -593,7 +593,7 @@ private void AsyncReadPageWithObjectsCallback(uint errorCode, uint num // Deserialize all objects until untilptr if (result.resumePtr < result.untilPtr) { - MemoryStream ms = new MemoryStream(result.freeBuffer2.buffer); + MemoryStream ms = new(result.freeBuffer2.buffer); ms.Seek(result.freeBuffer2.offset, SeekOrigin.Begin); Deserialize(result.freeBuffer1.GetValidPointer(), result.resumePtr, result.untilPtr, src, ms); ms.Dispose(); diff --git a/cs/src/core/Allocator/MallocFixedPageSize.cs b/cs/src/core/Allocator/MallocFixedPageSize.cs index 2b4464b8a..bf8da4aab 100644 --- a/cs/src/core/Allocator/MallocFixedPageSize.cs +++ b/cs/src/core/Allocator/MallocFixedPageSize.cs @@ -44,7 +44,7 @@ internal async ValueTask WaitAsync(CancellationToken cancellationToken) internal void Decrement() { - if (this.asyncTcs is {}) + if (this.asyncTcs is not null) { Debug.Assert(this.remaining > 0); if (Interlocked.Decrement(ref this.remaining) == 0) diff --git a/cs/src/core/Async/UpdateAsync.cs b/cs/src/core/Async/UpdateAsync.cs index 6222920e1..87d981b96 100644 --- a/cs/src/core/Async/UpdateAsync.cs +++ b/cs/src/core/Async/UpdateAsync.cs @@ -122,7 +122,7 @@ internal Status Complete() { if (_exception != default) _exception.Throw(); - if (flushEvent is { }) + if (!flushEvent.IsDefault()) flushEvent.Wait(); while (!this.TryCompleteSync(asyncOp: false, out flushEvent, out asyncResult)) { diff --git a/cs/src/core/ClientSession/FASTERClientSession.cs b/cs/src/core/ClientSession/FASTERClientSession.cs index 45b8b5f46..1f1d049a5 100644 --- a/cs/src/core/ClientSession/FASTERClientSession.cs +++ b/cs/src/core/ClientSession/FASTERClientSession.cs @@ -11,7 +11,7 @@ namespace FASTER.core { public unsafe partial class FasterKV : FasterBase, IFasterKV { - internal Dictionary _activeSessions = new Dictionary(); + internal Dictionary _activeSessions = new(); /// /// Client session type helper diff --git a/cs/src/core/Device/Devices.cs b/cs/src/core/Device/Devices.cs index 9d8dc9eb4..1de1ae936 100644 --- a/cs/src/core/Device/Devices.cs +++ b/cs/src/core/Device/Devices.cs @@ -29,7 +29,7 @@ public static IDevice CreateLogDevice(string logPath, bool preallocateFile = fal { IDevice logDevice; -#if NETSTANDARD +#if NETSTANDARD || NET if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { logDevice = new ManagedLocalStorageDevice(logPath, preallocateFile, deleteOnClose, capacity, recoverDevice); diff --git a/cs/src/core/Device/LocalStorageDevice.cs b/cs/src/core/Device/LocalStorageDevice.cs index 300792bea..3468ec242 100644 --- a/cs/src/core/Device/LocalStorageDevice.cs +++ b/cs/src/core/Device/LocalStorageDevice.cs @@ -15,6 +15,9 @@ namespace FASTER.core /// /// Local storage device /// +#if NET5_0 + [System.Runtime.Versioning.SupportedOSPlatform("windows")] +#endif public unsafe class LocalStorageDevice : StorageDeviceBase { /// @@ -98,7 +101,7 @@ protected internal LocalStorageDevice(string filename, bool useIoCompletionPort = true) : base(filename, GetSectorSize(filename), capacity) { -#if NETSTANDARD +#if NETSTANDARD || NET if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { throw new FasterException("Cannot use LocalStorageDevice from non-Windows OS platform, use ManagedLocalStorageDevice instead."); @@ -142,13 +145,13 @@ protected internal LocalStorageDevice(string filename, private void RecoverFiles() { - FileInfo fi = new FileInfo(FileName); // may not exist + FileInfo fi = new(FileName); // may not exist DirectoryInfo di = fi.Directory; if (!di.Exists) return; string bareName = fi.Name; - List segids = new List(); + List segids = new(); foreach (System.IO.FileInfo item in di.GetFiles(bareName + "*")) { segids.Add(int.Parse(item.Name.Replace(bareName, "").Replace(".", ""))); @@ -535,6 +538,9 @@ unsafe sealed class SimpleAsyncResult : IAsyncResult public bool IsCompleted => throw new NotImplementedException(); } +#if NET5_0 + [System.Runtime.Versioning.SupportedOSPlatform("windows")] +#endif unsafe sealed class LocalStorageDeviceCompletionWorker { public void Start(IntPtr ioCompletionPort, IOCompletionCallback _callback) diff --git a/cs/src/core/Device/ManagedLocalStorageDevice.cs b/cs/src/core/Device/ManagedLocalStorageDevice.cs index 1089da635..496aa5617 100644 --- a/cs/src/core/Device/ManagedLocalStorageDevice.cs +++ b/cs/src/core/Device/ManagedLocalStorageDevice.cs @@ -41,7 +41,7 @@ public sealed class ManagedLocalStorageDevice : StorageDeviceBase public ManagedLocalStorageDevice(string filename, bool preallocateFile = false, bool deleteOnClose = false, long capacity = Devices.CAPACITY_UNSPECIFIED, bool recoverDevice = false, bool osReadBuffering = false) : base(filename, GetSectorSize(filename), capacity) { - pool = new SectorAlignedBufferPool(1, 1); + pool = new(1, 1); ThrottleLimit = 120; string path = new FileInfo(filename).Directory.FullName; @@ -52,7 +52,7 @@ public ManagedLocalStorageDevice(string filename, bool preallocateFile = false, this.preallocateFile = preallocateFile; this.deleteOnClose = deleteOnClose; this.osReadBuffering = osReadBuffering; - logHandles = new SafeConcurrentDictionary, AsyncPool)>(); + logHandles = new(); if (recoverDevice) RecoverFiles(); } @@ -63,13 +63,13 @@ public ManagedLocalStorageDevice(string filename, bool preallocateFile = false, private void RecoverFiles() { - FileInfo fi = new FileInfo(FileName); // may not exist + FileInfo fi = new(FileName); // may not exist DirectoryInfo di = fi.Directory; if (!di.Exists) return; string bareName = fi.Name; - List segids = new List(); + List segids = new(); foreach (FileInfo item in di.GetFiles(bareName + "*")) { segids.Add(Int32.Parse(item.Name.Replace(bareName, "").Replace(".", ""))); @@ -114,7 +114,7 @@ public override void ReadAsync(int segmentId, ulong sourceAddress, bool gotHandle; int numBytes = 0; -#if NETSTANDARD2_1 +#if NETSTANDARD2_1 || NET UnmanagedMemoryManager umm = default; #else SectorAlignedMemory memory = default; @@ -128,7 +128,7 @@ public override void ReadAsync(int segmentId, ulong sourceAddress, if (gotHandle) { logReadHandle.Seek((long)sourceAddress, SeekOrigin.Begin); -#if NETSTANDARD2_1 +#if NETSTANDARD2_1 || NET unsafe { umm = new UnmanagedMemoryManager((byte*)destinationAddress, (int)readLength); @@ -154,7 +154,7 @@ public override void ReadAsync(int segmentId, ulong sourceAddress, Interlocked.Decrement(ref numPending); // Perform pool returns and disposals -#if !NETSTANDARD2_1 +#if !(NETSTANDARD2_1 || NET) memory?.Return(); #endif if (logReadHandle != null) streampool?.Return(logReadHandle); @@ -172,7 +172,7 @@ public override void ReadAsync(int segmentId, ulong sourceAddress, { logReadHandle = await streampool.GetAsync().ConfigureAwait(false); logReadHandle.Seek((long)sourceAddress, SeekOrigin.Begin); -#if NETSTANDARD2_1 +#if NETSTANDARD2_1 || NET unsafe { umm = new UnmanagedMemoryManager((byte*)destinationAddress, (int)readLength); @@ -197,7 +197,7 @@ public override void ReadAsync(int segmentId, ulong sourceAddress, Interlocked.Decrement(ref numPending); // Perform pool returns and disposals -#if !NETSTANDARD2_1 +#if !(NETSTANDARD2_1 || NET) memory?.Return(); #endif if (logReadHandle != null) streampool?.Return(logReadHandle); @@ -212,7 +212,7 @@ public override void ReadAsync(int segmentId, ulong sourceAddress, { numBytes = await readTask.ConfigureAwait(false); -#if !NETSTANDARD2_1 +#if !(NETSTANDARD2_1 || NET) unsafe { fixed (void* source = memory.buffer) @@ -233,7 +233,7 @@ public override void ReadAsync(int segmentId, ulong sourceAddress, Interlocked.Decrement(ref numPending); // Perform pool returns and disposals -#if !NETSTANDARD2_1 +#if !(NETSTANDARD2_1 || NET) memory?.Return(); #endif // Sequentialize all reads from same handle @@ -267,7 +267,7 @@ public override void WriteAsync(IntPtr sourceAddress, Task writeTask = default; bool gotHandle; -#if NETSTANDARD2_1 +#if NETSTANDARD2_1 || NET UnmanagedMemoryManager umm = default; #else SectorAlignedMemory memory = default; @@ -283,7 +283,7 @@ public override void WriteAsync(IntPtr sourceAddress, if (gotHandle) { logWriteHandle.Seek((long)destinationAddress, SeekOrigin.Begin); -#if NETSTANDARD2_1 +#if NETSTANDARD2_1 || NET unsafe { umm = new UnmanagedMemoryManager((byte*)sourceAddress, (int)numBytesToWrite); @@ -316,7 +316,7 @@ public override void WriteAsync(IntPtr sourceAddress, Interlocked.Decrement(ref numPending); // Perform pool returns and disposals -#if !NETSTANDARD2_1 +#if !(NETSTANDARD2_1 || NET) memory?.Return(); #endif if (logWriteHandle != null) streampool?.Return(logWriteHandle); @@ -334,7 +334,7 @@ public override void WriteAsync(IntPtr sourceAddress, { logWriteHandle = await streampool.GetAsync().ConfigureAwait(false); logWriteHandle.Seek((long)destinationAddress, SeekOrigin.Begin); -#if NETSTANDARD2_1 +#if NETSTANDARD2_1 || NET unsafe { umm = new UnmanagedMemoryManager((byte*)sourceAddress, (int)numBytesToWrite); @@ -366,7 +366,7 @@ public override void WriteAsync(IntPtr sourceAddress, Interlocked.Decrement(ref numPending); // Perform pool returns and disposals -#if !NETSTANDARD2_1 +#if !(NETSTANDARD2_1 || NET) memory?.Return(); #endif if (logWriteHandle != null) streampool?.Return(logWriteHandle); @@ -394,7 +394,7 @@ public override void WriteAsync(IntPtr sourceAddress, Interlocked.Decrement(ref numPending); // Perform pool returns and disposals -#if !NETSTANDARD2_1 +#if !(NETSTANDARD2_1 || NET) memory?.Return(); #endif // Sequentialize all writes to same handle @@ -471,7 +471,7 @@ private string GetSegmentName(int segmentId) private static uint GetSectorSize(string filename) { -#if NETSTANDARD +#if NETSTANDARD || NET if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { Debug.WriteLine("Assuming 512 byte sector alignment for disk with file " + filename); diff --git a/cs/src/core/Device/StorageDeviceBase.cs b/cs/src/core/Device/StorageDeviceBase.cs index 2c7fda6bb..65190bb73 100644 --- a/cs/src/core/Device/StorageDeviceBase.cs +++ b/cs/src/core/Device/StorageDeviceBase.cs @@ -169,7 +169,7 @@ public void ReadAsync(ulong alignedSourceAddress, IntPtr alignedDestinationAddre /// public virtual void RemoveSegment(int segment) { - ManualResetEventSlim completionEvent = new ManualResetEventSlim(false); + ManualResetEventSlim completionEvent = new(false); RemoveSegmentAsync(segment, r => completionEvent.Set(), null); completionEvent.Wait(); } @@ -189,7 +189,7 @@ public void TruncateUntilSegmentAsync(int toSegment, AsyncCallback callback, IAs callback(result); return; } - CountdownEvent countdown = new CountdownEvent(toSegment - oldStart); + CountdownEvent countdown = new(toSegment - oldStart); // This action needs to be epoch-protected because readers may be issuing reads to the deleted segment, unaware of the delete. // Because of earlier compare-and-swap, the caller has exclusive access to the range [oldStartSegment, newStartSegment), and there will // be no double deletes. @@ -214,7 +214,7 @@ public void TruncateUntilSegmentAsync(int toSegment, AsyncCallback callback, IAs /// public void TruncateUntilSegment(int toSegment) { - using (ManualResetEventSlim completionEvent = new ManualResetEventSlim(false)) + using (ManualResetEventSlim completionEvent = new(false)) { TruncateUntilSegmentAsync(toSegment, r => completionEvent.Set(), null); completionEvent.Wait(); @@ -239,7 +239,7 @@ public virtual void TruncateUntilAddressAsync(long toAddress, AsyncCallback call /// public virtual void TruncateUntilAddress(long toAddress) { - using (ManualResetEventSlim completionEvent = new ManualResetEventSlim(false)) + using (ManualResetEventSlim completionEvent = new(false)) { TruncateUntilAddressAsync(toAddress, r => completionEvent.Set(), null); completionEvent.Wait(); diff --git a/cs/src/core/Device/TieredStorageDevice.cs b/cs/src/core/Device/TieredStorageDevice.cs index 0b5556121..8a3c6a098 100644 --- a/cs/src/core/Device/TieredStorageDevice.cs +++ b/cs/src/core/Device/TieredStorageDevice.cs @@ -149,7 +149,7 @@ private static long ComputeCapacity(IList devices) private static string ComputeFileString(IList devices, int commitPoint) { - StringBuilder result = new StringBuilder(); + StringBuilder result = new(); foreach (IDevice device in devices) { string formatString = "{0}, file name {1}, capacity {2} bytes;"; diff --git a/cs/src/core/FASTER.core.csproj b/cs/src/core/FASTER.core.csproj index be14ff619..c3f3080c6 100644 --- a/cs/src/core/FASTER.core.csproj +++ b/cs/src/core/FASTER.core.csproj @@ -1,9 +1,9 @@  - netstandard2.1;netstandard2.0;net461 + net5.0;netstandard2.1;netstandard2.0;net461 AnyCPU;x64 - 8 + latest diff --git a/cs/src/core/FASTER.core.nuspec b/cs/src/core/FASTER.core.nuspec index f11ff81d3..14c60ebf1 100644 --- a/cs/src/core/FASTER.core.nuspec +++ b/cs/src/core/FASTER.core.nuspec @@ -20,20 +20,24 @@ - + - - + + + + + + @@ -46,5 +50,8 @@ + + + diff --git a/cs/src/core/Index/Common/CompletedOutput.cs b/cs/src/core/Index/Common/CompletedOutput.cs index bd6b7fbd2..9ab8f7fa9 100644 --- a/cs/src/core/Index/Common/CompletedOutput.cs +++ b/cs/src/core/Index/Common/CompletedOutput.cs @@ -133,12 +133,12 @@ internal void Dispose() { var tempKeyContainer = keyContainer; keyContainer = default; - if (tempKeyContainer is { }) + if (tempKeyContainer is not null) tempKeyContainer.Dispose(); var tempInputContainer = inputContainer; inputContainer = default; - if (tempInputContainer is { }) + if (tempInputContainer is not null) tempInputContainer.Dispose(); Output = default; diff --git a/cs/src/core/Index/Common/Contexts.cs b/cs/src/core/Index/Common/Contexts.cs index 52b2c12ea..ab6f0cb10 100644 --- a/cs/src/core/Index/Common/Contexts.cs +++ b/cs/src/core/Index/Common/Contexts.cs @@ -412,7 +412,7 @@ internal void Recover(Guid token, ICheckpointManager checkpointManager, DeltaLog if (metadata == null) throw new FasterException("Invalid log commit metadata for ID " + token.ToString()); - using (StreamReader s = new StreamReader(new MemoryStream(metadata))) + using (StreamReader s = new(new MemoryStream(metadata))) Initialize(s); } @@ -421,9 +421,9 @@ internal void Recover(Guid token, ICheckpointManager checkpointManager, DeltaLog /// public byte[] ToByteArray() { - using (MemoryStream ms = new MemoryStream()) + using (MemoryStream ms = new()) { - using (StreamWriter writer = new StreamWriter(ms)) + using (StreamWriter writer = new(ms)) { writer.WriteLine(CheckpointVersion); // checkpoint version writer.WriteLine(Checksum(checkpointTokens.Count)); // checksum @@ -610,15 +610,15 @@ public void Recover(Guid guid, ICheckpointManager checkpointManager) var metadata = checkpointManager.GetIndexCheckpointMetadata(guid); if (metadata == null) throw new FasterException("Invalid index commit metadata for ID " + guid.ToString()); - using (StreamReader s = new StreamReader(new MemoryStream(metadata))) + using (StreamReader s = new(new MemoryStream(metadata))) Initialize(s); } public readonly byte[] ToByteArray() { - using (MemoryStream ms = new MemoryStream()) + using (MemoryStream ms = new()) { - using (var writer = new StreamWriter(ms)) + using (StreamWriter writer = new(ms)) { writer.WriteLine(CheckpointVersion); // checkpoint version writer.WriteLine(Checksum()); // checksum diff --git a/cs/src/core/Index/FASTER/FASTER.cs b/cs/src/core/Index/FASTER/FASTER.cs index 2a04fadfe..c9cef24e9 100644 --- a/cs/src/core/Index/FASTER/FASTER.cs +++ b/cs/src/core/Index/FASTER/FASTER.cs @@ -472,7 +472,7 @@ public async ValueTask CompleteCheckpointAsync(CancellationToken token = default systemState.phase == Phase.IN_PROGRESS_GROW) return; - List valueTasks = new List(); + List valueTasks = new(); ThreadStateMachineStep(null, NullFasterSession.Instance, valueTasks, token); @@ -806,11 +806,11 @@ private unsafe string DumpDistributionInternal(int version) var ptable_ = state[version].tableAligned; long total_record_count = 0; long beginAddress = hlog.BeginAddress; - Dictionary histogram = new Dictionary(); + Dictionary histogram = new(); for (long bucket = 0; bucket < table_size_; ++bucket) { - List tags = new List(); + List tags = new(); int cnt = 0; HashBucket b = *(ptable_ + bucket); while (true) diff --git a/cs/src/core/Index/FASTER/FASTERThread.cs b/cs/src/core/Index/FASTER/FASTERThread.cs index 4d93bc598..a691c9587 100644 --- a/cs/src/core/Index/FASTER/FASTERThread.cs +++ b/cs/src/core/Index/FASTER/FASTERThread.cs @@ -329,7 +329,7 @@ internal void InternalCompletePendingRequest public readonly byte[] ToByteArray() { - using (var ms = new MemoryStream()) + using MemoryStream ms = new(); + using (BinaryWriter writer = new(ms)) { - using (var writer = new BinaryWriter(ms)) + writer.Write(0); // version + writer.Write(BeginAddress ^ FlushedUntilAddress); // checksum + writer.Write(BeginAddress); + writer.Write(FlushedUntilAddress); + if (Iterators?.Count > 0) { - writer.Write(0); // version - writer.Write(BeginAddress ^ FlushedUntilAddress); // checksum - writer.Write(BeginAddress); - writer.Write(FlushedUntilAddress); - if (Iterators?.Count > 0) + writer.Write(Iterators.Count); + foreach (var kvp in Iterators) { - writer.Write(Iterators.Count); - foreach (var kvp in Iterators) - { - writer.Write(kvp.Key); - writer.Write(kvp.Value); - } - } - else - { - writer.Write(0); + writer.Write(kvp.Key); + writer.Write(kvp.Value); } } - return ms.ToArray(); + else + { + writer.Write(0); + } } + return ms.ToArray(); } /// diff --git a/cs/src/core/Index/FasterLog/LocalLogCommitManager.cs b/cs/src/core/Index/FasterLog/LocalLogCommitManager.cs index 4f649bef0..f47bd16bc 100644 --- a/cs/src/core/Index/FasterLog/LocalLogCommitManager.cs +++ b/cs/src/core/Index/FasterLog/LocalLogCommitManager.cs @@ -31,13 +31,13 @@ public LocalLogCommitManager(string commitFile) public void Commit(long beginAddress, long untilAddress, byte[] commitMetadata) { // Two phase to ensure we write metadata in single Write operation - using var ms = new MemoryStream(); - using (var writer = new BinaryWriter(ms)) + using MemoryStream ms = new(); + using (BinaryWriter writer = new(ms)) { writer.Write(commitMetadata.Length); writer.Write(commitMetadata); } - using (var writer = new BinaryWriter(new FileStream(commitFile, FileMode.OpenOrCreate))) + using (BinaryWriter writer = new(new FileStream(commitFile, FileMode.OpenOrCreate))) { writer.Write(ms.ToArray()); writer.Flush(); diff --git a/cs/src/core/Index/Interfaces/IAdvancedFunctions.cs b/cs/src/core/Index/Interfaces/IAdvancedFunctions.cs index 13b9d2aa6..e590637f6 100644 --- a/cs/src/core/Index/Interfaces/IAdvancedFunctions.cs +++ b/cs/src/core/Index/Interfaces/IAdvancedFunctions.cs @@ -70,7 +70,7 @@ public interface IAdvancedFunctions /// The user input to be used for computing the updated value /// The existing value that would be copied. bool NeedCopyUpdate(ref Key key, ref Input input, ref Value oldValue) -#if NETSTANDARD2_1 +#if NETSTANDARD2_1 || NET => true #endif ; diff --git a/cs/src/core/Index/Interfaces/IFunctions.cs b/cs/src/core/Index/Interfaces/IFunctions.cs index c19fb5378..a0abbb9d2 100644 --- a/cs/src/core/Index/Interfaces/IFunctions.cs +++ b/cs/src/core/Index/Interfaces/IFunctions.cs @@ -69,7 +69,7 @@ public interface IFunctions /// The user input to be used for computing the updated value /// The existing value that would be copied. bool NeedCopyUpdate(ref Key key, ref Input input, ref Value oldValue) -#if NETSTANDARD2_1 +#if NETSTANDARD2_1 || NET => true #endif ; diff --git a/cs/src/core/Index/Interfaces/NullFasterSession.cs b/cs/src/core/Index/Interfaces/NullFasterSession.cs index c17a7ffd8..39a9b0d2c 100644 --- a/cs/src/core/Index/Interfaces/NullFasterSession.cs +++ b/cs/src/core/Index/Interfaces/NullFasterSession.cs @@ -2,7 +2,7 @@ { struct NullFasterSession : IFasterSession { - public static readonly NullFasterSession Instance = new NullFasterSession(); + public static readonly NullFasterSession Instance = new(); public void CheckpointCompletionCallback(string guid, CommitPoint commitPoint) { diff --git a/cs/src/core/Index/Recovery/DirectoryConfiguration.cs b/cs/src/core/Index/Recovery/DirectoryConfiguration.cs index 34429fd58..0e8d9407f 100644 --- a/cs/src/core/Index/Recovery/DirectoryConfiguration.cs +++ b/cs/src/core/Index/Recovery/DirectoryConfiguration.cs @@ -29,16 +29,16 @@ public void CreateIndexCheckpointFolder(Guid token) { var directory = GetIndexCheckpointFolder(token); Directory.CreateDirectory(directory); - DirectoryInfo directoryInfo = new System.IO.DirectoryInfo(directory); - foreach (System.IO.FileInfo file in directoryInfo.GetFiles()) + DirectoryInfo directoryInfo = new(directory); + foreach (FileInfo file in directoryInfo.GetFiles()) file.Delete(); } public void CreateHybridLogCheckpointFolder(Guid token) { var directory = GetHybridLogCheckpointFolder(token); Directory.CreateDirectory(directory); - DirectoryInfo directoryInfo = new System.IO.DirectoryInfo(directory); - foreach (System.IO.FileInfo file in directoryInfo.GetFiles()) + DirectoryInfo directoryInfo = new(directory); + foreach (FileInfo file in directoryInfo.GetFiles()) file.Delete(); } diff --git a/cs/src/core/Index/Recovery/LocalCheckpointManager.cs b/cs/src/core/Index/Recovery/LocalCheckpointManager.cs index efe65f23b..dc0db7142 100644 --- a/cs/src/core/Index/Recovery/LocalCheckpointManager.cs +++ b/cs/src/core/Index/Recovery/LocalCheckpointManager.cs @@ -21,7 +21,7 @@ public sealed class LocalCheckpointManager : ICheckpointManager /// public LocalCheckpointManager(string CheckpointDir) { - directoryConfiguration = new DirectoryConfiguration(CheckpointDir); + directoryConfiguration = new(CheckpointDir); } /// @@ -58,7 +58,7 @@ public void InitializeLogCheckpoint(Guid logToken) public void CommitIndexCheckpoint(Guid indexToken, byte[] commitMetadata) { string filename = directoryConfiguration.GetIndexCheckpointMetaFileName(indexToken); - using (var writer = new BinaryWriter(new FileStream(filename, FileMode.Create))) + using (BinaryWriter writer = new(new FileStream(filename, FileMode.Create))) { writer.Write(commitMetadata.Length); writer.Write(commitMetadata); @@ -67,10 +67,8 @@ public void CommitIndexCheckpoint(Guid indexToken, byte[] commitMetadata) string completed_filename = directoryConfiguration.GetIndexCheckpointFolder(indexToken); completed_filename += Path.DirectorySeparatorChar + "completed.dat"; - using (var file = new FileStream(completed_filename, FileMode.Create)) - { - file.Flush(); - } + using FileStream file = new(completed_filename, FileMode.Create); + file.Flush(); } /// @@ -81,7 +79,7 @@ public void CommitIndexCheckpoint(Guid indexToken, byte[] commitMetadata) public void CommitLogCheckpoint(Guid logToken, byte[] commitMetadata) { string filename = directoryConfiguration.GetHybridLogCheckpointMetaFileName(logToken); - using (var writer = new BinaryWriter(new FileStream(filename, FileMode.Create))) + using (BinaryWriter writer = new(new FileStream(filename, FileMode.Create))) { writer.Write(commitMetadata.Length); writer.Write(commitMetadata); @@ -90,10 +88,8 @@ public void CommitLogCheckpoint(Guid logToken, byte[] commitMetadata) string completed_filename = directoryConfiguration.GetHybridLogCheckpointFolder(logToken); completed_filename += Path.DirectorySeparatorChar + "completed.dat"; - using (var file = new FileStream(completed_filename, FileMode.Create)) - { - file.Flush(); - } + using FileStream file = new(completed_filename, FileMode.Create); + file.Flush(); } /// @@ -103,16 +99,14 @@ public void CommitLogCheckpoint(Guid logToken, byte[] commitMetadata) /// Metadata, or null if invalid public byte[] GetIndexCheckpointMetadata(Guid indexToken) { - var dir = new DirectoryInfo(directoryConfiguration.GetIndexCheckpointFolder(indexToken)); + DirectoryInfo dir = new(directoryConfiguration.GetIndexCheckpointFolder(indexToken)); if (!File.Exists(dir.FullName + Path.DirectorySeparatorChar + "completed.dat")) return null; string filename = directoryConfiguration.GetIndexCheckpointMetaFileName(indexToken); - using (var reader = new BinaryReader(new FileStream(filename, FileMode.Open))) - { - var len = reader.ReadInt32(); - return reader.ReadBytes(len); - } + using BinaryReader reader = new(new FileStream(filename, FileMode.Open)); + var len = reader.ReadInt32(); + return reader.ReadBytes(len); } /// @@ -144,16 +138,14 @@ public byte[] GetLogCheckpointMetadata(Guid logToken, DeltaLog deltaLog) if (metadata != null) return metadata; } - var dir = new DirectoryInfo(directoryConfiguration.GetHybridLogCheckpointFolder(logToken)); + DirectoryInfo dir = new(directoryConfiguration.GetHybridLogCheckpointFolder(logToken)); if (!File.Exists(dir.FullName + Path.DirectorySeparatorChar + "completed.dat")) return null; string checkpointInfoFile = directoryConfiguration.GetHybridLogCheckpointMetaFileName(logToken); - using (var reader = new BinaryReader(new FileStream(checkpointInfoFile, FileMode.Open))) - { - var len = reader.ReadInt32(); - return reader.ReadBytes(len); - } + using BinaryReader reader = new(new FileStream(checkpointInfoFile, FileMode.Open)); + var len = reader.ReadInt32(); + return reader.ReadBytes(len); } /// @@ -199,7 +191,7 @@ public IDevice GetDeltaLogDevice(Guid token) /// public IEnumerable GetIndexCheckpointTokens() { - var indexCheckpointDir = new DirectoryInfo(directoryConfiguration.GetIndexCheckpointFolder()); + DirectoryInfo indexCheckpointDir = new(directoryConfiguration.GetIndexCheckpointFolder()); var dirs = indexCheckpointDir.GetDirectories(); foreach (var dir in dirs) { @@ -227,7 +219,7 @@ public IEnumerable GetIndexCheckpointTokens() /// public IEnumerable GetLogCheckpointTokens() { - var hlogCheckpointDir = new DirectoryInfo(directoryConfiguration.GetHybridLogCheckpointFolder()); + DirectoryInfo hlogCheckpointDir = new(directoryConfiguration.GetHybridLogCheckpointFolder()); var dirs = hlogCheckpointDir.GetDirectories(); foreach (var dir in dirs) { diff --git a/cs/src/core/Index/Recovery/Recovery.cs b/cs/src/core/Index/Recovery/Recovery.cs index 2ba832ad9..7bc258fae 100644 --- a/cs/src/core/Index/Recovery/Recovery.cs +++ b/cs/src/core/Index/Recovery/Recovery.cs @@ -33,8 +33,8 @@ internal class RecoveryStatus public ReadStatus[] readStatus; public FlushStatus[] flushStatus; - private readonly SemaphoreSlim readSemaphore = new SemaphoreSlim(0); - private readonly SemaphoreSlim flushSemaphore = new SemaphoreSlim(0); + private readonly SemaphoreSlim readSemaphore = new(0); + private readonly SemaphoreSlim flushSemaphore = new(0); public RecoveryStatus(int capacity, long startPage, diff --git a/cs/src/core/Index/Synchronization/FasterStateMachine.cs b/cs/src/core/Index/Synchronization/FasterStateMachine.cs index a3e213b12..594c8e2ab 100644 --- a/cs/src/core/Index/Synchronization/FasterStateMachine.cs +++ b/cs/src/core/Index/Synchronization/FasterStateMachine.cs @@ -155,7 +155,7 @@ private void ThreadStateMachineStep( // Issue CPR callback for full session if (ctx.serialNum != -1) { - List excludedSerialNos = new List(); + List excludedSerialNos = new(); foreach (var v in ctx.ioPendingRequests.Values) { excludedSerialNos.Add(v.serialNum); diff --git a/cs/src/core/Utilities/Native32.cs b/cs/src/core/Utilities/Native32.cs index 8e879088a..ecba29d51 100644 --- a/cs/src/core/Utilities/Native32.cs +++ b/cs/src/core/Utilities/Native32.cs @@ -305,7 +305,7 @@ public static void AffinitizeThreadShardedNuma(uint threadIdx, ushort nrOfProces /// public static bool EnableProcessPrivileges() { -#if NETSTANDARD +#if NETSTANDARD || NET if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return false; #endif @@ -351,7 +351,7 @@ private static uint CTL_CODE(uint DeviceType, uint Function, uint Method, uint A internal static bool EnableVolumePrivileges(string filename, SafeFileHandle handle) { -#if NETSTANDARD +#if NETSTANDARD || NET if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return false; #endif @@ -391,7 +391,7 @@ internal static bool EnableVolumePrivileges(string filename, SafeFileHandle hand /// public static bool SetFileSize(SafeFileHandle file_handle, long file_size) { -#if NETSTANDARD +#if NETSTANDARD || NET if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return false; #endif diff --git a/cs/src/core/Utilities/SafeConcurrentDictionary.cs b/cs/src/core/Utilities/SafeConcurrentDictionary.cs index 38aefddfb..89a1a7576 100644 --- a/cs/src/core/Utilities/SafeConcurrentDictionary.cs +++ b/cs/src/core/Utilities/SafeConcurrentDictionary.cs @@ -20,16 +20,16 @@ internal sealed class SafeConcurrentDictionary : IEnumerable dictionary; - private readonly ConcurrentDictionary keyLocks = new ConcurrentDictionary(); + private readonly ConcurrentDictionary keyLocks = new(); public SafeConcurrentDictionary() { - this.dictionary = new ConcurrentDictionary(); + this.dictionary = new(); } public SafeConcurrentDictionary(IEnumerable> initialCollection) { - this.dictionary = new ConcurrentDictionary(initialCollection); + this.dictionary = new(initialCollection); } /// diff --git a/cs/src/core/VarLen/IVariableLengthStruct.cs b/cs/src/core/VarLen/IVariableLengthStruct.cs index 2de57d7dd..849469708 100644 --- a/cs/src/core/VarLen/IVariableLengthStruct.cs +++ b/cs/src/core/VarLen/IVariableLengthStruct.cs @@ -33,7 +33,7 @@ public interface IVariableLengthStruct /// /// unsafe void Serialize(ref T source, void* destination) -#if NETSTANDARD2_1 +#if NETSTANDARD2_1 || NET => Buffer.MemoryCopy(Unsafe.AsPointer(ref source), destination, GetLength(ref source), GetLength(ref source)) #endif ; @@ -44,7 +44,7 @@ unsafe void Serialize(ref T source, void* destination) /// /// unsafe ref T AsRef(void* source) -#if NETSTANDARD2_1 +#if NETSTANDARD2_1 || NET => ref Unsafe.AsRef(source) #endif ; @@ -56,8 +56,8 @@ unsafe ref T AsRef(void* source) /// /// unsafe void Initialize(void* source, void* end) -#if NETSTANDARD2_1 - { } +#if NETSTANDARD2_1 || NET + { } #else ; #endif diff --git a/cs/src/devices/AzureStorageDevice/AzureStorageDevice.cs b/cs/src/devices/AzureStorageDevice/AzureStorageDevice.cs index 18fdc94a1..8a8be98a3 100644 --- a/cs/src/devices/AzureStorageDevice/AzureStorageDevice.cs +++ b/cs/src/devices/AzureStorageDevice/AzureStorageDevice.cs @@ -55,7 +55,7 @@ public class AzureStorageDevice : StorageDeviceBase public AzureStorageDevice(CloudBlobDirectory cloudBlobDirectory, string blobName, IBlobManager blobManager = null, bool underLease = false, bool deleteOnClose = false, long capacity = Devices.CAPACITY_UNSPECIFIED) : base($"{cloudBlobDirectory}/{blobName}", PAGE_BLOB_SECTOR_SIZE, capacity) { - this.blobs = new ConcurrentDictionary(); + this.blobs = new(); this.blobDirectory = cloudBlobDirectory; this.blobName = blobName; this.underLease = underLease; @@ -90,7 +90,7 @@ public AzureStorageDevice(string connectionString, string containerName, string var container = client.GetContainerReference(containerName); container.CreateIfNotExists(); - this.blobs = new ConcurrentDictionary(); + this.blobs = new(); this.blobDirectory = container.GetDirectoryReference(directoryName); this.blobName = blobName; this.underLease = underLease; @@ -388,7 +388,7 @@ public override void WriteAsync(IntPtr sourceAddress, int segmentId, ulong desti if (!blobs.TryGetValue(segmentId, out BlobEntry blobEntry)) { - BlobEntry entry = new BlobEntry(this.BlobManager); + BlobEntry entry = new(this.BlobManager); if (blobs.TryAdd(segmentId, entry)) { CloudPageBlob pageBlob = this.blobDirectory.GetPageBlobReference(GetSegmentBlobName(segmentId)); diff --git a/cs/src/devices/AzureStorageDevice/DefaultBlobManager.cs b/cs/src/devices/AzureStorageDevice/DefaultBlobManager.cs index 82725fe85..cb212f547 100644 --- a/cs/src/devices/AzureStorageDevice/DefaultBlobManager.cs +++ b/cs/src/devices/AzureStorageDevice/DefaultBlobManager.cs @@ -32,8 +32,8 @@ public class DefaultBlobManager : IBlobManager private const string LeaseBlobName = "lease"; private CloudBlockBlob leaseBlob; - static SemaphoreSlim AsynchronousStorageReadMaxConcurrency = new SemaphoreSlim(Environment.ProcessorCount * 25); - static SemaphoreSlim AsynchronousStorageWriteMaxConcurrency = new SemaphoreSlim(Environment.ProcessorCount * 25); + static readonly SemaphoreSlim AsynchronousStorageReadMaxConcurrency = new(Environment.ProcessorCount * 25); + static readonly SemaphoreSlim AsynchronousStorageWriteMaxConcurrency = new(Environment.ProcessorCount * 25); /// /// Create instance of blob manager diff --git a/cs/src/devices/AzureStorageDevice/FASTER.devices.AzureStorageDevice.csproj b/cs/src/devices/AzureStorageDevice/FASTER.devices.AzureStorageDevice.csproj index 4fb7f5ec6..e38f31b03 100644 --- a/cs/src/devices/AzureStorageDevice/FASTER.devices.AzureStorageDevice.csproj +++ b/cs/src/devices/AzureStorageDevice/FASTER.devices.AzureStorageDevice.csproj @@ -1,8 +1,9 @@  - net461;netstandard2.0;netstandard2.1 + net5.0;netstandard2.1;netstandard2.0;net461 AnyCPU;x64 + latest @@ -32,10 +33,6 @@ bin\$(Platform)\Release\ - - $(DefineConstants);DOTNETCORE - - diff --git a/cs/src/devices/AzureStorageDevice/FASTER.devices.AzureStorageDevice.nuspec b/cs/src/devices/AzureStorageDevice/FASTER.devices.AzureStorageDevice.nuspec index 59dee0b80..b720acca6 100644 --- a/cs/src/devices/AzureStorageDevice/FASTER.devices.AzureStorageDevice.nuspec +++ b/cs/src/devices/AzureStorageDevice/FASTER.devices.AzureStorageDevice.nuspec @@ -28,6 +28,10 @@ + + + + @@ -40,5 +44,8 @@ + + + diff --git a/cs/test/FASTER.test.csproj b/cs/test/FASTER.test.csproj index 220e97104..3507d6ef7 100644 --- a/cs/test/FASTER.test.csproj +++ b/cs/test/FASTER.test.csproj @@ -1,10 +1,11 @@  - netcoreapp3.1;netcoreapp2.1;net461 + net5.0;netcoreapp3.1;netcoreapp2.1;net461 + net5.0;netcoreapp3.1 AnyCPU;x64 + latest true - 8 diff --git a/cs/test/FasterLogTests.cs b/cs/test/FasterLogTests.cs index c39c662a1..a92fc61f8 100644 --- a/cs/test/FasterLogTests.cs +++ b/cs/test/FasterLogTests.cs @@ -83,7 +83,7 @@ public void Setup() [TearDown] public void TearDown() { - if (log is { }) + if (log is not null) log.Dispose(); manager.Dispose(); device.Dispose(); @@ -133,10 +133,10 @@ private async ValueTask AssertGetNext(IAsyncEnumerator<(byte[] entry, int entryL IAsyncEnumerator<(IMemoryOwner entry, int entryLength, long currentAddress, long nextAddress)> asyncMemoryOwnerIter, FasterLogScanIterator iter, byte[] expectedData = default, bool verifyAtEnd = false) { - if (asyncByteVectorIter is {}) + if (asyncByteVectorIter is not null) { Assert.IsTrue(await asyncByteVectorIter.MoveNextAsync()); - if (expectedData is {}) + if (expectedData is not null) Assert.IsTrue(asyncByteVectorIter.Current.entry.SequenceEqual(expectedData)); // MoveNextAsync() would hang here waiting for more entries @@ -145,10 +145,10 @@ private async ValueTask AssertGetNext(IAsyncEnumerator<(byte[] entry, int entryL return; } - if (asyncMemoryOwnerIter is {}) + if (asyncMemoryOwnerIter is not null) { Assert.IsTrue(await asyncMemoryOwnerIter.MoveNextAsync()); - if (expectedData is {}) + if (expectedData is not null) Assert.IsTrue(asyncMemoryOwnerIter.Current.entry.Memory.Span.ToArray().Take(expectedData.Length).SequenceEqual(expectedData)); asyncMemoryOwnerIter.Current.entry.Dispose(); @@ -159,7 +159,7 @@ private async ValueTask AssertGetNext(IAsyncEnumerator<(byte[] entry, int entryL } Assert.IsTrue(iter.GetNext(out byte[] result, out _, out _)); - if (expectedData is {}) + if (expectedData is not null) Assert.IsTrue(result.SequenceEqual(expectedData)); if (verifyAtEnd) Assert.IsFalse(iter.GetNext(out _, out _, out _)); diff --git a/cs/test/ReadAddressTests.cs b/cs/test/ReadAddressTests.cs index 8dae1e851..913f05e1e 100644 --- a/cs/test/ReadAddressTests.cs +++ b/cs/test/ReadAddressTests.cs @@ -102,7 +102,7 @@ public override void CopyUpdater(ref Key key, ref Value input, ref Value oldValu // 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 {}) + if (ctx is not null) { ctx.output = output; ctx.recordInfo = recordInfo; @@ -112,7 +112,7 @@ public override void ReadCompletionCallback(ref Key key, ref Value input, ref Va public override void RMWCompletionCallback(ref Key key, ref Value input, Context ctx, Status status) { - if (ctx is {}) + if (ctx is not null) { ctx.output = input; ctx.recordInfo = default; diff --git a/cs/test/SharedDirectoryTests.cs b/cs/test/SharedDirectoryTests.cs index 06804209d..8716d9202 100644 --- a/cs/test/SharedDirectoryTests.cs +++ b/cs/test/SharedDirectoryTests.cs @@ -133,7 +133,9 @@ public void Initialize(string checkpointDirectory, string logDirectory, bool pop for (int i = 0; i < segmentIds.Count; i++) { var segmentId = segmentIds[i]; +#pragma warning disable CA1416 // populateLogHandles will be false for non-windows var handle = LocalStorageDevice.CreateHandle(segmentId, disableFileBuffering: false, deleteOnClose: true, preallocateFile: false, segmentSize: -1, fileName: deviceFileName, IntPtr.Zero); +#pragma warning restore CA1416 initialHandles[i] = new KeyValuePair(segmentId, handle); } } diff --git a/cs/test/VariableLengthStructFASTERTests.cs b/cs/test/VariableLengthStructFASTERTests.cs index 801d99032..9f28b83d5 100644 --- a/cs/test/VariableLengthStructFASTERTests.cs +++ b/cs/test/VariableLengthStructFASTERTests.cs @@ -2,13 +2,7 @@ // Licensed under the MIT license. using System; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Collections.Generic; -using System.Linq; using FASTER.core; -using System.IO; using NUnit.Framework; namespace FASTER.test @@ -17,6 +11,11 @@ namespace FASTER.test [TestFixture] internal class VariableLengthStructFASTERTests { + // VarLenMax is the variable-length portion; 2 is for the fixed fields + const int VarLenMax = 10; + const int StackAllocMax = VarLenMax + 2; + int GetVarLen(Random r) => r.Next(VarLenMax) + 2; + [Test] [Category("FasterKV")] public unsafe void VariableLengthTest1() @@ -35,12 +34,14 @@ public unsafe void VariableLengthTest1() Input input = default; Random r = new Random(100); + // Single alloc outside the loop, to the max length we'll need. + int* val = stackalloc int[StackAllocMax]; + for (int i = 0; i < 5000; i++) { var key1 = new Key { key = i }; - var len = 2 + r.Next(10); - int* val = stackalloc int[len]; + var len = GetVarLen(r); ref VLValue value = ref *(VLValue*)val; for (int j = 0; j < len; j++) *(val + j) = len; @@ -96,17 +97,19 @@ public unsafe void VariableLengthTest2() Input input = default; Random r = new Random(100); + // Single alloc outside the loop, to the max length we'll need. + int* keyval = stackalloc int[StackAllocMax]; + int* val = stackalloc int[StackAllocMax]; + for (int i = 0; i < 5000; i++) { - var keylen = 2 + r.Next(10); - int* keyval = stackalloc int[keylen]; + var keylen = GetVarLen(r); ref VLValue key1 = ref *(VLValue*)keyval; key1.length = keylen; for (int j = 1; j < keylen; j++) *(keyval + j) = i; - var len = 2 + r.Next(10); - int* val = stackalloc int[len]; + var len = GetVarLen(r); ref VLValue value = ref *(VLValue*)val; for (int j = 0; j < len; j++) *(val + j) = len; @@ -117,8 +120,7 @@ public unsafe void VariableLengthTest2() r = new Random(100); for (int i = 0; i < 5000; i++) { - var keylen = 2 + r.Next(10); - int* keyval = stackalloc int[keylen]; + var keylen = GetVarLen(r); ref VLValue key1 = ref *(VLValue*)keyval; key1.length = keylen; for (int j = 1; j < keylen; j++)