In fact, once you change the test to (fx<= n 1), the (inlining-limit 1000) doesn't change much; with it, I get
heine:~> gsc -exe fib2_scm
heine:~> time ./fib2_scm
2.160u 0.000s 0:02.16 100.0% 0+0k 0+0io 0pf+0w
Without it, I get
heine:~> gsc -exe fib2_scm
heine:~> time ./fib2_scm
2.280u 0.010s 0:02.29 100.0% 0+0k 0+0io 0pf+0w
If I add (inlining-limit 1000) to the original code with I get
heine:~> gsc -exe fib_scm
heine:~> time ./fib_scm
2.140u 0.020s 0:02.16 100.0% 0+0k 0+0io 0pf+0w
If I declare (not interrupts-enabled) in fib (I know this is not a good idea, because stack overflows are not caught), I get with (inlining-limit 1000) and the revised code:
heine:~> gsc -exe fib2_scm
heine:~> time ./fib2_scm
1.800u 0.010s 0:01.82 99.4% 0+0k 0+0io 0pf+0w
By the way, with
heine:~> /pkgs/chicken-4.6.0/bin/csc -O4 fib2_scm.scm
Warning: illegal declaration specifier: (inlining-limit 1000)
heine:~> time ./fib2_scm
3.080u 0.000s 0:03.08 100.0% 0+0k 0+0io 0pf+0w
while with
heine:~> /pkgs/chicken-4.6.0/bin/csc -O5 fib2_scm.scm
Warning: illegal declaration specifier: (inlining-limit 1000)
heine:~> time ./fib2_scm
0.970u 0.010s 0:00.98 100.0% 0+0k 0+0io 0pf+0w
I don't know what the various optimization levels of chicken mean precisely, or which options in -O5 makes the biggest difference over -O4:
-optimize-level 0 is equivalent to -no-usual-integrations -no-compiler-syntax
-optimize-level 1 is equivalent to -optimize-leaf-routine
-optimize-level 2 is equivalent to -optimize-leaf-routines -inline
-optimize-level 3 is equivalent to -optimize-leaf-routines -local -inline -inline-global
-optimize-level 4 is equivalent to -optimize-leaf-routines -local -inline -unsafe -unboxing
-optimize-level 5 is equivalent to -optimize-leaf-routines -block -inline -unsafe -unboxing -lambda-lift -disable-interrupts -no-trace -no-lambda-info
Marc, you know that with me and Gambit it's like the old Velvet Underground song: "I'm sticking with you, cause I'm made out of glue ..."
Brad