4 ms·
> Rust makes it easy to communicate with C APIs without overhead Zero overhead vs. the case where you'd also have function call in C. But in some cases, espec
by sampo 12y ago
> Rust makes it easy to communicate with C APIs without overhead
Zero overhead vs. the case where you'd also have function call in C.
But in some cases, especially with numerics, if you have a C library that is designed to be inlined, you get slowdown even calling C from C, if you prevent inlining.
A random number generator, SIMD-oriented Fast Mersenne Twister [1], was such a case when I tried. Just calling with `_attribute__ ((noinline))` makes it 2x slower, even when calling from C.
[1] http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/ http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/
- CyberDildonics 12y agoFor small functions that cannot be inlined, they should work across arrays that are as big as you can make them to make the overhead trivial.
- twoodfin 12y agoI don't see any reason (though I'd love to be enlightened) why the Rust implementation couldn't someday inline C functions. I'd actually be a little surprised if the underlying LLVM implementation can't use LTO to do it out of the box.
- kibwen 12y agoAs mentioned downthread, this is exactly what Servo intends to do to interop with SpiderMonkey. I'm very excited to see that project proceed.
- simias 12y agoCan't link time optimization help with that? I assume it's language agnostic.