Inter-process communication

G

Guest

Hi all,

I'm having a slight issue with the speed of my inter-process communication
at the moment, and was wondering if anyone could either tell me either that I
won't get any more speed out of my current approach or how I can improve the
performance.

At it's simplest, the architecture of the application I'm writing will have
one "Message Handler" component and multiple other processes that will send
messages to it - it's important to note that all the other processes are
required to talk to the same message handler.

In its current incarnation the message handler is a remotable object
configured as a singleton, hosted in a windows service. When a client starts
up, it creates the message handler using Activator.GetObject across a TCP
channel to the local machine. (Is this required? Is there a better
"channel" type to use? It really seems overkill for what I need...)

The client then simply calls a method on the message handler, for arguments
sake SendMessage(int, int, string) - n.b. no complex arguments.

I'm seeing a latency of about 0.0008 seconds between message calls, which
seems like an awfully long time to effectively just call a method.

Any pointers/suggestions will be gratefully received!
Many thanks,
Mike
 
S

Steven Cheng[MSFT]

Hi Mike,

Thanks for your posting. From your description, you've a service process
which expose a remote object as a MessageHandler. Other process (appdomain)
can get that remote object via remoting activation and call the method on
it to send message in the service process. But currrently you're concerning
about the speed the of the method call , yes?

Based on my experience, such cross-boundary calls( cross-appdomain,
cross-process ...) does need some additional time than a normal method
call. In fact, when we invoke a method on a remote object, the first step
occurs on the remote object's client side proxy in the client appdomain,
the proxy generate a Message object represent the method call then the
message go through several sinks and channels , and at the server
process(appdomain) the message is regenerated into stack based method call
on the actual object. So that'll take more time than a normal pure stack
based method call.

In addition, I notice that you're using the sendmessage in your service
process. Since the SendMessage method will block the method call until the
the message's target window finish processing the message, I suggest you
can try use PostMessage or other async means instead which won't block the
method call. Also, you can also try remotely call a very simple method
(without send message) to see how long it will take and compare with the
method which send messages. That can also help to verify whether it's the
remote message exchange that eat the most times in a complete remote method
call.

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top