Reposted from
https://github.com/rabbitmq/rabbitmq-dotnet-client/issues/97 as deemed to be not an "Issue", grateful for any comments or help :-) :
----------------------------------------------
Hi,
I've been working on an application that handles a LOT of messages and after optimising my code to every bit of its life believe I have found a performance issue in rabbitmq-dotnet-client v3.5.3.
Visual Studio 2013 performance analysis points out that the majority of the program now spends its time executing this:
```c#
while (m_running)
{
```
projects\client\RabbitMQ.Client\src\client\impl\Connection.cs
I've noticed that if I have 1 channel open, then I am unable to keep up with the volume of messages, however if I open another channel (presumably MainLoopIteration then runs for longer and has more things to do) say about 3, then the application performs perfectly and spends more time reading messages.
The ironic thing is just running 3 instances of exactly the same channel code against the same connection is enough to improve the performance enough to keep up in real time.
For my consumers I use ManualResetEvent and AutoResetEvent as that is generally now preferable in threads than using very tight while loops like while (true) or while (m_running) and I wondered if the RabbitMQ client needed the same?
I'm new to the RabbitMQ .NET Client source, does someone more familiar with the code base know if the while loop can be replaced with a semaphore like that used by ManualResetEvent to further improve its performance? Presumably the frame would be written to a BlockingCollection and then the loop would wait for the signal?
See :
http://stackoverflow.com/questions/8881396/cpu-usage-increasing-up-to-100-in-infinite-loop-in-thread and
http://stackoverflow.com/questions/7402146/cpu-friendly-infinite-loopThank you for your time,
Matthew
----------------------------------------------