LazySweepの性能を上げた

バグがあった

前に作ったパッチは異様にMarkが遅い時があった。
それで、調べてみるとHeapの使い方がおかしいことに気づく。
さらに調べると、パッチのコードにバグがあった。。。
そこを改善すると性能が上がりました。
(たった1行の変更)
 

benchmark

bencmarks.tar

   normal  lazy_old  lazy_improve  lazy_old  lazy_improve
 bm_gc_flagment  time      diff  
           
 gc call  20  47911  47735  239555%  238675%
 gc all time  176.0664  219.9233  157.5371  124.90%  89.475%
 gc ave time  8.803324  0.004590  0.003300  0.0521%  0.0374%
 gc min time  0.076007  0.000691  0.000691  0.9091%  0.9091%
 gc max time  18.40860  15.60051  7.101607  84.745%  38.577%
           
 mark call  20  19  15  95%  75%
 mark all time  92.25098  90.98276  44.54592  98.625%  48.287%
 mark ave time  4.612549  4.788566  2.969728  103.81%  64.383%
 mark min time  0.066294  0.066308  0.068591  100.02%  103.46%
 mark max time  9.965903  15.58728  7.098406  156.40%  71.226%
           
 sweep call  20  47911  47735  239555%  238675%
 sweep all time  83.77476  104.2004  88.42194  124.38%  105.54%
 sweep ave time  4.188738  0.002174  0.001852  0.0519%  0.0442%
 sweep min time  0.008609  0.000289  0.000289  3.3569%  3.3569%
 sweep max time  9.022408  3.481890  1.677408  38.591%  18.591%
           
 program time  18.39694  20.13445  18.81249  109.44%  102.25%
           
 bm_gc_heapsort          
           
 gc call  46  508  672  1104.3%  1460.8%
 gc all time  3.560066  4.733865  4.020089  132.97%  112.92%
 gc ave time  0.077392  0.009318  0.005982  12.040%  7.7294%
 gc min time  0.044798  0.000786  0.000691  1.7545%  1.5424%
 gc max time  0.098204  0.100278  0.067400  102.11%  68.632%
           
 mark call  46  58  45  126.08%  97.826%
 mark all time  1.932518  2.541659  1.916026  131.52%  99.146%
 mark ave time  0.042011  0.043821  0.042578  104.30%  101.34%
 mark min time  0.0  0.026998  0.026988    
 mark max time  0.058300  0.061804  0.062496  106.01%  107.19%
           
 sweep call  46  507  672  1102.1%  1460.8%
 sweep all time  1.532042  1.914015  1.725266  124.93%  112.61%
 sweep ave time  0.033305  0.003775  0.002567  11.334%  7.7075%
 sweep min time  0.012897  0.0  0.0  0%  0%
 sweep max time  0.041300  0.048391  0.012100  117.16%  29.297%
           
 program time  0.477287  0.519978  0.486881  108.94%  102.01%
           
 bm_gc_life          
           
 gc call  84  1154  1244  1373.8%  1480.9%
 gc all time  7.709240  10.73818  8.735369  139.28%  113.31%
 gc ave time  0.091776  0.009305  0.007022  10.138%  7.6512%
 gc min time  0.062704  0.000786  0.0  1.2535%  0%
 gc max time  0.099992  0.069403  0.059103  69.408%  59.107%
           
 mark call  84  123  84  146.42%  100%
 mark all time  2.734374  4.073444  2.713968  148.97%  99.253%
 mark ave time  0.032552  0.033117  0.032309  101.73%  99.253%
 mark min time  0.0  0.030392  0.030502    
 mark max time  0.042798  0.050308  0.041494  117.54%  96.953%
           
 sweep call  83  1153  1242  1389.1%  1496.3%
 sweep all time  4.802001  6.057985  5.338222  126.15%  111.16%
 sweep ave time  0.057855  0.005254  0.004298  9.0813%  7.4289%
 sweep min time  0.018792  0.0  0.0  0%  0%
 sweep max time  0.062794  0.048805  0.016800  77.722%  26.754%
           
 program time  0.494729  0.537175  0.485718  108.57%  98.178%
           
 bm_gc_many_obj_make          
           
 gc call  21  32375  32375  154166%  154166%
 gc all time  462.4284  257.0240  257.9035  55.581%  55.771%
 gc ave time  22.02040  0.007938  0.007966  0.0360%  0.0361%
 gc min time  0.049901  0.000691  0.000596  1.3847%  1.1943%
 gc max time  69.60859  50.98810  50.97548  73.249%  73.231%
           
 mark call  21  13  13  61.904%  61.904%
 mark all time  325.5857  101.0185  101.5506  31.026%  31.190%
 mark ave time  15.50408  7.770661  7.811590  50.120%  50.384%
 mark min time  0.041700  0.038507  0.039900  92.342%  95.683%
 mark max time  43.25510  37.56229  37.62219  86.838%  86.977%
           
 sweep call  21  32375  32375  154166%  154166%
 sweep all time  136.7694  138.4491  138.4993  101.22%  101.26%
 sweep ave time  6.512830  0.004276  0.004277  0.0656%  0.0656%
 sweep min time  0.007096  0.000108  0.000101  1.5219%  1.4233%
 sweep max time  26.34820  13.53378  13.41298  51.365%  50.906%
           
 program time  14.70822  15.98557  15.87122  108.68%  107.90%
           
 bm_gc_mapsort          
           
 gc call  41  604  607  1473.1%  1480.4%
 gc all time  3.710389  6.038641  4.816651  162.74%  129.81%
 gc ave time  0.090497  0.009997  0.007935  11.046%  8.7682%
 gc min time  0.056600  0.000691  0.000691  1.2208%  1.2208%
 gc max time  0.118398  0.086498  0.104308  73.056%  88.099%
           
 mark call  41  67  41  163.41%  100%
 mark all time  2.246501  3.859802  2.608042  171.81%  116.09%
 mark ave time  0.054792  0.057608  0.063610  105.13%  116.09%
 mark min time  0.028796  0.027307  0.036204  94.829%  125.72%
 mark max time  0.081504  0.080888  0.099607  99.244%  122.21%
           
 sweep call  41  604  607  1473.1%  1480.4%
 sweep all time  1.429922  1.866080  1.842123  130.50%  128.82%
 sweep ave time  0.034876  0.003089  0.003034  8.8570%  8.6993%
 sweep min time  0.014900  0.000208  0.000292  1.3959%  1.9597%
 sweep max time  0.036900  0.039418  0.015988  106.82%  43.327%
           
 program time  0.206207  0.238099  0.206643  115.46%  100.21%

結果

全体的に以前のLazySweepよりも改善されている。
中でも最大停止時間は以前と比べても、よく改善されているようだ。
 

自分への教訓

たった1行の変更でここまで改善するとは。。。
恐ろしいもんですね。