Using managed memory to call a RIOSend function with registered I / O

I am working on a system that requires high speed, low latency / jitter communications and is written in C #. We saw that there is a new mechanism for improving performance using sockets called Windows Registered IO http://www.serverframework.com/asynchronousevents/2011/10/windows-8-registered-io-networking-extensions.html

... But at the moment it is not available for C # ... and this, of course, shows the best performance based on testing in C ++.

In any case, I already wrote the Managed C ++ / CLI part for creating the DLL, and it seems to work fine with C # and significantly improved numbers.

But I am wondering if I can save a copy of the send buffer ...

Currently, the C ++ shell looks like this:

bool ManagedSendData( array<byte> ^ buf, ULONG bufLen )
{
// must pin array memory until we're done with sending it, 
// at which point it'll be copied into the unmanaged memory

   pin_ptr<Byte> p = &buf[0];   // pinning one element of an array pins the whole array
   unsigned char * cp = p;

   return _RIObs->SendData( cp, bufLen );
}

Where _RIObsis an unmanaged C ++ object that implements the functionality of registered I / O. In this function, it copies the data to the buffer that was registered at startup with RIORegisterBuffer(), and then calls RIOSend()to notify the OS of the availability of data to send.

, : Managed ++ GCHandle::Alloc() , , RIORegisterBuffer() , , ++ ? , , , , , . , , .

, , , , .

+5
2

RIO #, ++/CLI; p > 85k, LoH, GC, , :

_underlyingBuffer = new byte[BufferLength];
var pinnedBuffer = GCHandle.Alloc(_underlyingBuffer, GCHandleType.Pinned);
var address = Marshal.UnsafeAddrOfPinnedArrayElement(_underlyingBuffer, 0);
var bufferId = _rio.RegisterBuffer(address, BufferLength);

http--, IO , ( ).

+2

. , GCHandle:: Pinned, GCHandle, , .

+1

All Articles