New run request for fastjson

681 views
Skip to first unread message

szujobs

unread,
Aug 2, 2011, 5:30:56 AM8/2/11
to java-serialization-benchmarking

szujobs

unread,
Aug 2, 2011, 5:31:25 AM8/2/11
to java-serialization-benchmarking
create ser +same deser
+shal +deep total size +dfl
java-built-in 124 8654 8000 43787
44036 44242 52896 889 514
java-manual 127 1397 1239 1098
1047 1135 2532 255 147
hessian 118 6725 5967 10460
10401 10411 17136 501 313
protobuf 237 2964 1340 1745
1813 1991 4955 239 149
thrift 241 3177 3040 1949
2026 2122 5299 349 197
avro 155 3520 3359 1948
2526 3245 6765 221 133
json/jackson-manual 121 2062 1909 2927
2968 3032 5094 468 253
json/jackson-databind 123 3052 3017 4161
4294 4522 7574 503 271
json/json-lib-databind 124 45788 45075 146547
146743 147252 193039 485 263
json/fastjson-databind 123 2595 2454 1472
1523 1510 4105 468 255

Eishay Smith

unread,
Aug 6, 2011, 3:20:39 PM8/6/11
to java-serializat...@googlegroups.com
Would you like to fork the project on GitHub, add the fastjson code so we can pull it in?


--
You received this message because you are subscribed to the Google Groups "java-serialization-benchmarking" group.
To post to this group, send email to java-serializat...@googlegroups.com.
To unsubscribe from this group, send email to java-serialization-be...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/java-serialization-benchmarking?hl=en.


szujobs

unread,
Aug 7, 2011, 12:53:18 AM8/7/11
to java-serialization-benchmarking
What time to update the benchmark test results?

Had been fork on GitHub.:
https://github.com/szujobs/fastjson/tree/master/fastjson

On 8月7日, 上午3时20分, Eishay Smith <eis...@gmail.com> wrote:
> Would you like to fork the project on GitHub, add the fastjson code so we
> can pull it in?
>
>

Tatu Saloranta

unread,
Aug 7, 2011, 2:20:25 AM8/7/11
to java-serializat...@googlegroups.com
On Sat, Aug 6, 2011 at 12:20 PM, Eishay Smith <eis...@gmail.com> wrote:
> Would you like to fork the project on GitHub, add the fastjson code so we
> can pull it in?

I actually updated fastjson jar to latest, and optimized usage to bind
straight from byte array.
So I assume all that is needed is to re-run tests -- fastjson seems to
produce rather good numbers, possibly becoming the fast json
databinder tested.

-+ Tatu +-

szujobs

unread,
Aug 7, 2011, 6:04:51 AM8/7/11
to java-serialization-benchmarking
fastjson serialization time, sort by field name, using this sequential
output JSONString. This, parser can according to this order, using a
technique called "sort field fast match" algorithm, which greatly
improved parser performance.

fastjson dynamically generated deserializer using asm:
https://github.com/szujobs/fastjson/blob/master/fastjson/src/main/java/com/alibaba/fastjson/parser/deserializer/ASMDeserializerFactory.java

The following code demonstrates the behavior of the code generated:

// For fast matching prefix of each field
char[] size_ = "\"size\":".toCharArray();
char[] uri_ = "\"uri\":".toCharArray();
char[] titile_ = "\"title\":".toCharArray();
char[] width_ = "\"width\":".toCharArray();
char[] height_ = "\"height\":".toCharArray();

// Save parse the beginning of the lexer state information
int mark = lexer.getBufferPosition();
char mark_ch = lexer.getCurrent();
int mark_token = lexer.token();

int height = lexer.scanFieldInt(height_);
if (lexer.matchStat == JSONScanner.NOT_MATCH) {
// Exit fast mode into normal mode
lexer.reset(mark, mark_ch, mark_token);
return (T) super.deserialze(parser, clazz);
}

String value = lexer.scanFieldString(size_);
if (lexer.matchStat == JSONScanner.NOT_MATCH) {
// Exit fast mode into normal mode
lexer.reset(mark, mark_ch, mark_token);
return (T) super.deserialze(parser, clazz);
}
Size size = Size.valueOf(value);

// ... ...

// batch set
Image image = new Image();
image.setSize(size);
image.setUri(uri);
image.setTitle(title);
image.setWidth(width);
image.setHeight(height);

return (T) image;

szujobs

unread,
Aug 7, 2011, 6:13:09 AM8/7/11
to java-serialization-benchmarking
{ "id" : 123, "name" : "Steve Jobs", "salary" : 56789.79}
------ ------------ -------------

When using the "sort field fast match" algorithm, the above example,
the total number of token is 13, need to deal with the token only six.

On 8月7日, 下午6时04分, szujobs <szuj...@gmail.com> wrote:
> fastjson serialization time, sort by field name, using this sequential
> output JSONString. This, parser can according to this order, using a
> technique called "sort field fast match" algorithm, which greatly
> improved parser performance.
>
> fastjson dynamically generated deserializer using asm:https://github.com/szujobs/fastjson/blob/master/fastjson/src/main/jav...

Tatu Saloranta

unread,
Aug 7, 2011, 1:16:09 PM8/7/11
to java-serializat...@googlegroups.com
On Sun, Aug 7, 2011 at 3:04 AM, szujobs <szu...@gmail.com> wrote:
> fastjson serialization time, sort by field name, using this sequential
> output JSONString. This, parser can according to this order, using a
> technique called "sort field fast match" algorithm, which greatly
> improved parser performance.
>
> fastjson dynamically generated deserializer using asm:
> https://github.com/szujobs/fastjson/blob/master/fastjson/src/main/java/com/alibaba/fastjson/parser/deserializer/ASMDeserializerFactory.java

Yes, I noticed that, very clever! And good thing is it works even if
order varies (or fields are missing), so that it is an optimization
and not requirement. And this definitely produces high throughput
numbers.

-+ Tatu +-

Programmer Bruce

unread,
Nov 22, 2011, 6:08:46 AM11/22/11
to java-serializat...@googlegroups.com
I'm working on incorporating these updates and running a new performance test.  Will update wiki once I get things working...

Programmer Bruce

unread,
Nov 28, 2011, 2:59:41 AM11/28/11
to java-serializat...@googlegroups.com

ikabiljo

unread,
Nov 29, 2011, 11:59:35 AM11/29/11
to java-serializat...@googlegroups.com
Cool! 
One question, I added Wobly library between last two test runs, so it is in the updated results (thanks!), but doesn't have a link in the list, and isn't on the ToolBehavior page. 
Can I just add them there, or is it preferable if some contributor adds it there?

Link to the Wobly is: http://code.google.com/p/wobly/

Fields for Wobly in ToolBehavior page should be:
Language-Neutral: no (java only)
Data Structure: annotate
Serialization: auto
Formats: binary

It is also backward and forward compatible.

Thanks,
ikabiljo

Programmer Bruce

unread,
Nov 29, 2011, 12:04:03 PM11/29/11
to java-serializat...@googlegroups.com
I think the wiki page is publicly editable.  If it's not, then I'll be glad to update it.

ikabiljo

unread,
Nov 29, 2011, 2:30:04 PM11/29/11
to java-serializat...@googlegroups.com
Thanks.
I am having trouble updating wiki - when I only click on edit, and on preview (or save), all the formatting is lost (and tags are being shown). It shows edit mode to be MediaWiki, is that the one you use?

Regards,
ikabiljo

Programmer Bruce

unread,
Nov 29, 2011, 2:39:59 PM11/29/11
to java-serializat...@googlegroups.com
I added the link to Wobly.  The edit mode defaults to Textile for me.

ikabiljo

unread,
Nov 29, 2011, 11:05:10 PM11/29/11
to java-serializat...@googlegroups.com
Thanks!
I added Wobly to ToolBehaviour wiki.(switching to Textile keeps the formatting) 
Reply all
Reply to author
Forward
0 new messages