badkins
2020-12-26 21:21:42

I’ve been looking at Julia for high performance “mathy” stuff, and I just discovered that Racket absolutely crushes Julia for BigInt performance :) As a simple test, Racket CS 7.9 will sum integers 1 to 1 billion in about 2.2 seconds. Julia can only sum up to 6 million in the same time frame because it allocates a new BigInt for each add/subtract! :-o


badkins
2020-12-26 21:24:04

I’ve always appreciated Scheme/Racket’s numeric tower. Now if I could just have fast math stuff w/o resorting to Typed Racket :)


badkins
2020-12-26 22:13:14

Oops :)


badkins
2020-12-26 22:14:41

I think I miscalculated on this one :) Most of my career has been 32-bit, but I think in this case, Racket never has to use BigInt. I’ll have to construct a different example …


badkins
2020-12-26 22:42:55

Ok, Racket still comes out on top with 1.21 seconds vs. Julia’s 6.78 seconds. I just did a summation starting with an integer bigger than 2^64. Given Julia’s emphasis on performance, I suppose I can stick with the original wording of “crushes” :)


badkins
2020-12-26 22:44:46

In addition to the performance gain, it’s also nice to not have to anticipate the issue and specify a type of BigInt. Racket just handles it when it gets too big. Of course, if we could add type hints for extra performance, that would be nice, but it does seem like you need something like Julia’s multiple dispatch to get good native performance w/ dynamic typing.


jcoo092
2020-12-26 23:08:45

Huh, that definitely seems quite, er, strange, given what Julia is intended for :confused: Unless maybe with Julia they focus on floating point or something.


badkins
2020-12-26 23:25:17

I’m not exactly sure why. I think both Julia and Racket are delegating to GMP. And I expect (+ a b) returns a new boxed integer for Racket also i.e. we’re not taking advantage of the mutating GMP functions, are we?


samth
2020-12-27 00:03:14

Racket integrates GMP fairly tightly into the runtime (on BC, on CS it has a custom implementation).


jcoo092
2020-12-27 01:16:42

GitHub just pointed me to this: https://github.com/justinethier/cyclone (which I hadn’t heard of before) I presume it thought I would be interested considering all the Racket in one my repositories :smile: