クロージャ生成のコスト - パフォーマンスチューニング

ある手続きが重いので調べていた。
そこでは fold を使っていてその引数に渡している無名 lambda が重い原因だった。
その手続きが数十万回呼ばれるものだったのでクロージャも数十万回生成されて重いという。
グローバルなクロージャを定義しコストを抑えたら速くなった。


次は append2 が呼ばれているところを特定するか。

time%        msec      calls   name                              location
  24          320          -   (<top-level>)
  18          240      17932   append2
   9          120       4606   pass3/find-free
   6           90       4039   code-builder-append!
   4           60       4347   pass3/find-sets
   3           50       8883   (pass1/call proc args lib...)     compiler-with-library.scm:7287
   3           40       4039   (pass3/$lambda cb iform l...)     compiler-with-library.scm:9923
   3           40      25245   find10
   1           20      42676   (pass1/sexp->iform sexp l...)     compiler-with-library.scm:7549
   1           20     112784   (generic-assoc releq obj ...)     compiler-with-library.scm:1229
   1           20      49459   (pass1/expand sexp)               compiler-with-library.scm:6525
   0           10          2   (lambda lis ans)                  compiler-with-library.scm:116