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

[C#] Support IOCP-based operations in LocalStorageDevice #402

Merged
merged 7 commits into from
Feb 20, 2021
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Updated throttle limit to apply per device instance
badrishc committed Feb 18, 2021
commit 35760031a0d88b856ee6b7c9a8da60c1602137cc
6 changes: 3 additions & 3 deletions cs/benchmark/FasterYcsbBenchmark.cs
Original file line number Diff line number Diff line change
@@ -108,12 +108,12 @@ public FASTER_YcsbBenchmark(int threadCount_, int numaStyle_, string distributio
freq = Stopwatch.Frequency;
#endif

// Increase throttle limit for higher concurrency runs
if (threadCount > 8) LocalStorageDevice.ThrottleLimit *= 2;

var path = "D:\\data\\FasterYcsbBenchmark\\";
device = Devices.CreateLogDevice(path + "hlog", preallocateFile: true, useIoCompletionPort: false);

// Increase throttle limit for higher concurrency runs
if (threadCount > 8) device.ThrottleLimit *= 2;

if (kSmallMemoryLog)
store = new FasterKV<Key, Value>
(kMaxKey / 2, new LogSettings { LogDevice = device, PreallocateLog = true, PageSizeBits = 22, SegmentSizeBits = 26, MemorySizeBits = 26 }, new CheckpointSettings { CheckPointType = CheckpointType.FoldOver, CheckpointDir = path });
8 changes: 7 additions & 1 deletion cs/src/core/Device/IDevice.cs
Original file line number Diff line number Diff line change
@@ -52,6 +52,12 @@ public interface IDevice : IDisposable
/// </summary>
int EndSegment { get; }

/// <summary>
/// Throttle limit (max number of pending I/Os) for this device instance. Device needs
/// to implement Throttle() in order to use this limit.
/// </summary>
int ThrottleLimit { get; set; }

/// <summary>
/// Initialize device. This function is used to pass optional information that may only be known after
/// FASTER initialization (whose constructor takes in IDevice upfront). Implementation are free to ignore
@@ -72,7 +78,7 @@ public interface IDevice : IDisposable
bool TryComplete();

/// <summary>
/// Whether device should be throttled
/// Whether device should be throttled at this instant (i.e., caller should stop issuing new I/Os)
/// </summary>
/// <returns></returns>
bool Throttle();
9 changes: 2 additions & 7 deletions cs/src/core/Device/LocalStorageDevice.cs
Original file line number Diff line number Diff line change
@@ -23,18 +23,13 @@ public unsafe class LocalStorageDevice : StorageDeviceBase
/// are concurrently created.
/// </summary>
public static bool UsePrivileges = true;

/// <summary>
/// Number of IO completion threads dedicated to this instance. Used only
/// if useIoCompletionPort is set to true.
/// </summary>
public static int NumCompletionThreads = 1;

/// <summary>
/// Throttle I/O when this limit is reached
/// </summary>
public static int ThrottleLimit = 120;

private readonly bool preallocateFile;
private readonly bool deleteOnClose;
private readonly bool disableFileBuffering;
@@ -108,7 +103,7 @@ protected internal LocalStorageDevice(string filename,
throw new FasterException("Cannot use LocalStorageDevice from non-Windows OS platform, use ManagedLocalStorageDevice instead.");
}
#endif

ThrottleLimit = 120;
this.useIoCompletionPort = useIoCompletionPort;
if (useIoCompletionPort)
{
3 changes: 2 additions & 1 deletion cs/src/core/Device/ManagedLocalStorageDevice.cs
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@ public ManagedLocalStorageDevice(string filename, bool preallocateFile = false,
: base(filename, GetSectorSize(filename), capacity)
{
pool = new SectorAlignedBufferPool(1, 1);
ThrottleLimit = 120;

string path = new FileInfo(filename).Directory.FullName;
if (!Directory.Exists(path))
@@ -51,7 +52,7 @@ public ManagedLocalStorageDevice(string filename, bool preallocateFile = false,
}

/// <inheritdoc />
public override bool Throttle() => numPending > 120;
public override bool Throttle() => numPending > ThrottleLimit;

private void RecoverFiles()
{
5 changes: 5 additions & 0 deletions cs/src/core/Device/StorageDeviceBase.cs
Original file line number Diff line number Diff line change
@@ -51,6 +51,11 @@ public abstract class StorageDeviceBase : IDevice
private int segmentSizeBits;
private ulong segmentSizeMask;

/// <summary>
/// Throttle limit (max number of pending I/Os) for this device instance
/// </summary>
public int ThrottleLimit { get; set; } = int.MaxValue;

/// <summary>
/// Instance of the epoch protection framework in the current system.
/// A device may have internal in-memory data structure that requires epoch protection under concurrent access.