Remoting large dataset - deserialization is slow
- From: "tanitack" <tanitack@xxxxxxxxx>
- Date: 5 Nov 2006 22:36:33 -0800
Hi,
We have a client/server application windows based application. The
client displays a number of data points to the user. We transfer all
the necessary data over remoting. The data is transferred as a dataset
containing all the required tables. We use the compression code given
in Chapter 13, Extending .Net Remoting, by Ingo Rammer. The compression
works fine and transfers the data over the remoting channel pretty fast
even for around 68369 rows. But even though remoting is fast, there are
other things which take time at the client side and server side.
For example, on the server side in the CompressioHelper class we have
the GetCompressedStreamCopy which takes some 4 to 5 seconds.
public static Stream GetCompressedStreamCopy(Stream inStream) {
Stream outStream = new System.IO.MemoryStream();
DeflaterOutputStream compressStream = new DeflaterOutputStream(
outStream,new Deflater(Deflater.BEST_COMPRESSION));
byte[] buf = new Byte[1000];
int cnt = inStream.Read(buf,0,1000);
while (cnt>0) {
compressStream.Write(buf,0,cnt);
cnt = inStream.Read(buf,0,1000);
}
compressStream.Finish();
compressStream.Flush();
outStream.Seek(0,SeekOrigin.Begin);
return outStream;
}
Here the loop takes time. If we remove the loop and do it in one go
like,
public static Stream getCompressedStreamCopy(Stream inStream) {
Stream outStream = new System.IO.MemoryStream();
DeflaterOutputStream compressStream = new
DeflaterOutputStream(outStream,
new Deflater(Deflater.DEFAULT_COMPRESSION));
int bufferSize = Convert.ToInt32(inStream.Length);
byte[] buf = new Byte[bufferSize];
int cnt = inStream.Read(buf,0,bufferSize);
//while (cnt>0) {
compressStream.Write(buf,0,cnt);
//cnt = inStream.Read(buf,0,bufferSize);
//}
compressStream.Finish();
compressStream.Flush();
return outStream;
}
Even this case there is a 4 second time to compress the data. The 4
second is just for the one statement
"compressStream.Write(buf,0,cnt);". Is there any way to improve this?
We want to bring up all the data on the client side in less than 10
secs. Though remoting over the wire doesnt take much time, data loading
+ plus this 4 secs makes it almost 20 secs on the server side alone.
The buffer size in the above code for which it took 4 secs was
35139484.
Client Side:
The client side decompression happens pretty fast. But after it gets
decompressed and moves through the call stack to the point where the
original method call was made, it takes almost a minute. The bulk of
the time is between two system calls:
The time taken to hit RemotingProxy.CallProcessMessage() after it hits
Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage() is 40
seconds. So we are loosing all the time saving we have made by
compressing the data. Basically you find it to be taking huge time to
deserialize, the surprise thing is serialization is faster. Any clues
as why all these are happening?
regards,
Catinat
.
- Follow-Ups:
- Re: Remoting large dataset - deserialization is slow
- From: Yuancai \(Charlie\) Ye
- Re: Remoting large dataset - deserialization is slow
- From: Spam Catcher
- Re: Remoting large dataset - deserialization is slow
- Prev by Date: Re: server auto-identification of the clients after authenfication
- Next by Date: Re: Remoting large dataset - deserialization is slow
- Previous by thread: Re: server auto-identification of the clients after authenfication
- Next by thread: Re: Remoting large dataset - deserialization is slow
- Index(es):
Relevant Pages
|