Re: GWT 10 times slower in web (production) mode than hosted (developer) mode

187 views
Skip to first unread message

Bhaskar Janakiraman

unread,
Dec 15, 2012, 10:36:08 PM12/15/12
to google-we...@googlegroups.com
Perhaps you are running into limitations imposed by Javascript on GWT? See:
https://developers.google.com/web-toolkit/doc/latest/DevGuideCodingBasicsCompatibility

On Saturday, December 15, 2012 4:49:25 PM UTC-8, Sami Kanderian wrote:
Dear all,

I am having the opposite problem than what is reported by most of you and would appreciate some advice. I am fairly new to GWT and wrote my first app that runs entirely client side. When a button is clicked it does tens or even hundreds of thousands flops that are mathematical computations and outputs the result. I have placed timers in the code and this computation algorithm takes 2 seconds to run in developer mode (i.e when it runs in Java). This run time is acceptable.  However, when I GWT compiled the app (into JavaScript) and run it on the web, the same computation function takes 25 seconds. This latency is unacceptable. My question is what’s the best way to resolve this? I see 2 potential options and wouls appreciate some advice on which way I should go and if there are alternative options I am missing:

Option 1:

-          - Should I switch the computation functions to run server side?

          - How much time does it take the server to send 5,000 doubles back to the client?

Option 2:

-           - Should I scratch GWT and the whole JavaScript conversion/compilation and just have the whole thing run in Java client side in an applet? I am bummed as I chose GWT as to have the App run on many different platforms that do not accept the Java Run Time Engine.

      -  I like the GUI I am using, can GWT and Smart GWT GUIs run a Java Applet (i.e can I use the same GUI I created with GWT but run the core components of the app in Java, basically run like it does in developer mode now but as the finished app?)

Thanks in advance!

Sami

Daniel Kurka

unread,
Dec 16, 2012, 3:07:56 AM12/16/12
to google-web-toolkit
Since GWT is compiled to JavaScript, runtime performance for heavy computations is highly dependent on the JavaScript engine performance. 

On which browser is this happening?

For your heavy computation you might want to consider rewriting it to use JavaScript semantics (e.g. JsArray) instead of Java semantics since all Java semantics have to be emulated in JavaScript and this comes with some overhead.

There is always the options to profile the actual code with a JavaScript profiler (Chrome developer tools) to find out why its actually slow.

Maybe you can post the relevant part of your algorithm so we can point you in the right direction.

-Daniel





2012/12/16 Bhaskar Janakiraman <bjanak...@google.com>

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/ngNj_ZFK9PMJ.

To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Ümit Seren

unread,
Dec 17, 2012, 7:35:04 AM12/17/12
to google-we...@googlegroups.com
There are several angel to the problem. 

1.) find out what is causing the performance issues (you can use Chrome Dev Tools to do that). 
2.) if you found out what is the root of the performance issue, try to improve performance by using for example different data structure (see the other poster's comment about Hashset, typed arrays, etc). There are a couple of interesting Google I/O talks about javascript and V8 performance pitfalls, etc. 
3.) If you optimized your code and it is still slow you can do 3 things: 
   - Run the code asynchronously using web workers (provide feedback to the user using a progress bar etc). Your UI will still be responsive because the computation is  done asynchronously via web workers
   - Look into Nacl (Native Client). It allows you write native (C/C++, etc) code and run it in your Browser at almost native speed (will be similar in performance as if you would run it in a java applet) 
   - Run the computation on the server and transmit the results to the client. 

BTW: 5000 double values are no problem at all. I transmit and serialize/de-serialize up to 10.000 float values (using JSON) with minimal time delay. 
Reply all
Reply to author
Forward
0 new messages