[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Where is my performance going?



Taking a virgin Takeuchi function:

(defun tak (x y z)
  (if (not (< y x))
      z
      (tak (tak (1- x) y z)
	   (tak (1- y) z x)
	   (tak (1- z) x y))))

If you evaluate the function before compiling it, you suffer a serious
performance handicap. For example, 
(a) -------------------------------------------------------
Try wiping the following into your kill ring, then yanking it into a listener:

(compile
  (defun tak1 (x y z)
    (if (not (< y x))
        z
        (tak1 (tak1 (1- x) y z)
	      (tak1 (1- y) z x)
	      (tak1 (1- z) x y)))))

(process:without-preemption (time (tak1 18. 12. 6.)))

Results on my non-FPA G-machine 0.609 seconds (3630 Genera 8.0.1).

(b) -------------------------------------------------------
Try copying the following into kill ring, the yanking it into an editor buffer:

(defun tak2 (x y z) 
  (if (not (< y x))
      z
      (tak2 (tak2 (1- x) y z)
	    (tak2 (1- y) z x)
	    (tak2 (1- z) x y))))

Do a c-sh-C incremental compile on this tak2 form, then evaluate

(process:without-preemption (time (tak2 18. 12. 6.)))

Results here: 0.459 seconds.

Now do a c-sh-E incremental evaluation on the tak2 form, 
followed by c-sh-C (incremental compile), then repeat

(process:without-preemption (time (tak2 18. 12. 6.)))

Results here: back down to 0.6+ seconds.


Once I have done an evaluation of the definition, I cannot get the
original performance (30% faster) back whilst using the same function
name. 

In the old days of Release 6, I noticed a similar effect if you put a
large list on the symbol-plist of the function name. This does not seem
to effect Genera 7 or 8.

I am foxed - any ideas?