日期:2014-05-16  浏览次数:20368 次

fastjson发布1.1.1版本
之前的一个版本是1.1.0,1.1.0采用asm和SortFastMatch算法提高性能,由于过于着急展示其优越的性能,没有进行严格测试就发布了。

1.1.1相对于1.1.0,这是一个比较稳定的版本了,行测试覆盖率重新提升到90%以上,build verify testcase 983个。

这个版本进一步完善了asm和SortFastMatch算法,进一步提升了性能,同时补充了大量的testcase,提升了稳定性,我向你推荐使用这个版本,使用这个版本你将会得到令人惊奇的性能。

1.1.1版本的asm来源自objectweb的asm项目,根据fastjson的需要做裁剪,确保引入asm的同时不引起包大小的过渡变大。

为了更好使用sort field martch优化算法提升parser的性能,fastjson序列化的时候,缺省把SerializerFeature.SortField特性打开了。反序列化的时候也缺省把SortFeidFastMatch的选项打开了。这样,如果你用fastjson序列化的文本,输出的结果是按照fieldName排序输出的,parser时也能利用这个顺序进行优化读取。这种情况下,parser能够获得非常好的性能。

我使用github.com/eishay/jvm-serializers/提供的程序做测试,性能数据如下:
|  | 序列化时间 | 反序列化时间 | 大小 | 压缩后大小 |
|java序列化| 8546 | 43199 | 889 | 541|
|hessian| 6643 | 10043 | 501 | 313 |
|protobuf|3008 | 1694 | 239 | 149 |
| thrift | 3182 | 1951 | 349 | 197 |
| avro | 3575 | 2095 | 221 | 133 |
| jackson | 3245 | 2986 | 503 | 271 |
| fastjson | 2292 | 1499 | 468 | 251 |

的是跑的脚本是:
{code}
./run -chart -include=`cat serializers.txt | tr "\\n" ","`  data/media.1.cks
{code}

从上面的数据来看,fastjson的性能已经超越protobuf、thrift、avro这些二进制协议了。一个文本协议的性能超越二进制协议是很难的,我很高兴向你宣布我做到了!!

鉴于fastjson优越的性能表现,我建议做如下事情;
1、替换其他所有的json库,java世界里没有其他的json库能够和fastjson可相比了。
2、使用fastjson的序列化和反序列化替换java serialize,java serialize不单性能慢,而且体制大。
3、使用fastjson替换hessian,json协议不必hessian体积大,而且fastjson性能优越,数倍于hessian
4、把fastjson用于memached缓存对象数据。

h3. How to get it?
If you're Maven user, just use our maven repository(http://code.alibabatech.com/mvn/releases/) with folloging dependency
{code}
<dependency>
     <groupId>com.alibaba</groupId>
     <artifactId>fastjson</artifactId>
     <version>1.1.1</version>
</dependency>
{code}

h3. Downlaods
Source : http://code.alibabatech.com/mvn/releases/com/alibaba/fastjson/1.1.1/fastjson-1.1.1.jar
Binary :http://code.alibabatech.com/mvn/releases/com/alibaba/fastjson/1.1.1/fastjson-1.1.1-sources.jar
Subversion : http://code.alibabatech.com/svn/fastjson/
1 楼 tywo45 2011-08-01  
下面这段是1.1.1生成的json串,IE解析不了(同样的内容用1.0.6解析是可以的):{"completed":false,"currentDbName":"BRSCFG_DB","currentTableName":"R_IPDISP","dbCount":5,"dbIndex":5,"exceptionOccured":false,"infoForShow":"","progressIndex":3,"saveResult":0,"synMsgChangeListener":{"dispathComleted":false,"responseList":[{"responseMsg":"ftp mdb sync: recv msg from omc!"},{"responseMsg":"Table: R_FRG_IPDISP is a new table, not exist in ZDB !"},{"responseMsg":"Table: R_IPV6DISP is a new table, not exist in ZDB !"},{"responseMsg":"Table: R_INTERMEDIAIP is a new table, not exist in ZDB !"},{"responseMsg":"Table: R_BRSGLOBAL is a new table, not exist in ZDB !"},{"responseMsg":"Table: R_MAXCON is a new table, not exist in ZDB !"},{"responseMsg":"Table: R_IPPD is a new table, not exist in ZDB !"},{"responseMsg":"Table: R_IPDISP4_6_DYNAMIC is a new table, not exist in ZDB !"},{"responseMsg":"Table R_SCTP Field MAXBURST: FieldType isn't compatible,TypeZDB=2,TypeMem=1!"},{"responseMsg":"Table R_SCTP Field MAXBURST: FieldLength 1 is smaller in Mem!"},{"responseMsg":"Table: R_PORTATTIBUTE is a new table, not exist in ZDB !"},{"responseMsg":"Table: R_STATICARP is a new table, not exist in ZDB !"},{"responseMsg":"Table: R_BFDAUTH is a new table, not exist in ZDB !"},{"responseMsg":"Table: R_BFDSESSION is a new table, not exist in ZDB !"},{"responseMsg":"Table: R_VPN_VRF is a new table, not exist in ZDB !"},{"responseMsg":"Table: R_VRF_ATTR is a new table, not exist in ZDB !"},{"responseMsg":"Table: R_VRF_RT is a new table, not exist in ZDB !"},{"responseMsg":"Table: R_IPGLOBAL is a new table, not exist in ZDB !"},{"responseMsg":"Table: R_INICFG is a new t