[Bese-devel] UCW vs Seaside (and Scheme)

Marco Baringer mb at bese.it
Sun Sep 4 09:53:26 UTC 2005


Aleksandar Bakic <a_bakic at yahoo.com> writes:

>> > Working properly, at the cost of one or two orders of magnitude
>> > slowdown in the interpreted code. The interpreted code isn't a
>> > bottleneck, so don't worry about it.
>
> I suppose not everything is interpreted. Is it just code wrapped by
> with-call/cc, defaction and defmethod/cc, or is there more? Any suggestions on
> how to structure code to know easily which chunks of code are interpreted and
> which ones are compiled?

anything within the body of a with-call/cc is interpreted, this
includes any macro which wraps with-call/cc, such as:

defun/cc
defmethod/cc 
defaction
defentry-point

here's a half backed benchmark (note that this stresses the speed of
function calls, which in the interpreter are known to be slow):

ARNESI> (defun fib (x)
          (if (< x 2)
              1
              (+ (fib (- x 1))
                 (fib (- x 2)))))
FIB
ARNESI> (time (fib 30))
(FIB 30) took 386 milliseconds (0.386 seconds) to run.
Of that, 280 milliseconds (0.280 seconds) were spent in user mode
         0 milliseconds (0.000 seconds) were spent in system mode
         106 milliseconds (0.106 seconds) were spent executing other OS processes.

1346269
ARNESI> (defun/cc fib/cc (x)
          (if (< x 2)
              1
              (+ (fib/cc (- x 1))
                 (fib/cc (- x 2)))))
FIB/CC
ARNESI> (time (with-call/cc (fib/cc 30)))
(WITH-CALL/CC (FIB/CC 30)) took 510,689 milliseconds (510.689 seconds) to run.
Of that, 214,840 milliseconds (214.840 seconds) were spent in user mode
         37,720 milliseconds (37.720 seconds) were spent in system mode
         258,129 milliseconds (258.129 seconds) were spent executing other OS processes.
90,336 milliseconds (90.336 seconds) was spent in GC.
 2,940,249,976 bytes of memory allocated.

1346269
ARNESI> 

so it took 510 seconds vs 0.386 (~ 1300 times slower). the real cause
though is the difference in memory use: 2,940,249,976 bytes (2.73 GB)
vs. 0. that said, fib doesn't need call/cc, let's compare our fib with
this:

ARNESI> (time (with-call/cc (fib 30)))
(WITH-CALL/CC (FIB 30)) took 345 milliseconds (0.345 seconds) to run.
Of that, 260 milliseconds (0.260 seconds) were spent in user mode
         0 milliseconds (0.000 seconds) were spent in system mode
         85 milliseconds (0.085 seconds) were spent executing other OS processes.
 216 bytes of memory allocated.

1346269
ARNESI> 

so if you have a piece of code you know to be slow just move it out
into a seperate function and call that (technically the intepreter
could do this enough, but it's just not worth the effort).

-- 
-Marco
Ring the bells that still can ring.
Forget the perfect offering.
There is a crack in everything.
That's how the light gets in.
	-Leonard Cohen



More information about the bese-devel mailing list