cbaxter / InfinityMQ

A .NET Message Transport on Steroids
GNU Lesser General Public License v3.0
5 stars 1 forks source link

Consider custom implementation of FrameWriter for sockets. #12

Closed cbaxter closed 12 years ago

cbaxter commented 12 years ago

Sockets implement custom send that accepts collection of buffers; thus would no longer require Buffer.BlockCopy to build up single message buffer. Determine impact on performance and act accordingly.

cbaxter commented 12 years ago

1,000,000 messages of 4,096 bytes each achieves the following metrics:

PUB/SUB Channel

REQ/REP Channel

Not sure if there will be a huge gain from creating custom implementations given the Buffer.BlockCopy is adding negligible overhead according to ANTS Performance Profiler. Thoughts?

cbaxter commented 12 years ago

Spiked out custom SocketBlockingFrameWriter implementation against REQ/REP channel. Throughput actually dropped by ~2,000 msg/sec. Buffer.BlockCopy is already optimized to move around buffers very efficiently (basically doing an unsafe copy). Looked in to Socket.Send implementation and is pinning each individual buffer prior to calling:

UnsafeNclNativeMethods.OSSOCK.WSASend_Blocking(this.m_Handle.DangerousGetHandle(), buffersArray, count, out num2, socketFlags, IntPtr.Zero, IntPtr.Zero);

Not worth the added code or complexity required for implementation.

NOTE: GitHub not allowing selection of 'Rejected' tag.