Re: Big speed diff. 32/64-bit when doing /

2014-09-30 Thread Alexander Burger
Hi Jon,

> I just noticed a surprisingly big difference in execution speed
> between 32- and 64-bit PicoLisp when doing divisions.

In general, arithmetics is much faster in pil64 than in pil32.

One reason is the more efficient implementation in assembly, where you
have direct access to the CPU flags like "sign" and "carry".

But more important is that pil32 must represent all numbers internally
as bignums (i.e. in cell structures), due to the restricted word length
and tag bits.

Pil64, on the other hand, represents short numbers (up to 60 bits plus
sign) directly in the tagged pointer. This has the advantage that
results of arithmetic operations won't cause cell allocation in the
heap, avoiding increased garbage collections.


> The first line sets P to (6402373705728000 18 17 16 15 14 13 12 11 10 9 8 7 6 
> 5 4 3 2).

The first number is still in the range of a short num. So the whole
computation takes place as short numbers in pil64.

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Big speed diff. 32/64-bit when doing /

2014-09-30 Thread Jon Kleiser
Hi,

I just noticed a surprisingly big difference in execution speed between 32- and 
64-bit PicoLisp when doing divisions. Here is my code:

(setq R (reverse (range 2 18)) P (cons (apply * R) R))
(bench (do 120 (apply / P)))

The first line sets P to (6402373705728000 18 17 16 15 14 13 12 11 10 9 8 7 6 5 
4 3 2).

On my Mac, 32-bit PicoLisp takes some 6.760 sec to do the divisions, while 
64-bit (I’m using my Docker image) takes only 0.308 sec.

32-bit PicoLisp is actually slower at this task than my JavaScript based 
EmuLisp. In Chrome it takes roughly 5.350 sec, but when you think of the 
difference between JavaScript arithmetic and PicoLisp arithmetic, it’s not that 
strange.

/Jon--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe