Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
177 commits
Select commit Hold shift + click to select a range
b4e4803
Fix epoch refresh of uncommitted safe tail
tli2 Sep 12, 2022
b414a5b
Add refactored libDPR
tli2 Oct 27, 2022
044a1db
Refactor and add libDPR counter server example
tli2 Oct 27, 2022
ed72041
libDPR tests and tweaks
tli2 Oct 31, 2022
b13f000
Add DARQ data structure
tli2 Nov 1, 2022
9734e13
Add some server code
tli2 Nov 2, 2022
b058652
Checkpoint changes
tli2 Nov 9, 2022
e3fbd4d
Add refactored stream example; implement checkpointing in DARQ
tli2 Nov 16, 2022
fa118d9
Finish Stream examples
tli2 Nov 17, 2022
7e0c180
Merge branch 'main' of https://github.com/microsoft/FASTER into research
tli2 Mar 8, 2023
d442f1c
update git ignore
tli2 Mar 16, 2023
da856af
Merge branch 'main' into research
tli2 Mar 16, 2023
4ee1a56
Merge branch 'research' of https://github.com/tli2/FASTER into research
tli2 Mar 22, 2023
4ac8e53
Documentation pass
tli2 Mar 23, 2023
d5f020e
Merge branch 'main' into research
tli2 Apr 17, 2023
b40711e
Merge branch 'research' of https://github.com/tli2/FASTER into research
tli2 Apr 17, 2023
2acf7a1
Fix some libDPR issues
tli2 Apr 18, 2023
9f510dd
Bug fixes
tli2 Apr 20, 2023
71b2db9
More bug fixes
tli2 Apr 24, 2023
6ed5211
Merge branch 'main' of https://github.com/tli2/FASTER into research
tli2 May 1, 2023
af87ac5
Merge branch 'main' into research
badrishc May 3, 2023
5eed632
Checkpoint code
tli2 May 3, 2023
14f9a27
Merge branch 'research' of https://github.com/tli2/FASTER into research
tli2 May 3, 2023
804d5dc
Update example code
tli2 May 4, 2023
d43fb18
More documentation
tli2 May 5, 2023
8c3f1a1
A bit more documentation
tli2 May 5, 2023
65a2403
Merge branch 'main' of https://github.com/microsoft/FASTER into research
tli2 Jun 2, 2023
4702064
Finish tweaking the examples
tli2 Jun 13, 2023
566b59a
Merge branch 'main' into research
tli2 Jun 13, 2023
fd169a4
Merge branch 'research' of https://github.com/tli2/FASTER into research
tli2 Jun 14, 2023
1aab6bc
untrack ignored files
tli2 Jun 14, 2023
aba8b3a
downgrade unit test target framework for build compatibility
tli2 Jun 14, 2023
ccb1e8b
Code review comments
tli2 Jun 19, 2023
bff64bf
Merge branch 'main' into research
tli2 Jun 19, 2023
37f236f
Remove DARQ code from MessageType
tli2 Jun 29, 2023
b2edb69
Merge branch 'research' of https://github.com/tli2/FASTER into research
tli2 Jun 29, 2023
d8722aa
Remove DARQ wire formats from FASTER.common
tli2 Jul 3, 2023
c1b4d44
Merge branch 'main' into research
tli2 Jul 5, 2023
d3e8346
Merge branch 'main' into research
tli2 Jul 7, 2023
b9ae4b6
Merge branch 'main' into research
tli2 Jul 14, 2023
6cb1567
Merge branch 'main' into research
tli2 Jul 20, 2023
bccbf09
Merge branch 'research' of https://github.com/tli2/FASTER into research
tli2 Jul 20, 2023
e39cd26
fix enum assertions
tli2 Jul 22, 2023
fae5235
Merge branch 'main' into research
badrishc Aug 3, 2023
c67bc1f
Merge branch 'main' into research
tli2 Sep 6, 2023
03ee491
Merge branch 'main' into research
tli2 Sep 12, 2023
5905585
Merge branch 'main' into research
tli2 Oct 25, 2023
460914d
Disable debug assert around bump
tli2 Nov 2, 2023
d78f37a
checkpoint work
tli2 Nov 30, 2023
37ae042
checkpoint more work
tli2 Dec 1, 2023
fcab586
Fix bug with test case
tli2 Dec 11, 2023
5454f8e
Add test
tli2 Dec 13, 2023
bfa38da
save progress
tli2 Dec 27, 2023
a8ab866
Clean up DPR session logic and DARQ failure path
tli2 Jan 10, 2024
59d2084
Checkpoint for DPR refactor
tli2 Jan 24, 2024
a08b90f
Modify gRPC wrapper into using rwlatch-based version protection to su…
tli2 Jan 25, 2024
6b252f8
Get started on a toy workflow application. Add gRPC DARQ variant for …
tli2 Jan 30, 2024
38fd25f
Refactor DARQ message type logic
tli2 Feb 8, 2024
f99984a
Refactor and a bunch of other fixes to get gRPC example working
tli2 Feb 12, 2024
1f248f4
DARQ background work overhaul + detach/merge concept of dpr workers
tli2 Feb 14, 2024
2ceafbc
Fix DprSession passing logic
tli2 Feb 15, 2024
16266f9
DI shenanigans and clean shutdown fix
tli2 Feb 15, 2024
991f7dd
Speculation Barrier proof of concept
tli2 Feb 19, 2024
73df86b
Checkpoint changes
tli2 Feb 20, 2024
0e29f5a
Prototype of polymorphic DARQ background worker
tli2 Feb 20, 2024
ca0140e
Minor updates
tli2 Feb 27, 2024
3592ec7
Linux compatibility fix
tli2 Feb 27, 2024
39090c8
fix npe
tli2 Feb 27, 2024
274c35e
Fix speculation barrier code
tli2 Feb 27, 2024
c14a976
Checkpoint work
tli2 Mar 6, 2024
3d9bbee
Workflow system with speculation support
tli2 Mar 18, 2024
2c73ae4
Checkpoint benchmark implementation
tli2 Mar 24, 2024
6d07f5e
Updates to benchmarking scaffolding
tli2 Mar 25, 2024
0521dad
Dockerfile fix
tli2 Mar 25, 2024
db814fc
More work on kubernetes
tli2 Mar 25, 2024
a4ed085
Switch pubsub to be based on DARQs instead
tli2 Apr 2, 2024
a62b288
Add registration logic
tli2 Apr 2, 2024
18369bb
Checkpoint work
tli2 Apr 8, 2024
3c93ea3
Tweaking quotes and variable names
tli2 Apr 10, 2024
0eee1b3
Update dockerfile
tli2 Apr 10, 2024
e8369a5
helm syntax shenanigans
tli2 Apr 10, 2024
c1d342c
More kubernetes fuckery
tli2 Apr 10, 2024
42cb42a
I hate kubernetes
tli2 Apr 10, 2024
ba19ee3
I fucking hate Kubernetes
tli2 Apr 10, 2024
3128fea
Fix pingpong device start from scratch behavior
tli2 Apr 11, 2024
e312fe5
Allow epoch to now be able to handle arbitrary context and not just t…
tli2 Apr 11, 2024
abde94b
Add simplified workflow logic
tli2 Apr 11, 2024
7510476
Add tracing messages
tli2 Apr 11, 2024
b566721
Checkpoint Kube work
tli2 Apr 11, 2024
2c54b1f
Checkpoint work
tli2 Apr 16, 2024
1b559b8
Abstract benchmark constants into Environment class
tli2 Apr 17, 2024
ddca313
Switch to using pvcs for k8 experiments
tli2 Apr 17, 2024
4831e2d
kubernetes fuckery
tli2 Apr 17, 2024
56aaa55
Apoply kubernetes node selector
tli2 Apr 17, 2024
fcd3526
Use correct label name this time
tli2 Apr 17, 2024
36fa7b6
Reorganize helm to split storage and workloads so storage volumes can…
tli2 Apr 17, 2024
fcbfc7e
More logging + temporarily disable non-speculative mode
tli2 Apr 17, 2024
4cd50e4
Correctly cleanup leftover state
tli2 Apr 17, 2024
ab0fca5
Actually dispose of devices at the start of execution. Introduce some…
tli2 Apr 17, 2024
51dd378
More scripting shenanigans
tli2 Apr 17, 2024
544d267
More kubernetes fuckery
tli2 Apr 17, 2024
a69d369
The fun never stops
tli2 Apr 17, 2024
7990dc7
Convert to using helm for event processing benchmark as well
tli2 Apr 18, 2024
b1b231d
Add speculative flag back in
tli2 Apr 18, 2024
5ba497c
Remove large file for docker perf
tli2 Apr 18, 2024
25d439b
Fix deadlock from interplay of FASTER and EPVS
tli2 Apr 18, 2024
fec4544
reduce sleep time on start up
tli2 Apr 18, 2024
de2202b
Actually delete files for fuck sake
tli2 Apr 18, 2024
a192a44
Fix workflow generation
tli2 Apr 18, 2024
4b0c055
Add output labeling
tli2 Apr 18, 2024
c6592f7
Separate output name and workload name
tli2 Apr 18, 2024
5855300
Checkpoint before streaming refactor
tli2 Apr 19, 2024
2078f3e
Turns out rate limiting works?
tli2 Apr 19, 2024
5fefcfa
Use correct environment
tli2 Apr 19, 2024
bb801c2
Debug prints for reservation service checkpoint pass
tli2 Apr 19, 2024
a3c8365
Try to get debug working on kubernetes
tli2 Apr 20, 2024
3db3f02
Remove hard coded init files
tli2 Apr 20, 2024
b7899d8
Fix Faster checkpoint error?
tli2 Apr 20, 2024
3ce46e2
Include source file and build with debug symbols
tli2 Apr 20, 2024
aaaec12
fix file structure
tli2 Apr 20, 2024
6993150
more path problems
tli2 Apr 20, 2024
b5a6eab
Fix Linux bug
tli2 Apr 21, 2024
7bfe791
Remove resource limit on containers
tli2 Apr 21, 2024
823bdf7
Remove unnecessary awaits
tli2 Apr 21, 2024
252cdb7
Update experiment configs
tli2 Apr 21, 2024
cd5fb6f
Make issue window a command line arg
tli2 Apr 21, 2024
207a1aa
Update workload file paths
tli2 Apr 21, 2024
cbe22fa
file system shenanigans
tli2 Apr 21, 2024
6b2ad7b
Updates
tli2 Apr 21, 2024
6f655e4
More threads
tli2 Apr 21, 2024
0226e7f
Various Async fixes
tli2 Apr 21, 2024
8c0ef4f
Hack to avoid having ManagedLocalStorageDevice Task starve
tli2 Apr 21, 2024
f6467c0
Disable checkpoint metadata write in critical section to avoid blocking
tli2 Apr 21, 2024
0f26073
Checkpoint work for event processing
tli2 Apr 22, 2024
3179551
More set up for Kubernetes workload
tli2 Apr 22, 2024
1fffb56
Slight optimization around data loading logic
tli2 Apr 23, 2024
d113e06
Update paths
tli2 Apr 23, 2024
3790d09
Update docker file
tli2 Apr 23, 2024
64bad34
remove selector from jobs
tli2 Apr 23, 2024
0a88d2f
Fix typo
tli2 Apr 23, 2024
203641c
Fix typos and add sleep to make sure client launches after processors
tli2 Apr 23, 2024
3312e3b
correct init container
tli2 Apr 23, 2024
e1642ff
Kubernetes fuckery
tli2 Apr 23, 2024
8902e9c
Optimizations
tli2 Apr 23, 2024
a01f973
Fix messages that are too large
tli2 Apr 23, 2024
73102c2
Add missing await
tli2 Apr 23, 2024
e215e14
Optimization?
tli2 Apr 23, 2024
5a05f3d
Temporarily disable user side rate limit
tli2 Apr 23, 2024
9121f07
Re-enable
tli2 Apr 23, 2024
1ad7305
Make stepping speculative for speed
tli2 Apr 23, 2024
da7b7b6
Update docker file
tli2 Apr 24, 2024
b282340
Rollback probelmatic reuse
tli2 Apr 24, 2024
aa9c71f
Disable gRPC auto close connection and tweak Linux thread pool
tli2 Apr 24, 2024
3f50710
Rewrite checkpoint manager to use synchronous file operations
tli2 Apr 24, 2024
0f98626
Add rate limiting for state object related awaits
tli2 Apr 24, 2024
11b2d77
Switch to Thread.Yield() for StateObject busy wait under access control
tli2 Apr 24, 2024
a4104ba
Task behavior optimizations
tli2 Apr 25, 2024
a71cd01
Use thread-based background tasks
tli2 Apr 25, 2024
d9d1ecb
Add more data to collect on stream processing
tli2 Apr 25, 2024
72b420f
Add microbench
tli2 Apr 26, 2024
2691d64
Fix bytes flushed logic
tli2 Apr 26, 2024
89543d5
Checkpoint work
tli2 Apr 28, 2024
669ae9e
Add coordinator microbenchmark
tli2 Apr 28, 2024
b18d9be
update docker file
tli2 Apr 28, 2024
f539d95
Add missing account
tli2 Apr 29, 2024
89e9c0e
Fix iteration logic
tli2 Apr 29, 2024
60984a4
Use ms instead of ticks
tli2 Apr 29, 2024
2857967
Add synchronization to ensure simulated workers start at the same time
tli2 Apr 29, 2024
d875f81
Actually synchronize
tli2 Apr 29, 2024
395457f
Try sharing stopwatch across threads
tli2 Apr 29, 2024
74eedb5
Don't use multiple threads
tli2 Apr 29, 2024
5cdd8d7
initialize
tli2 Apr 29, 2024
4339693
Initialize
tli2 Apr 29, 2024
1025696
Fix reuse bugs
tli2 Apr 29, 2024
a68965a
Change environment
tli2 Apr 29, 2024
9722d85
initial dump
opheez Apr 30, 2024
ecabef6
Update src to 2pc
opheez May 5, 2024
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
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ nativebin/

# JetBrains
cs/.idea/
cs/remote/.idea
cs/libdpr/.idea
cs/remote/.idea/
cs/research/libdpr/.idea/
cs/libdpr/.idea/
cs/research/darq/.idea/

cs/**/BenchmarkDotNet.Artifacts/
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env
WORKDIR /app

# Build Travel Reservation
COPY ./cs .
WORKDIR /app/research/darq/TravelReservation
RUN dotnet restore
RUN dotnet build -c Release -o out

# Build EventProcessing
WORKDIR /app/research/darq/EventProcessing
RUN dotnet restore
RUN dotnet publish -c Release -o out

# Build CoordinatorMicrobench
WORKDIR /app/research/darq/CoordinatorMicrobench
RUN dotnet restore
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/aspnet:7.0
WORKDIR /app
COPY --from=build-env /app/TravelReservation-latency ./TravelReservation-latency
COPY --from=build-env /app/TravelReservation-thr ./TravelReservation-thr
COPY --from=build-env /app/EventProcessing ./EventProcessing-latency
COPY --from=build-env /app/research/darq/TravelReservation/out ./TravelReservation
COPY --from=build-env /app/research/darq/EventProcessing/out ./EventProcessing
COPY --from=build-env /app/research/darq/CoordinatorMicrobench/out ./CoordinatorMicrobench
EXPOSE 4022
60 changes: 45 additions & 15 deletions cs/playground/FasterLogMLSDTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using FASTER.core;

namespace FasterLogStress
Expand All @@ -16,27 +18,55 @@ public class Program
static readonly byte[] entry = new byte[100];
private static string commitPath;

public static void Main()
private static byte[] buffer;

public static async Task Main()
{
commitPath = "FasterLogStress/";
using var settings = new FasterLogSettings("./Test", deleteDirOnDispose: true)
{
AutoRefreshSafeTailAddress = true
};
log = new FasterLog(settings);

// Clean up log files from previous test runs in case they weren't cleaned up
// We loop to ensure clean-up as deleteOnClose does not always work for MLSD
while (Directory.Exists(commitPath))
Directory.Delete(commitPath, true);
buffer = new byte[2048];
Random.Shared.NextBytes(buffer);

// Create devices \ log for test
device = new ManagedLocalStorageDevice(commitPath + "ManagedLocalStore.log", deleteOnClose: true);
log = new FasterLog(new FasterLogSettings { LogDevice = device, PageSizeBits = 12, MemorySizeBits = 14 });
await Task.WhenAll(EnqueueThread(), ScanThread());
log.Dispose();
}

static async Task EnqueueThread()
{
for (int count = 0; count < 5; ++count)
{
await log.EnqueueAsync(buffer);
await Task.Delay(1000);
}

ManagedLocalStoreBasicTest();
log.CompleteLog();
Console.WriteLine("Enqueue complete");
}

log.Dispose();
device.Dispose();
static async Task ScanThread()
{
using var iterator = log.Scan(log.BeginAddress, long.MaxValue, scanUncommitted: true);
while (true)
{
byte[] result;
while (!iterator.GetNext(out result, out _, out _))
{
if (iterator.Ended)
{
Console.WriteLine("Scan complete");
return;
}

// Clean up log files
if (Directory.Exists(commitPath))
Directory.Delete(commitPath, true);
await iterator.WaitAsync();
}

Console.WriteLine("Received buffer");
Debug.Assert(result.SequenceEqual(buffer));
}
}


Expand Down
10 changes: 9 additions & 1 deletion cs/remote/src/FASTER.common/ElasticCircularBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Threading;

namespace FASTER.common
{
Expand Down Expand Up @@ -92,7 +93,8 @@ public sealed class ElasticCircularBuffer<T> : IEnumerable<T>
private readonly LinkedList<CircularBuffer<T>> buffers;
private LinkedListNode<CircularBuffer<T>> head;
private LinkedListNode<CircularBuffer<T>> tail;

private int count;

/// <summary>
/// Constructor
/// </summary>
Expand All @@ -103,6 +105,9 @@ public ElasticCircularBuffer()
buffers.AddFirst(node);
tail = head = node;
}

public int ApproxCount => count;


/// <summary>
/// Enqueue
Expand All @@ -111,6 +116,8 @@ public ElasticCircularBuffer()
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Enqueue(ref T value)
{
Interlocked.Increment(ref count);

if (tail.Value.IsFull())
{
tail.Value.Sealed = true;
Expand Down Expand Up @@ -158,6 +165,7 @@ public T Dequeue()
if (head == null) head = buffers.First;
temp.Value.Sealed = false;
}
Interlocked.Decrement(ref count);
return head.Value.Dequeue();
}

Expand Down
17 changes: 16 additions & 1 deletion cs/remote/src/FASTER.common/HeaderReaderWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,22 @@ public unsafe int ReadPendingSeqNo(ref byte* dst)
public unsafe bool Write(MessageType s, ref byte* dst, int length)
{
if (length < 1) return false;
*dst++ = (byte)s;
*dst++ = (byte) s;
return true;
}

/// <summary>
/// Write message type to memory
/// </summary>
/// <param name="s">Message type</param>
/// <param name="dst">Destination memory</param>
/// <param name="length">Length of destination</param>
/// <returns>Whether write succeeded</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe bool Write(byte s, ref byte* dst, int length)
{
if (length < 1) return false;
*dst++ = s;
return true;
}

Expand Down
7 changes: 1 addition & 6 deletions cs/remote/src/FASTER.common/INetworkSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@ public interface INetworkSender : IDisposable
/// <summary>
/// Send response (caller owns buffer space)
/// </summary>
void SendResponse(byte[] buffer, int offset, int count, object context);

/// <summary>
/// Send response (caller owns buffer space)
/// </summary>
void SendCallback(object context);
void SendResponse(byte[] buffer, int offset, int count, Action sendCallback);

/// <summary>
/// Dispose, optionally waiting for ongoing outgoing calls to complete
Expand Down
8 changes: 5 additions & 3 deletions cs/remote/src/FASTER.common/NetworkSenderBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace FASTER.common
using System;

namespace FASTER.common
{
/// <summary>
/// NetworkSenderBase class
Expand Down Expand Up @@ -57,12 +59,12 @@ public NetworkSenderBase(int serverBufferSize)

/// <inheritdoc />
public abstract bool SendResponse(int offset, int size);

/// <inheritdoc />
public abstract void SendResponse(byte[] buffer, int offset, int count, object context);

/// <inheritdoc />
public abstract void SendCallback(object context);
public abstract void SendResponse(byte[] buffer, int offset, int count, Action sendCallback);

/// <inheritdoc />
public abstract void Dispose();
Expand Down
22 changes: 15 additions & 7 deletions cs/remote/src/FASTER.common/SimpleObjectPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT license.

using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading;

Expand All @@ -12,20 +11,29 @@ namespace FASTER.common
/// Object pool
/// </summary>
/// <typeparam name="T"></typeparam>
public class SimpleObjectPool<T> : IDisposable where T : class, IDisposable
public class SimpleObjectPool<T> : IDisposable where T : class
{
private readonly Func<T> factory;
private readonly Action<T> destructor;
private readonly LightConcurrentStack<T> stack;
private int allocatedObjects;

/// <summary>
/// Constructor
/// </summary>
/// <param name="factory"></param>
/// <param name="maxObjects"></param>
public SimpleObjectPool(Func<T> factory, int maxObjects = 128)
/// <param name="factory"> method used to create new objects of type T </param>
/// <param name="maxObjects">
/// Max number of objects that will be retained and recycled in this object pool.
/// Objects exceeding this count are created and destroyed on demand
/// </param>
/// <param name="destructor"> method used to dispose retained objects when they go out of scope.
/// WARNING: NOT invoked on retained objects before reuse
/// </param>

public SimpleObjectPool(Func<T> factory, int maxObjects = 128, Action<T> destructor = null)
{
this.factory = factory;
this.destructor = destructor;
stack = new LightConcurrentStack<T>(maxObjects);
allocatedObjects = 0;
}
Expand All @@ -39,7 +47,7 @@ public void Dispose()
{
while (stack.TryPop(out var elem))
{
elem.Dispose();
destructor?.Invoke(elem);
Interlocked.Decrement(ref allocatedObjects);
}
Thread.Yield();
Expand Down Expand Up @@ -69,7 +77,7 @@ public void Return(T obj)
{
if (!stack.TryPush(obj))
{
obj.Dispose();
destructor?.Invoke(obj);
Interlocked.Decrement(ref allocatedObjects);
}
}
Expand Down
35 changes: 29 additions & 6 deletions cs/remote/src/FASTER.common/TcpNetworkSender.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using System;
using System.Net;
using System.Net.Sockets;
using System.Runtime.CompilerServices;
Expand All @@ -22,6 +23,9 @@ public class TcpNetworkSender : NetworkSenderBase
/// Response object
/// </summary>
protected SeaaBuffer responseObject;

// For use when user invokes send variant with user-owned buffers
private SimpleObjectPool<SocketAsyncEventArgs> saeaPool = new(() => new SocketAsyncEventArgs());

/// <summary>
/// Reusable SeaaBuffer
Expand Down Expand Up @@ -58,7 +62,8 @@ public TcpNetworkSender(
: base(maxSizeSettings)
{
this.socket = socket;
this.reusableSeaaBuffer = new SimpleObjectPool<SeaaBuffer>(() => new SeaaBuffer(SeaaBuffer_Completed, this.serverBufferSize));
this.reusableSeaaBuffer = new SimpleObjectPool<SeaaBuffer>(() => new SeaaBuffer(SeaaBuffer_Completed,
this.serverBufferSize), 128, s => s.Dispose());
this.responseObject = null;
this.ThrottleMax = throttleMax;

Expand All @@ -82,7 +87,8 @@ public TcpNetworkSender(
: base(serverBufferSize)
{
this.socket = socket;
this.reusableSeaaBuffer = new SimpleObjectPool<SeaaBuffer>(() => new SeaaBuffer(SeaaBuffer_Completed, this.serverBufferSize));
this.reusableSeaaBuffer = new SimpleObjectPool<SeaaBuffer>(() => new SeaaBuffer(SeaaBuffer_Completed,
this.serverBufferSize), 128, s => s.Dispose());
this.responseObject = null;
this.ThrottleMax = throttleMax;

Expand Down Expand Up @@ -154,15 +160,32 @@ public override bool SendResponse(int offset, int size)
}

/// <inheritdoc />
public override void SendResponse(byte[] buffer, int offset, int count, object context)
public override void SendResponse(byte[] buffer, int offset, int count, Action sendCallback)
{
throw new System.NotImplementedException();
var saea = saeaPool.Checkout();
saea.SetBuffer(buffer, offset, count);
saea.UserToken = sendCallback;
saea.Completed += SaeaBuffer_Completed;

if (Interlocked.Increment(ref throttleCount) > ThrottleMax)
throttle.Wait();
if (!socket.SendAsync(saea))
SaeaBuffer_Completed(null, saea);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void SaeaBuffer_Completed(object sender, SocketAsyncEventArgs e)
{
((Action)e.UserToken)();
saeaPool.Return(e);
if (Interlocked.Decrement(ref throttleCount) >= ThrottleMax)
throttle.Release();
}

/// <inheritdoc />
public override void SendCallback(object context)
public override void SendResponse(byte[] buffer, int offset, int count, object context)
{
throw new System.NotImplementedException();
throw new NotImplementedException();
}

/// <inheritdoc />
Expand Down
Loading