[racket-dev] [plt] Push #28633: master branch updated

From: Neil Toronto (neil.toronto at gmail.com)
Date: Mon Apr 28 00:16:09 EDT 2014

On 04/27/2014 09:16 PM, Matthew Flatt wrote:
> At Sun, 27 Apr 2014 18:56:32 -0600, Neil Toronto wrote:
>> Strange thing, though: while `inexact->exact` is now about 10x faster,
>> my TR implementation `flonum->rational` is now about 7x slower. I've
>> verified that `flonum->fields` accounts for about 85% of the running
>> time. I see that you've changed `integer-bytes->integer`, which
>> `flonum->fields` uses. Could it have been a pessimization on certain
>> platforms?
>
> That's surprising. I don't expect the modified `integer-bytes->integer`
> to be any slower.
>
> Are you timing with the "flonum-to-racket.rkt" that you sent me? When I
> run it on various machines (Mac 32-bit x86, Mac 64-bit x86, Mac 32-bit
> PPC, Linux 64-bit x86, Windows 64-bit x86 VM), the time reported for
> your code is not slower than before, and it's consistently within 50%
> of the time reported for the new `inexact->exact`.

I was being stupid. The file I sent you, which I did the majority of my 
testing with, does 100,000 conversions in the speed test. At some point, 
I changed it to 1,000,000. When I use 100,000 again, the TR 
implementation `flonum->rational` actually takes 50% less time than it 
used to. So thanks again, and sorry about making you test more!

For anyone wondering what this stuff means: most mixed exact/inexact 
math in Racket should be up to 5x or so faster now, depending on how 
conversion-heavy it is and how large the numbers are. On my machine, 
`real->double-flonum` is 1x or 25x faster on exact rationals (1x if the 
numerator and denominator both fit in a flonum; we optimized the slow 
path), and `inexact->exact` is 4x-100x faster (depending on the 
magnitude of the flonum's exponent). Also, conversions from exact to 
inexact now always find the closest approximation, so e.g. `sqrt` is a 
little more accurate when given exact rationals.

FWIW, the C implementations aren't much faster than the Typed Racket 
prototypes. I find that totally awesome.

Neil ⊥


Posted on the dev mailing list.