Sending large nested DTO object over RPC - Browser freezes

148 views
Skip to first unread message

Jonas

unread,
Jun 15, 2011, 9:07:20 AM6/15/11
to google-we...@googlegroups.com
 In my GWT program I parse a large xml file using JAXB on the server side and then convert these objects into DTO. They contain a lot of strings, doubles, and integers in a nested hierarchy. I'm using ArrayList as collection for the nested objects. The problem is that when I send this over RPC it takes around 16 seconds and the browser freezes. I first thought there was something wrong with JAXB or the DTO conversion but as you can see below they are very fast:

DEBUG gwt-log:72 - - JAXB conversion time: 0.047 seconds
DEBUG gwt-log:72 - - DTO conversion time: 0.015 seconds

When I inspect the RPC call using FireBug I can see that the object being transferred is 4.6 kb and it says POST dispatch 111ms.

When I inspect some more I can see that the function @com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader::readInt() seems to be the culprit with 5428 calls and 6654ms total time.
::getString(I), ::readDouble(), ::readLong() are also called a lot with around 3000ms each.

Am I doing something wrong here or should it really be this slow? ~16 seconds for 5 kb of DTO data. It just seems wrong to me.

brancoch

unread,
Jun 15, 2011, 9:58:57 AM6/15/11
to Google Web Toolkit
You probably can try the com.google.gwt.rpc.RPC module though it has
been experimental for awhile. It seems to be a more efficient way of
encoding and decoding.

To use it it is almost the same as the other RPC:

1- Inherit the module: <inherits name='com.google.gwt.rpc.RPC'/>

2- Have you service interface extends the
com.google.gwt.rpc.client.RpcService
Ex:
/**
* The client side stub for the RPC service.
*/
@RemoteServiceRelativePath("myService ")
public interface MyService extends RpcService {
MyComplexObject myMethod(String name);
}

3- Have your implementation extends from
com.google.gwt.rpc.server.RpcServlet

Ex:
@SuppressWarnings("serial")
public class MyServiceImpl extends RpcServlet implements MyService {

public MyComplexObject myMethod(String input) {
return null;
}

}

4- You need the Async the same way as the other RPC service:
Ex:
public interface MyServiceAsync {
void myMethod(String input, AsyncCallback<MyComplexObject> callback);
}

This is it.

Paul Stockley

unread,
Jun 15, 2011, 11:14:49 AM6/15/11
to google-we...@googlegroups.com
Is this in dev mode or the final compiled JS?

Jonas

unread,
Jun 15, 2011, 12:42:11 PM6/15/11
to google-we...@googlegroups.com
This is hosted mode and on my intel core i3 work laptop. I tried the same code on my home computer and there it was much faster, around 5 seconds instead of 16. But still, far from what I had expected. I'll try and see what the speed is when deployed.

ciosbel

unread,
Jun 15, 2011, 4:34:48 PM6/15/11
to google-we...@googlegroups.com
Try to use this to better inspect RPC serialization/deserialization and round trip timings.
http://code.google.com/p/gwt-debug-panel/

Jambi

unread,
Jun 17, 2011, 5:02:12 AM6/17/11
to Google Web Toolkit
How long does it take when you run the compiled code? I think the
hosted mode could be the problem here.

Jens

unread,
Jun 17, 2011, 5:28:05 AM6/17/11
to google-we...@googlegroups.com
Hosted mode is really slow when it comes to serialization/deserialization with GWT RPC. In my experience the Firefox GWT plugin does the best job and handle it a way faster than in other browsers. I think even in compiled mode you would recognize some delay at least in IE. Maybe its faster to encode your data in JSON and transfer the JSON String. Parsing JSON on client side is way faster than serialization/deserialization.


Jonas

unread,
Jun 17, 2011, 8:37:39 AM6/17/11
to google-we...@googlegroups.com
It definitely was hosted mode that was the problem. When compiled and deployed it takes only a couple of seconds, somewhere around 5 seconds for very large files which is still a bit too long for me to be satisfied. I think I will give JSON a shot. Thanks all for the feedback.
Reply all
Reply to author
Forward
0 new messages