Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes for "dotnet run" and run on linux
if merged, published app with memory-only pattern on linux will be able to run. this fix following problems. * strange NetCoreAssemblyReferences list is built in linux(because of TRUSTED_PLATFORM_ASSEMBLIES's spec) * exception occured when `dotnet run` because of differences of handling resource between core and netframework * get `..\Index\FASTER\FASTERImpl.cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8` from ResourceManager.GetString in netcoreapp * using EmbeddedResource instead * exception occured when calling LightEpoch.ReserveEntryForThread in linux(using Thread.CurrentThread.ManagedThreadId instead) * be careful to performance regression
- Loading branch information
Showing
14 changed files
with
465 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using FASTER.core; | ||
using System.Diagnostics; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace ManagedSample1 | ||
{ | ||
public unsafe class Functions | ||
{ | ||
public static void RMWCompletionCallback(KeyStruct* key, InputStruct* output, Empty* ctx, Status status) | ||
{ | ||
} | ||
|
||
public static void ReadCompletionCallback(KeyStruct* key, InputStruct* input, OutputStruct* output, Empty* ctx, Status status) | ||
{ | ||
} | ||
|
||
public static void UpsertCompletionCallback(KeyStruct* key, ValueStruct* output, Empty* ctx) | ||
{ | ||
} | ||
|
||
public static void PersistenceCallback(long thread_id, long serial_num) | ||
{ | ||
Debug.WriteLine("Thread {0} repors persistence until {1}", thread_id, serial_num); | ||
} | ||
|
||
// Read functions | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static void SingleReader(KeyStruct* key, InputStruct* input, ValueStruct* value, OutputStruct* dst) | ||
{ | ||
ValueStruct.Copy(value, (ValueStruct*)dst); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static void ConcurrentReader(KeyStruct* key, InputStruct* input, ValueStruct* value, OutputStruct* dst) | ||
{ | ||
ValueStruct.AcquireReadLock(value); | ||
ValueStruct.Copy(value, (ValueStruct*)dst); | ||
ValueStruct.ReleaseReadLock(value); | ||
} | ||
|
||
// Upsert functions | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static void SingleWriter(KeyStruct* key, ValueStruct* src, ValueStruct* dst) | ||
{ | ||
ValueStruct.Copy(src, dst); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static void ConcurrentWriter(KeyStruct* key, ValueStruct* src, ValueStruct* dst) | ||
{ | ||
ValueStruct.AcquireWriteLock(dst); | ||
ValueStruct.Copy(src, dst); | ||
ValueStruct.ReleaseWriteLock(dst); | ||
} | ||
|
||
// RMW functions | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static int InitialValueLength(KeyStruct* key, InputStruct* input) | ||
{ | ||
return ValueStruct.GetLength(default(ValueStruct*)); | ||
} | ||
|
||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static void InitialUpdater(KeyStruct* key, InputStruct* input, ValueStruct* value) | ||
{ | ||
ValueStruct.Copy((ValueStruct*)input, value); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static void InPlaceUpdater(KeyStruct* key, InputStruct* input, ValueStruct* value) | ||
{ | ||
ValueStruct.AcquireWriteLock(value); | ||
value->vfield1 += input->ifield1; | ||
value->vfield2 += input->ifield2; | ||
ValueStruct.ReleaseWriteLock(value); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static void CopyUpdater(KeyStruct* key, InputStruct* input, ValueStruct* oldValue, ValueStruct* newValue) | ||
{ | ||
newValue->vfield1 = oldValue->vfield1 + input->ifield1; | ||
newValue->vfield2 = oldValue->vfield2 + input->ifield2; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using FASTER.core; | ||
using System; | ||
|
||
namespace ManagedSample1 | ||
{ | ||
public unsafe interface ICustomFaster | ||
{ | ||
/* Thread-related operations */ | ||
Guid StartSession(); | ||
long ContinueSession(Guid guid); | ||
void StopSession(); | ||
void Refresh(); | ||
|
||
/* Store Interface */ | ||
Status Read(KeyStruct* key, InputStruct* input, OutputStruct* output, Empty* context, long lsn); | ||
Status Upsert(KeyStruct* key, ValueStruct* value, Empty* context, long lsn); | ||
Status RMW(KeyStruct* key, InputStruct* input, Empty* context, long lsn); | ||
Status Delete(KeyStruct* key, Empty* context, long lsn); | ||
bool CompletePending(bool wait); | ||
|
||
/* Statistics */ | ||
long Size { get; } | ||
void DumpDistribution(); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using System.Runtime.CompilerServices; | ||
|
||
namespace ManagedSample1 | ||
{ | ||
public unsafe struct InputStruct | ||
{ | ||
public long ifield1; | ||
public long ifield2; | ||
|
||
public static InputStruct* MoveToContext(InputStruct* input) | ||
{ | ||
return input; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using FASTER.core; | ||
using System; | ||
using System.IO; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace ManagedSample1 | ||
{ | ||
public unsafe struct KeyStruct | ||
{ | ||
public const int physicalSize = sizeof(long) + sizeof(long); | ||
public long kfield1; | ||
public long kfield2; | ||
|
||
public static long GetHashCode(KeyStruct* key) | ||
{ | ||
return Utility.GetHashCode(*((long*)key)); | ||
} | ||
public static bool Equals(KeyStruct* k1, KeyStruct* k2) | ||
{ | ||
return k1->kfield1 == k2->kfield1 && k1->kfield2 == k2->kfield2; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static int GetLength(KeyStruct* key) | ||
{ | ||
return physicalSize; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static void Copy(KeyStruct* src, KeyStruct* dst) | ||
{ | ||
dst->kfield1 = src->kfield1; | ||
dst->kfield2 = src->kfield2; | ||
} | ||
|
||
#region Serialization | ||
public static bool HasObjectsToSerialize() | ||
{ | ||
return false; | ||
} | ||
|
||
public static void Serialize(KeyStruct* key, Stream toStream) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public static void Deserialize(KeyStruct* key, Stream fromStream) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public static void Free(KeyStruct* key) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
#endregion | ||
|
||
public static KeyStruct* MoveToContext(KeyStruct* key) | ||
{ | ||
return key; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.1</TargetFramework> | ||
<Platforms>x64</Platforms> | ||
<RuntimeIdentifier>win-x64</RuntimeIdentifier> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<RootNamespace>ManagedSampleCore</RootNamespace> | ||
<ErrorReport>prompt</ErrorReport> | ||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||
<RestoreProjectStyle>PackageReference</RestoreProjectStyle> | ||
<Prefer32Bit>true</Prefer32Bit> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)' == 'Debug'"> | ||
<DefineConstants>TRACE;DEBUG</DefineConstants> | ||
<DebugType>full</DebugType> | ||
<DebugSymbols>true</DebugSymbols> | ||
<OutputPath>bin\x64\Debug\</OutputPath> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)' == 'Release'"> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\x64\Release\</OutputPath> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\core\FASTER.core.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
namespace ManagedSample1 | ||
{ | ||
public unsafe struct OutputStruct | ||
{ | ||
public ValueStruct value; | ||
|
||
public static OutputStruct* MoveToContext(OutputStruct* output) | ||
{ | ||
return output; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using FASTER.core; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ManagedSample1 | ||
{ | ||
public class Program | ||
{ | ||
static unsafe void Main(string[] args) | ||
{ | ||
var fht = FASTERFactory.Create | ||
<KeyStruct, ValueStruct, InputStruct, OutputStruct, Empty, Functions, ICustomFaster> | ||
(128, FASTERFactory.CreateLogDevice(""), LogMutableFraction: 0.5); | ||
|
||
fht.StartSession(); | ||
|
||
OutputStruct output = default(OutputStruct); | ||
|
||
var key1 = new KeyStruct { kfield1 = 13, kfield2 = 14 }; | ||
var value = new ValueStruct { vfield1 = 23, vfield2 = 24 }; | ||
|
||
// Upsert item into store, and read it back | ||
fht.Upsert(&key1, &value, null, 0); | ||
fht.Read(&key1, null, &output, null, 0); | ||
|
||
if ((output.value.vfield1 != value.vfield1) || (output.value.vfield2 != value.vfield2)) | ||
Console.WriteLine("Error!"); | ||
else | ||
Console.WriteLine("Success!"); | ||
|
||
var key2 = new KeyStruct { kfield1 = 15, kfield2 = 16 }; | ||
var input = new InputStruct { ifield1 = 25, ifield2 = 26 }; | ||
|
||
// Two read-modify-write (RMW) operations (sum aggregator) | ||
// Followed by read of result | ||
fht.RMW(&key2, &input, null, 0); | ||
fht.RMW(&key2, &input, null, 0); | ||
fht.Read(&key2, null, &output, null, 0); | ||
|
||
if ((output.value.vfield1 != input.ifield1*2) || (output.value.vfield2 != input.ifield2*2)) | ||
Console.WriteLine("Error!"); | ||
else | ||
Console.WriteLine("Success!"); | ||
|
||
fht.StopSession(); | ||
|
||
Console.ReadLine(); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
cs/playground/ManagedSampleCore/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyCopyright("Copyright © 2017")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("17bdd0a5-98e5-464a-8a00-050d9ff4c562")] |
Oops, something went wrong.