larcenists / larceny

Larceny Scheme implementation
Other
202 stars 32 forks source link

Slow bitwise operations on bignums #798

Open jkoser opened 7 years ago

jkoser commented 7 years ago

(This is related to #414, but only incidentally.)

As noted in the code, bitwise-{and|ior|xor} and functions that use them are really slow. Specifically, the pattern of splitting into high and low parts and recombining makes these operations take time quadratic in the length of their input.

I've written a benchmark that stresses bitwise ops. Currently Racket 6.8 outperforms Larceny on it by a factor of 10 (though, of course, that varies when the problem size changes).

Ideally, these functions would take linear time. I notice that Larceny provides integer-logand and friends (in bignums.sch). Is there any reason we can't just use those?

WillClinger commented 7 years ago

You can use anything listed in src/Lib/Common/toplevel.sch. integer-logand is listed.