[gambit-list] decreasing GC

Marc Feeley feeley at iro.umontreal.ca
Wed Apr 24 14:17:39 EDT 2013


On 2013-04-24, at 12:37 PM, Zhen Shen <zhenshen10 at outlook.com> wrote:

> Havens!! Do gambit users launch rockets into space, is that the reason for having bignum arithmetic by default??!

I'm not sure if you mean that question as a criticism of Scheme, a criticism of Gambit, or an actual question (in which case the answer is yes).  It is not so much that bignum arithmetic is "on by default".  It is really a consequence of the language design which specifies that Scheme arithmetic corresponds to mathematics when operating on exact numbers.  There are plenty of languages to choose from if you prefer (expt 2 31) returning -2147483648 .

> Oh, and speaking of "exact" arithmetic, I thought that was impossible cause digital computers cant store reals?
> 
> Anyhow, thanks to your and brad's suggestions, I made significant improvements:
> memory usage is 3GB (down from 18GB!) and execution time descreased by 80%. This is mostly due to the flonums.
> 
> Now, doing (declare (flonum)) at the top level, does this stop gambit from boxing flonums across function calls?

No, flonums are kept unboxed only within a basic-block of code (a block of code uninterrupted by a jump, such as an "if" or function call).  So it pays to think carefully about where floating point calculations are placed.  Sometimes it is beneficial to recompute a result if it prevents carrying an intermediate result accross a jump.

Marc




More information about the Gambit-list mailing list