Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support async/await session model #130

Merged
merged 118 commits into from
Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
484c674
Initial checkin
badrishc May 16, 2019
fc89978
Merge branch 'master' into async-support
badrishc May 21, 2019
63d1276
Merge branch 'master' into async-support
badrishc May 21, 2019
0c7bddd
Merge branch 'master' into async-support
badrishc Jul 10, 2019
3d17a2d
Merge branch 'master' into async-support
badrishc Jul 10, 2019
2b7e24f
Rough sketch of session without touching currrent thread-local framew…
badrishc Jul 11, 2019
00dc474
Improved support, added session pooling option, added session testcases.
badrishc Jul 12, 2019
533652b
Updates to session support
badrishc Jul 13, 2019
2fff5cb
Merge branch 'master' into async-support
badrishc Jul 24, 2019
6c5420a
Merge branch 'master' into async-support
badrishc Jul 26, 2019
4412113
Merge branch 'master' of https://github.com/Microsoft/FASTER into asy…
badrishc Jul 26, 2019
366a8cc
Merge branch 'async-support' of https://github.com/Microsoft/FASTER i…
badrishc Jul 26, 2019
0353678
Support large number of sessions (not limited by epoch table size). S…
badrishc Aug 1, 2019
7a487e3
Update FASTER.core.csproj
badrishc Aug 1, 2019
571333d
Initial checkin of async CompletePending - no tests yet.
badrishc Aug 3, 2019
d63603c
Merge branch 'async-support' of https://github.com/Microsoft/FASTER i…
badrishc Aug 3, 2019
c41855e
Update azure-pipelines.yml
badrishc Aug 3, 2019
252ef54
Update azure-pipelines.yml
badrishc Aug 3, 2019
2a2d7ac
Update azure-pipelines.yml
badrishc Aug 3, 2019
c67d882
Update azure-pipelines.yml
badrishc Aug 3, 2019
bcb75e7
Update azure-pipelines.yml
badrishc Aug 3, 2019
2eafe9b
Support suspend/resume sessions
badrishc Aug 6, 2019
0bd752e
Support true async CompleteCheckpoint
badrishc Aug 7, 2019
dbe13fd
Improved async sessions interface, working now. Does not persist doma…
badrishc Aug 8, 2019
1754b68
Persist dormant sessions correctly.
badrishc Aug 8, 2019
a486834
Update testcase
badrishc Aug 8, 2019
d72c92a
Correct handling of thread switching with async
badrishc Aug 9, 2019
869a88e
Merge branch 'master' into async-support
badrishc Aug 9, 2019
e5a4859
Merge branch 'async-support' of https://github.com/Microsoft/FASTER i…
badrishc Aug 9, 2019
82a01a5
Update
badrishc Aug 9, 2019
26be7f6
update
badrishc Aug 9, 2019
733e4de
update
badrishc Aug 9, 2019
30adeca
Updates and bugfixes
badrishc Aug 12, 2019
9e84d63
Removing sample test code.
badrishc Aug 12, 2019
9c60144
Update
badrishc Aug 13, 2019
d7064e8
Updated fast threadlocal
badrishc Aug 13, 2019
ea64fdf
Revert "Update"
badrishc Aug 13, 2019
363508c
Merge remote-tracking branch 'origin/async-support-test2' into async-…
badrishc Aug 13, 2019
789d38e
update
badrishc Aug 13, 2019
572b8bd
revert max threads in pool
badrishc Aug 13, 2019
4b75494
test
badrishc Aug 14, 2019
026912c
test
badrishc Aug 14, 2019
03c4d8e
Update azure-pipelines.yml for Azure Pipelines
badrishc Aug 14, 2019
e925af3
Update azure-pipelines.yml for Azure Pipelines
badrishc Aug 14, 2019
1c33b49
Update azure-pipelines.yml
badrishc Aug 14, 2019
4dc6d27
Update azure-pipelines.yml
badrishc Aug 14, 2019
5cda2f9
more tests, phew
badrishc Aug 15, 2019
68df34d
trying to reduce async context - incomplete
badrishc Aug 17, 2019
7e80b07
Merge branch 'master' into async-support
badrishc Aug 20, 2019
81a4a82
Merging from master
badrishc Aug 29, 2019
75b9cb2
Update
badrishc Sep 3, 2019
b16212f
Updates
badrishc Sep 4, 2019
b2479ed
Merge branch 'async-support-test' of https://github.com/Microsoft/FAS…
badrishc Sep 4, 2019
d03bcea
Updates
badrishc Sep 4, 2019
00fadc5
Merge branch 'master' into async-support-test
badrishc Sep 4, 2019
27b677e
Fixes
badrishc Sep 4, 2019
94b901e
Merge branch 'master' into async-support-test
badrishc Sep 4, 2019
9afc5fb
Wired in excluded serial nos for commit points.
badrishc Sep 5, 2019
62cecc8
Cleaning up interface and comments.
badrishc Sep 5, 2019
6cab32a
Fixing thread local init, cleanup
badrishc Sep 5, 2019
990d789
Merging from work branch
badrishc Sep 5, 2019
b9404b6
Fixing merge
badrishc Sep 5, 2019
78c2649
Updates to support sessions natively without thread-local
badrishc Sep 12, 2019
e170463
updates
badrishc Sep 12, 2019
38a26ff
Added tests
badrishc Sep 13, 2019
0740f87
Merge branch 'async-support' into async-support-test
badrishc Sep 13, 2019
669881d
Cleanup of warnings
badrishc Sep 13, 2019
29c64e1
Merge branch 'master' into async-support-test
badrishc Sep 13, 2019
16edd83
Initial checkin
badrishc Sep 17, 2019
3077f52
Updates.
badrishc Sep 17, 2019
853b3ea
Updates
badrishc Sep 17, 2019
6315a14
Cleaned up epochs, improved fine grain scalability.
badrishc Sep 18, 2019
19d5d82
Fixing test change
badrishc Sep 18, 2019
4ef03bb
Merge branch 'fasterlog' into async-support
badrishc Sep 18, 2019
ce31917
Fixing break after merge.
badrishc Sep 18, 2019
88d7269
Added commit and recovery support.
badrishc Sep 19, 2019
ddcc338
Added TryAppend so users can implement log throttling.
badrishc Sep 19, 2019
2cd85e3
Fasterlog lowmem (#178)
badrishc Sep 26, 2019
ec2a3b5
Fasterlog TryAppend (#179)
badrishc Sep 30, 2019
bb4e357
minor fix
badrishc Sep 30, 2019
4504937
merge
badrishc Sep 30, 2019
b06d112
Fasterlog async (#180)
badrishc Oct 3, 2019
002b993
Merge branch 'master' into fasterlog
badrishc Oct 4, 2019
944504b
Added tailing iterator WaitAsync to wait for iteration to proceed.
badrishc Oct 4, 2019
540d1a5
Merge branch 'fasterlog' of https://github.com/Microsoft/FASTER into …
badrishc Oct 4, 2019
80a2aeb
Convert Span to ReadOnlySpan for appends
badrishc Oct 4, 2019
0050694
Added MemoryPool/IMemoryOwner variant of iterator
badrishc Oct 4, 2019
127e908
Updates
badrishc Oct 4, 2019
6dc7af6
Updated way to pin pooled memory
badrishc Oct 4, 2019
ff27448
Update azure-pipelines.yml
badrishc Oct 4, 2019
72cdfdb
Merging from FasterLog branch for epoch and allocator goodness.
badrishc Oct 5, 2019
0c0bf58
Updates to merge
badrishc Oct 5, 2019
7565a21
Merging
badrishc Oct 5, 2019
8e42a74
Support minimum buffer size of just 1 page!
badrishc Oct 5, 2019
915f01e
Merge branch 'fasterlog' into async-support
badrishc Oct 6, 2019
089d545
Cleanup and updates.
badrishc Oct 7, 2019
c55de3f
Actually checking in support for 1 page in memory, added initial draf…
badrishc Oct 7, 2019
db68ae0
Added a test
badrishc Oct 7, 2019
5caea66
Improved sample, changed GetMemory to use byte[] instead of Span<byte>
badrishc Oct 7, 2019
e0f745f
Merging from fasterlog
badrishc Oct 7, 2019
fc47dbd
Merging goodness from master.
badrishc Oct 31, 2019
c4fba23
Merge branch 'master' into async-support
badrishc Oct 31, 2019
ca15128
Merge branch 'master' into async-support
badrishc Nov 14, 2019
0f65fbb
Merge branch 'master' into async-support
badrishc Nov 20, 2019
72ecc4f
Fixed break
badrishc Nov 20, 2019
a1b87a5
Merge branch 'master' into async-support
badrishc Dec 3, 2019
6b03887
Merge branch 'master' into async-support
badrishc Dec 3, 2019
876c0d3
Merging from master
badrishc Dec 4, 2019
b3cccd0
Fix merge
badrishc Dec 4, 2019
1eca340
Major API cleanup and porting to session-based interface
badrishc Dec 9, 2019
0237a0c
Added async API to sessions, added first draft of async sample.
badrishc Dec 10, 2019
255c000
Added tests
badrishc Dec 12, 2019
a16c5eb
Update README.md
badrishc Dec 12, 2019
95c0e58
Merge branch 'master' into async-support
badrishc Dec 14, 2019
0624fd5
Updates based on review.
badrishc Dec 19, 2019
b31631b
Merge branch 'async-support' of https://github.com/microsoft/FASTER i…
badrishc Dec 19, 2019
ecbf696
Minor fixes.
badrishc Dec 19, 2019
49866bf
fixed call to newsession
badrishc Dec 20, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cs/FASTER.sln
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FASTER.devices.AzureStorage
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FasterLogSample", "playground\FasterLogSample\FasterLogSample.csproj", "{25C5C6B6-4A8A-46DD-88C1-EB247033FE58}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FasterKVAsyncSample", "playground\FasterKVAsyncSample\FasterKVAsyncSample.csproj", "{859F76F4-93D8-4D60-BF9A-363E217FA247}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -166,6 +168,12 @@ Global
{25C5C6B6-4A8A-46DD-88C1-EB247033FE58}.Release|Any CPU.Build.0 = Release|x64
{25C5C6B6-4A8A-46DD-88C1-EB247033FE58}.Release|x64.ActiveCfg = Release|x64
{25C5C6B6-4A8A-46DD-88C1-EB247033FE58}.Release|x64.Build.0 = Release|x64
{859F76F4-93D8-4D60-BF9A-363E217FA247}.Debug|Any CPU.ActiveCfg = Debug|x64
{859F76F4-93D8-4D60-BF9A-363E217FA247}.Debug|x64.ActiveCfg = Debug|x64
{859F76F4-93D8-4D60-BF9A-363E217FA247}.Debug|x64.Build.0 = Debug|x64
{859F76F4-93D8-4D60-BF9A-363E217FA247}.Release|Any CPU.ActiveCfg = Release|x64
{859F76F4-93D8-4D60-BF9A-363E217FA247}.Release|x64.ActiveCfg = Release|x64
{859F76F4-93D8-4D60-BF9A-363E217FA247}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -187,6 +195,7 @@ Global
{A6B14415-D316-4955-BE5F-725BB2DEBEBE} = {28800357-C8CE-4CD0-A2AD-D4A910ABB496}
{E571E686-01A0-44D5-BFF5-B7678284258B} = {A6B14415-D316-4955-BE5F-725BB2DEBEBE}
{25C5C6B6-4A8A-46DD-88C1-EB247033FE58} = {E6026D6A-01C5-4582-B2C1-64751490DABE}
{859F76F4-93D8-4D60-BF9A-363E217FA247} = {E6026D6A-01C5-4582-B2C1-64751490DABE}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A0750637-2CCB-4139-B25E-F2CE740DCFAC}
Expand Down
25 changes: 16 additions & 9 deletions cs/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Introduction to FASTER C#
=========================

FASTER C# works in .NET Framework and .NET core, and can be used in both a single-threaded and concurrent setting. It has been tested to work on both Windows and Linux. It exposes an API that allows one to performs a mix of Reads, Blind Updates (Upserts), and Read-Modify-Write operations. It supports data larger than memory, and accepts an `IDevice` implementation for storing logs on storage. We have provided `IDevice` implementations for local file system, but one may create new devices, for example, to write to remote file systems. Alternatively, one may mount remote storage into the local file system. FASTER may be used as a high-performance replacement for traditional concurrent data structures such as the .NET ConcurrentDictionary, and additionally supports larger-than-memory data. It also supports checkpointing of the data structure - both incremental and non-incremental.
FASTER C# works in .NET Framework and .NET core, and can be used in both a single-threaded and concurrent setting. It has been tested to work on both Windows and Linux. It exposes an API that allows one to performs a mix of Reads, Blind Updates (Upserts), and Read-Modify-Write operations. It supports data larger than memory, and accepts an `IDevice` implementation for storing logs on storage. We have provided `IDevice` implementations for local file system and Azure Page Blobs, but one may create new devices as well. We also offer meta-devices that can group device instances into sharded and tiered configurations. FASTER may be used as a high-performance replacement for traditional concurrent data structures such as the .NET ConcurrentDictionary, and additionally supports larger-than-memory data. It also supports checkpointing of the data structure - both incremental and non-incremental. Operations on FASTER can be issued synchronously or asynchronously, i.e., using the C# `async` interface.

Table of Contents
-----------
Expand All @@ -14,7 +14,7 @@ Table of Contents
## Getting FASTER

### Building From Sources
Clone the Git repo, open cs/FASTER.sln in VS 2017, and build.
Clone the Git repo, open cs/FASTER.sln in VS 2019, and build.

### NuGet
You can install FASTER binaries using Nuget, from Nuget.org. Right-click on your project, manage NuGet packages, browse for FASTER. Here is a [direct link](https://www.nuget.org/packages/FASTER).
Expand All @@ -30,7 +30,7 @@ FASTER supports three basic operations:

### Constructor

Before instantiating FASTER, you need to create storage devices that FASTER will use. If you are using blittable types, you only need the hybrid log device. If you are also using objects, you need to create a separate object log device.
Before instantiating FASTER, you need to create storage devices that FASTER will use. If you are using value (blittable) types, you only need one log device. If you are also using objects, you need to create a separate object log device.

```Csharp
IDevice log = Devices.CreateLogDevice("C:\\Temp\\hybridlog_native.log");
Expand Down Expand Up @@ -59,7 +59,7 @@ The user provides an instance of a type that implements `IFunctions<>`. This typ

1. SingleReader and ConcurrentReader: These are used to read from the store values and copy them to Output. Single reader can assume there are no concurrent operations.
2. SingleWriter and ConcurrentWriter: These are used to write values to the store, from a source value.
3. Completion callbacks: Called when various operations complete.
3. Completion callbacks: Called by FASTER when various operations complete.
4. RMW Updaters: There are three updaters that the user specifies, InitialUpdater, InPlaceUpdater, and CopyUpdater. Together, they are used to implement the RMW operation.

### Constructor Parameters
Expand All @@ -76,15 +76,22 @@ The total in-memory footprint of FASTER is controlled by the following parameter

### Sessions (Threads)

Once FASTER is instantiated, threads may use FASTER by registering themselves via the concept of a Session, using the call
Once FASTER is instantiated, one issues operations to FASTER by creating logical sessions. A session represents a sequence of operations issued to FASTER. There is no concurrency within a session, but different sessions may execute concurrently. Sessions do not need to be affinitized to threads, but if they are, FASTER can leverage the same (covered later). You create a session as follows:

```fht.StartSession();```
```var session = fht.NewSession();```

At the end, the thread calls:
You can then perform a sequence of read, upsert, and RMW operations on the session. FASTER supports sync and async versions of operations. Examples:

```fht.StopSession();```
```cs
var status = session.Read(ref key, ref input, ref output, ref context);
await session.ReadAsync(key, input);
```

At the end, the session is disposed:

```session.Dispose();```

When all threads are done operating on FASTER, you finally dispose the FASTER instance:
When all sessions are done operating on FASTER, you finally dispose the FASTER instance:

```fht.Dispose();```

Expand Down
3 changes: 1 addition & 2 deletions cs/benchmark/ConcurrentDictionaryBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,10 @@ public enum Op : ulong
Input[] input_;
Input* input_ptr;

ConcurrentDictionary<Key, Value> store;
readonly ConcurrentDictionary<Key, Value> store;

long total_ops_done = 0;

const string kKeyWorkload = "a";
readonly int threadCount;
readonly int numaStyle;
readonly string distribution;
Expand Down
52 changes: 28 additions & 24 deletions cs/benchmark/FasterYcsbBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ public enum Op : ulong
ReadModifyWrite = 2
}

const bool kUseSyntheticData = false;
#if DEBUG
const bool kUseSmallData = true;
const bool kUseSyntheticData = true;
#else
const bool kUseSmallData = false;
const bool kUseSyntheticData = false;
#endif
const long kInitCount = kUseSmallData ? 2500480 : 250000000;
const long kTxnCount = kUseSmallData ? 10000000 : 1000000000;
const int kMaxKey = kUseSmallData ? 1 << 22 : 1 << 28;
Expand All @@ -42,11 +47,10 @@ public enum Op : ulong
Input[] input_;
readonly IDevice device;

FasterKV<Key, Value, Input, Output, Empty, Functions> store;
readonly FasterKV<Key, Value, Input, Output, Empty, Functions> store;

long total_ops_done = 0;

const string kKeyWorkload = "a";
readonly int threadCount;
readonly int numaStyle;
readonly string distribution;
Expand Down Expand Up @@ -97,9 +101,9 @@ private void RunYcsb(int thread_idx)
sw.Start();


Value value = default(Value);
Input input = default(Input);
Output output = default(Output);
Value value = default;
Input input = default;
Output output = default;

long reads_done = 0;
long writes_done = 0;
Expand All @@ -111,7 +115,7 @@ private void RunYcsb(int thread_idx)
int count = 0;
#endif

store.StartSession();
var session = store.NewSession(null, true);

while (!done)
{
Expand All @@ -136,25 +140,25 @@ private void RunYcsb(int thread_idx)

if (idx % 256 == 0)
{
store.Refresh();
session.Refresh();

if (idx % 65536 == 0)
{
store.CompletePending(false);
session.CompletePending(false);
}
}

switch (op)
{
case Op.Upsert:
{
store.Upsert(ref txn_keys_[idx], ref value, Empty.Default, 1);
session.Upsert(ref txn_keys_[idx], ref value, Empty.Default, 1);
++writes_done;
break;
}
case Op.Read:
{
Status result = store.Read(ref txn_keys_[idx], ref input, ref output, Empty.Default, 1);
Status result = session.Read(ref txn_keys_[idx], ref input, ref output, Empty.Default, 1);
if (result == Status.OK)
{
++reads_done;
Expand All @@ -163,7 +167,7 @@ private void RunYcsb(int thread_idx)
}
case Op.ReadModifyWrite:
{
Status result = store.RMW(ref txn_keys_[idx], ref input_[idx & 0x7], Empty.Default, 1);
Status result = session.RMW(ref txn_keys_[idx], ref input_[idx & 0x7], Empty.Default, 1);
if (result == Status.OK)
{
++writes_done;
Expand Down Expand Up @@ -192,8 +196,9 @@ private void RunYcsb(int thread_idx)
#endif
}

store.CompletePending(true);
store.StopSession();
session.CompletePending(true);
session.Dispose();

sw.Stop();

Console.WriteLine("Thread " + thread_idx + " done; " + reads_done + " reads, " +
Expand Down Expand Up @@ -312,7 +317,7 @@ private void SetupYcsb(int thread_idx)
else
Native32.AffinitizeThreadShardedNuma((uint)thread_idx, 2); // assuming two NUMA sockets

store.StartSession();
var session = store.NewSession(null, true);

#if DASHBOARD
var tstart = Stopwatch.GetTimestamp();
Expand All @@ -321,7 +326,7 @@ private void SetupYcsb(int thread_idx)
int count = 0;
#endif

Value value = default(Value);
Value value = default;

for (long chunk_idx = Interlocked.Add(ref idx_, kChunkSize) - kChunkSize;
chunk_idx < kInitCount;
Expand All @@ -331,15 +336,15 @@ private void SetupYcsb(int thread_idx)
{
if (idx % 256 == 0)
{
store.Refresh();
session.Refresh();

if (idx % 65536 == 0)
{
store.CompletePending(false);
session.CompletePending(false);
}
}

store.Upsert(ref init_keys_[idx], ref value, Empty.Default, 1);
session.Upsert(ref init_keys_[idx], ref value, Empty.Default, 1);
}
#if DASHBOARD
count += (int)kChunkSize;
Expand All @@ -357,9 +362,8 @@ private void SetupYcsb(int thread_idx)
#endif
}


store.CompletePending(true);
store.StopSession();
session.CompletePending(true);
session.Dispose();
}

#if DASHBOARD
Expand Down Expand Up @@ -433,7 +437,7 @@ void DoContinuousMeasurements()
}
#endif

#region Load Data
#region Load Data

private unsafe void LoadDataFromFile(string filePath)
{
Expand Down Expand Up @@ -575,7 +579,7 @@ private void LoadSyntheticData()
Console.WriteLine("loaded " + kTxnCount + " txns.");

}
#endregion
#endregion


}
Expand Down
5 changes: 3 additions & 2 deletions cs/benchmark/Functions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Runtime.CompilerServices;
using System.Diagnostics;
using FASTER.core;
using System.Collections.Generic;

namespace FASTER.benchmark
{
Expand All @@ -28,9 +29,9 @@ public void DeleteCompletionCallback(ref Key key, Empty ctx)
{
}

public void CheckpointCompletionCallback(Guid sessionId, long serialNum)
public void CheckpointCompletionCallback(string sessionId, CommitPoint commitPoint)
{
Debug.WriteLine("Session {0} reports persistence until {1}", sessionId, serialNum);
Debug.WriteLine("Session {0} reports persistence until {1}", sessionId, commitPoint.UntilSerialNo);
}

// Read functions
Expand Down
Loading