2 ms·
> On these programs, the overhead is usually somewhere around 2-3x. Nice! > It's also possible that the way I'm compiling things down to Racket is defeating o
by gus_massa 4y ago
> On these programs, the overhead is usually somewhere around 2-3x.
Nice!
> It's also possible that the way I'm compiling things down to Racket is defeating optimizations, but I haven't yet dug in.
Part of the secret of the reimplementation Racket on top of Chez Scheme is that there are many macros pretending to be functions. The optimization pass inlines some of the functions, but sometimes the heuristic is not good enough, and you must cheat using a macro. (And sometimes the "obvious" improvements are wrong, and using a macro to force the expansion of the code has a worse result.)
For example in https://github.com/Bogdanp/racket-lua/blob/master/lua-lib/private/arithmetic.rkt#L103-L111 https://github.com/Bogdanp/racket-lua/blob/master/lua-lib/pr... I'd try using a macro to inline the fast case where both numbers are exact integers, and then call a real function for the slow cases. (Is it common that someone wants to use 7.0 to do bit operations? Perhaps it's better to inline more. That's the tricky part, understanding which is the best split. I'm not sure. Probably only Matthew knows.)