Top Performance for Cross AppDomain Signaling

My performance-sensitive application uses MemoryMappedFiles to transfer massive data between many AppDomains. I need the fastest mechanism to signal to the receiving AD that there is new data to read.

The design is as follows:

AD 1: Writer for MMF, when data is written, it should notify AD readers

AD 2,3, N ..: Read MMF

Readers do not need to know how much data is written, because each written message will start with a non-zero int, and it will read to zero, do not worry about partially written messages.

(I think). Traditionally, during one AD, Monitor.Wait / Pulse can be used for this, I do not think that it works through AppDomains.

You can also use the MarshalByRefObject remote access method or event, but I would like something faster. (I estimate 1,000,000 MarshalByRefObject calls / sec on my machine, not bad, but I want more)

A named EventWaitHandle is about twice as fast as the initial dimensions.

Is there anything faster?

Note. Receiving ADs do not need to receive each signal until the last signal is deleted.

+7
source share
2 answers

A named EventWaitHandle is the path for a one-way signal (for minimal delay). Of my measurements, it's 2 times faster than calling the cross-appdomain method. The performance of a method call is very impressive in recent versions of the CLR today (4) and should make the most sense for the vast majority of cases, since you can transfer some information to the method call (in my case, how much data to read)

If it is normal to continuously record the stream on the receiving side, and performance is critical, then a tough loop can be faster.

I hope that Microsoft will continue to improve cross-application functionality as it can really help with application reliability and plugins.

0
source

A thread context switch costs 2,000 to 10,000 cycles on Windows. If you want more than a million per second, you have to solve the problem of the Big Silicone Bottleneck. You are already at the very bottom of the service data.

Focus on switching less frequently and collecting data in one hit. Nothing should switch to a microsecond.

+2
source

All Articles