Why is IPC communication so slow?

T

tony

I use Ipcserverchannel class and Ipcclientchannel to do IPC. I try to
read a file to memory using process A and then use IPC to transport it
to process B. However, IPC use nearly as much time as from a from
disk, which is very surprising ( I expect it to be much much faster).
What could possibly be the problem?

Part of my code:

Server:
IpcServerChannel serverChannel = new
IpcServerChannel("remote");
ChannelServices.RegisterChannel(serverChannel);

// Expose an object

RemotingConfiguration.RegisterWellKnownServiceType(typeof(SharedCache),
"myObj", WellKnownObjectMode.Singleton);

Client:
clientChannel = new IpcClientChannel();
ChannelServices.RegisterChannel(clientChannel);

RemotingConfiguration.RegisterWellKnownClientType(typeof(SharedObj),
"ipc://remote/myObj");

ShareObj is the shared remoting object which can reading the file from
the disk and transport the file to the client process.
 
N

Nicholas Paldino [.NET/C# MVP]

Does the SharedCache type derive from MarshalByRefObject? If so, every
call you make will be marshaled back across the app domain boundary, and
this could definitely add some overhead.

Also, how are you transporting the file?
 
T

tony

Yes..It is derived from MarshalByRefObject ( I just followed the
example in MSDN)
It is like following:

public class SharedObj : MarshalByRefObject
{
public void LoadFileToMemory(string filename)
{
}

public void GetFileFromMemory(string filename, ref MemoryStream
ms)
{
}
}

Client A calls LoadFileToMemory, and Client B calls GetFileFromMemory,
so the content of file (store in a MemoryStream) is passed from
Process Client A to Process Client B.

I test the time to read the file from the disk and the time to pass
the memorystream from A to B, it is roughly the same speed.. How can
IO compete CPU in speed?


Does the SharedCache type derive from MarshalByRefObject? If so, every
call you make will be marshaled back across the app domain boundary, and
this could definitely add some overhead.

Also, how are you transporting the file?

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




I use Ipcserverchannel class and Ipcclientchannel to do IPC. I try to
read a file to memory using process A and then use IPC to transport it
to process B. However, IPC use nearly as much time as from a from
disk, which is very surprising ( I expect it to be much much faster).
What could possibly be the problem?
Part of my code:
Server:
IpcServerChannel serverChannel = new
IpcServerChannel("remote");
ChannelServices.RegisterChannel(serverChannel);
// Expose an object
RemotingConfiguration.RegisterWellKnownServiceType(typeof(SharedCache),
"myObj", WellKnownObjectMode.Singleton);
Client:
clientChannel = new IpcClientChannel();
ChannelServices.RegisterChannel(clientChannel);

ShareObj is the shared remoting object which can reading the file from
the disk and transport the file to the client process.- Hide quoted text -

- Show quoted text -
 

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