9

I am observing really bad performance when using GWT requestfactory. For example, a request that takes my service layer 2 seconds to fullfil is taking GWT 20 seconds to serialize. My service is returning ~100 what will be EntityProxies. Each of these objects has what will become 4 ValueProxies and 2 more EntityProxies (100 root level EntityProxies, 400 ValueProxies and 200 additional EntityProxies). However, I see the same 10x performance degradation on much smaller datasets.

Example of log snippet:

D 2012-10-18 22:42:39.546 ServiceLayerDecorator invoke: Inoking service layer took 2265 ms
D 2012-10-18 22:42:58.957 RequestFactoryServlet doPost: Entire request took 22870 ms

I have added some profiling code to the ServiceLayerDecorator#invoke method and wrapped the entire servlet in a timer. I have profiled the service by itself, and it is indeed returning results in ~2s.

I am using GWT 2.4, but have tested this on GWT 2.5rc1 and GWT 2.5rc2. My backend is on GAE, but I dont think that is playing a role here.

I found this bug filed against 2.4, which seems to be very related. I have manually applied the patch from this google group without any luck.

My domain models look like:

class Trip {
  protected Address origin; // becomes ValueProxy
  protected Address destination; becomes ValueProxy
  protected Set<TripPassenger> tripPassengers; // Set of ValueProxies
}

class TripPassenger {
  protected Passenger passenger;
}

class Passenger {
  protected Account account;
}

My question is:

  • Have I profiled the code correctly and isolated the problem to the GWT serialization?
  • Could I be doing something wrong that would cause this behavior?
  • How can I better profile the GWT serialization code to try and figure out the cause?
Brad
  • 5,428
  • 1
  • 33
  • 56
  • I think you have a too complex datastructure. Try to flatten it. Cn you explain a little more, how your DTO look like? Do you use AutoBean? – Christian Kuetbach Oct 19 '12 at 17:47
  • I added part of the domain model to the question. In some of the more expensive ones, this is the graph that is getting loaded up. Do you have any references for saying the data structure is too complex? What is complex about it (the size or the relationships)? To me, it seems fairly reasonable for any business application. I have started looking at AutoBean and am thinking about returning JSON from the server instead. – Brad Oct 19 '12 at 20:26
  • I just profiled a request that loads up ~10 EntityProxies (no ValueProxy or nested associations). The service layer took ~1s but GWT serialization took just over 3 seconds. – Brad Oct 19 '12 at 20:51

1 Answers1

1
  • Have I profiled the code correctly and isolated the problem to the GWT serialization?

RequestFactory uses reflection a whole lot (much more than GWT-RPC for instance), so I'm not really surprised that it causes some perf issues in some cases. And GAE could play a role here.
I believe RequestFactory (the AutoBean part actually) could greatly benefit from code generation at build-time.

  • Could I be doing something wrong that would cause this behavior?

Check your locators' find and/or isLive methods.

  • How can I better profile the GWT serialization code to try and figure out the cause?

It would also be interesting to know the time spent on deserialization of the request, applying changes, and then serialization of the response. And don't forget to substract from those the time spent in find and isLive.

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164
  • I will get a breakdown of times shortly. I spent most of the weekend profiling my code and one thing I noticed was that requests that include a domain model as an argument do not have an expensive serialization time. For example `Trip service.save(Trip t)` has ~100ms of serialization time. Whereas `Trip service.find(String id)` has near 12k ms of serialization time. Same graph structures but different contexts. Also, my isLive method is stubbed out to always return true. – Brad Oct 22 '12 at 15:44
  • Interesting. Feel free to open a new issue in the GWT tracker with what you found out profiling your app. Thanks in advance! – Thomas Broyer Oct 22 '12 at 16:37