[erlang-questions] [ANNOUNCE] JSX 1.0 and 1.1rc

Dmitry Kolesnikov dmkolesnikov@REDACTED
Thu Mar 22 20:08:03 CET 2012


Hello,

Just run the test on Mac Mini: 2GHz i7, 4GB 1333 MHz (basic Min Server) with R15B

./configure --prefix=/usr/local/otp-R15B --enable-threads --enable-smp-support --enable-kernel-poll --enable-sctp --enable-hipe --disable-dynamic-ssl-lib --enable-darwin-64bit --enable-m64-build --without-javac

100 unique objects has been converted to_json and to_term about 10000 times (100 time per object) and jsx result was compared with mochijson2. Got the following results:

to_term
 * jsx:       2231 ms, 0.223 ms per object
 * mochi:  2347 ms, 0.235 ms per object

to_json
 * jsx:       5203 ms, 0.520 ms per object
 * mochi: 1511ms,  0.151 ms per object

The problem with jsx is inefficient json_escape algorithm that causes alot of binary string copying. 
See the profile:
{[{{jsx_utils,json_escape,2},                  3200,  347.542,    7.202},      
  {{jsx_utils,json_escape,3},                  218000,    0.000,  334.072}],     
 { {jsx_utils,json_escape,3},                  221200,  347.542,  341.274},     %
 [{garbage_collect,                             535,    5.287,    5.287},      
  {suspend,                                     107,    0.981,    0.000},      
  {{jsx_utils,json_escape,3},                  218000,    0.000,  334.072}]}.

I've made an fix to it and now

to_json
 * jsx       2157ms, 0.217 ms per object
 * mochi 1495ms, 0.150 ms per object

but the memory usage dynamic fir jsx if much more better (like it is reported by erlang:memory(processes)

* jsx      from 1.921.751 to max 2.045.904
* mochi from 1.724.560 to max 4.498.640

As a conclusion: 

fixed jsx ;-) is 1.45 times slower then mochijson but 2x time more memory efficient + I like jsx semantic of object encoding/decoding. BTW, I'll send you a pull request for performance fix.

- Dmitry


On Mar 21, 2012, at 4:38 PM, Tristan Sloughter wrote:

> I'll try to run a performance comparison your code and mochiweb in my test env.
> 
> It would be great if you included jiffy (https://github.com/davisp/jiffy) too and please share if you do :)
> 
> Tristan
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120322/9eb9b89c/attachment.htm>


More information about the erlang-questions mailing list