On 8/13/2018 10:02 AM, 'Paulo Matos' via Racket Users wrote
On 11/08/18 19:41, Sam Tobin-Hochstadt wrote:
> There are basically two differences between the `unsafe-lsb` function
> in Racket and the C one:
>  - the Racket calling convention vs the C calling convention
>  - the instruction used to perform the LSB calculation
> > For a variety of reasons Racket's function calling convention is more
> heavyweight than C's, but if that code is inlined into some larger
> function that will go away (as it would in C). The simpler instruction
> used by the C compiler is because the C compiler recognizes that
> pattern of bitwise and, whereas the Racket JIT does the obvious `and`.
> That could of course be fixed in the JIT, although it's not clear how
> much of a win it is.
Is this something that will change with Racket-on-Chez? i.e. Racket will
then use the Chez optimizer to generate machine code?

Racket's function call convention is heavier than C's because it has to deal with the possibility that functions may be redefined at runtime, or may be overloaded ... things C does not have to deal with.  The same function may have multiple entry points depending on number of arguments, or presence of keywords, etc.  And functions that may be redefined must be called indirectly to avoid (re)patching every call site when/if the definition changes.  These things make (average) function calling in Racket slower than in C.

It is expected that the Chez compiler will do a better job at optimizing code, but it can't overcome differences in call semantics.  If you do something "schemely" with your functions, then you WILL pay the price for it.

George

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to