[kramdown-users] Performance optimizations

Shawn Van Ittersum svicalifornia at gmail.com
Thu Oct 28 05:45:17 EDT 2010


Hi Thomas,

How do you implement preservation of element attribute order?  Would you please point me to it in the code?

Thanks,
Shawn

On Thu, 28 Oct 2010 10:05:06 +0200, Thomas Leitner wrote:
> Hi everybody,
> 
> there was a major performance drop in the 0.11.0 version of kramdown
> due to the preservation of the ordering of the element attributes.
> 
> I did some investigations and found that turning off the garbage
> collector makes kramdown run much faster. So it seems that kramdown
> creates too much objects and the garbage collector has to do too much.
> After some tweaking the performance of the next release should be much
> better again. Also, 15% less objects are created in comparison with the
> 0.11.0 release.
> 
> Here are some performance numbers for various kramdown versions on
> different ruby versions. All benchmarks are run on an Intel Core i5
> M520 with 4GB memory on Ubuntu 10.10 with 64bit. The data is generated
> with the new `benchmark/benchmark.sh` script. You can reproduce the
> data by cloning the git repository and running
> 
>     bash benchmark/benchmark.sh -k "REL_0_1_0 REL_0_6_0 REL_0_9_0 
> REL_0_10_0 REL_0_11_0 master"
> 
> The generated data can be found in /tmp/kramdown-benchmark. By default
> all tags and the master version are used for the kramdown versions if
> not overridden with the `-k` option. The script uses rvm to switch
> between ruby versions, so you need that too! You will also need gnuplot
> so that the images can be generated.
> 
> jruby-1.5.0RC1
> #       REL_0_1_0 ||  REL_0_6_0 ||  REL_0_9_0 || REL_0_10_0 || 
> REL_0_11_0 ||     master
>   1       0.23100       0.21300       0.24600       0.17700       
> 0.18600       0.25500
>   2       0.15100       0.23300       0.21500       0.21300       
> 0.24600       0.21600
>   4       0.17200       0.17400       0.19600       0.18700       
> 0.33900       0.23600
>   8       0.29300       0.28600       0.31200       0.29600       
> 0.37600       0.31800
>  16       0.37400       0.35600       0.52100       0.50500       
> 0.42200       0.45600
>  32       0.59000       0.55700       0.59900       0.59900       
> 0.70300       0.64900
> 
> ruby 1.8.5-p231
> #       REL_0_6_0 ||  REL_0_9_0 || REL_0_10_0 || REL_0_11_0 ||     master
>   1       0.01000       0.01051       0.01136       0.01195       0.01175
>   2       0.02109       0.02174       0.02119       0.02277       0.02039
>   4       0.03730       0.04732       0.04732       0.04573       0.04850
>   8       0.09734       0.08701       0.08335       0.11130       0.08702
>  16       0.18256       0.20505       0.19535       0.23545       0.20143
>  32       0.41248       0.44407       0.46074       0.49541       0.46472
> 
> ruby 1.8.6-p399
> #       REL_0_1_0 ||  REL_0_6_0 ||  REL_0_9_0 || REL_0_10_0 || 
> REL_0_11_0 ||     master
>   1       0.01241       0.01014       0.01191       0.01134       
> 0.01222       0.01117
>   2       0.01608       0.02513       0.02176       0.02733       
> 0.02321       0.02155
>   4       0.03024       0.03929       0.04743       0.04753       
> 0.04654       0.04751
>   8       0.06593       0.07937       0.08792       0.08623       
> 0.09291       0.08353
>  16       0.13082       0.17244       0.19194       0.18539       
> 0.22715       0.18366
>  32       0.27855       0.38740       0.42560       0.42649       
> 0.47899       0.49377
> 
> ruby 1.8.7-p249
> #       REL_0_1_0 ||  REL_0_6_0 ||  REL_0_9_0 || REL_0_10_0 || 
> REL_0_11_0 ||     master
>   1       0.00895       0.01051       0.01264       0.01274       
> 0.01242       0.01141
>   2       0.01722       0.02107       0.02299       0.02229       
> 0.02382       0.02318
>   4       0.03070       0.04586       0.04909       0.04872       
> 0.04764       0.04919
>   8       0.06811       0.08272       0.09249       0.09098       
> 0.11013       0.08745
>  16       0.16567       0.17962       0.19554       0.18920       
> 0.22599       0.18849
>  32       0.28729       0.39177       0.53765       0.44901       
> 0.49453       0.39598
> 
> ruby 1.8.7-p302
> #       REL_0_1_0 ||  REL_0_6_0 ||  REL_0_9_0 || REL_0_10_0 || 
> REL_0_11_0 ||     master
>   1       0.00966       0.01171       0.01291       0.01286       
> 0.01387       0.01261
>   2       0.01778       0.02483       0.02535       0.02476       
> 0.03128       0.02728
>   4       0.03422       0.05098       0.05400       0.05377       
> 0.05474       0.05435
>   8       0.07529       0.09204       0.09825       0.09899       
> 0.12087       0.09575
>  16       0.18189       0.19847       0.21057       0.25462       
> 0.24744       0.20743
>  32       0.31704       0.43067       0.51242       0.51385       
> 0.53427       0.44922
> 
> ruby 1.9.2-p0
> #       REL_0_1_0 ||  REL_0_6_0 ||  REL_0_9_0 || REL_0_10_0 || 
> REL_0_11_0 ||     master
>   1       0.01357       0.00870       0.00934       0.00935       
> 0.01056       0.00968
>   2       0.02199       0.01758       0.01957       0.01947       
> 0.02030       0.01938
>   4       0.04581       0.03701       0.04082       0.04215       
> 0.04545       0.04122
>   8       0.09261       0.07473       0.08601       0.08608       
> 0.08778       0.08847
>  16       0.18589       0.14448       0.15985       0.16125       
> 0.18634       0.15448
>  32       0.38448       0.31029       0.35264       0.35203       
> 0.37317       0.34102
> 
> -- Thomas
> _______________________________________________
> kramdown-users mailing list
> kramdown-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/kramdown-users


More information about the kramdown-users mailing list