AutoBeanCodex.decode performance

60 views
Skip to first unread message

Sam J.

unread,
Jul 27, 2011, 10:22:35 AM7/27/11
to Google Web Toolkit
Hi all

I'm seeing some slowness with AutoBeanCodex.decode(...), and I have a
few questions.
In my application, it needs to decode hundreds of json objects. Here
are some rough timings:

FF3 on Mac: <1 second
Safari on Mac: <1 second
Chrome on Mac: seconds, but still reasonable
IE6 on XP: 1 minute+

Is there anything I can do to make the parsing run faster on IE6? I
know the parsing code is slow because when I substitute json parsing
with randomly generated data, IE6 renders within reasonable time. (I
hate IE6, hate IE6, hate IE6... but that doesn't mean I can skip its
support =/)

I'm looking at the AutoBeanCodex.decode code. Does it have any calls
that are known to be slow on IE6? What about builtin function eval? I
heard there are security risks, but say if I mind them (crossing
fingers >_<), is there a way to tell autobean codex to use eval
instead of the default parser?

many thanks

p.s. I understand that there are other work arounds (like incremental
loading etc) to this issue, for now, I just want to focus on
AutoBeanCodex.decode.

Thomas Broyer

unread,
Jul 27, 2011, 7:53:07 PM7/27/11
to google-we...@googlegroups.com
FYI, AutoBeanCodex.decode uses StringQuoter, whose super-source implementation (used in compiled code only) uses JsonUtils.safeEval, which in turn uses eval() in IE6 to "parse" the JSON, after checking it with a couple regexps. So maybe the regexps are slow with large strings?
You could try overriding the StringQuoter (put your version earlier on the classpath) with a version that uses JsonUtils.unsafeEval to see if it makes a difference (at your own risks).

But AutoBeans do create a lot of objects (an AutoBean and a "wrapper" implementing your interface for each object in the JSON), and that could really be the bottleneck in your case.

Sam J.

unread,
Jul 28, 2011, 10:29:45 AM7/28/11
to Google Web Toolkit
As you suspected, the bottleneck is indeed elsewhere, very likely in
object creation.
I swapped safeEval with unsafeEval, and that only saved me about
50-100ms down from 300-400ms.

Are there any fixes / hacks that can speed up the autobean framework?

thanks

Sam J.

unread,
Jul 28, 2011, 11:15:04 AM7/28/11
to Google Web Toolkit
actually, I just did an upgrade from gwt 2.2 to gwt 2.3. I did not
realize the AutoBean decode got reworked. I now see a speedup more
than 50% =D
Reply all
Reply to author
Forward
0 new messages