GWT Requestfactory performance suggestions

核能气质少年 提交于 2019-12-04 10:36:30

问题


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?

回答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.



来源:https://stackoverflow.com/questions/12977922/gwt-requestfactory-performance-suggestions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!