Live data from Hacker News

What can Rust do for astrophysics?

arxiv.org

1–10 of 115 posts

Re: What can Rust do for astrophysics?

#2
Where are the links to the sources and is there a chance to compare the versions (Fortran vs Rust doing the same calculations)? I wasn't able to find them.

Where is the discussion of the library availability? The libraries for Fortran are maintained and improved during the decades?

Re: What can Rust do for astrophysics?

#3
It's crazy for me to see that C is much slower than rust. I'm almost sure that there's something wrong there.

In table 1

   Rust    Fortran     C         Go
0m13.660s 0m14.640s 2m32.910s 4m26.240s

They did have a note that C could be faster if language specific features could be used.

Is rust really that performant compared to C? Or did they neglect to even bother checking C's performance?

Re: What can Rust do for astrophysics?

#4
post #3

It's crazy for me to see that C is much slower than rust. I'm almost sure that there's something wrong there. In table 1 Rust Fortran C Go 0m13.660s 0m14.640s 2m32.910s 4m26.240s They did have a note that C could be faster if language specific features could be used. Is rust really that performant compared to C? Or did they neglect to even bother checking C's performance?

There's something wrong there. Either a corner case, or they are multithreading and vectorizing the Rust/Fortran but not the C.

Which would be the equivalent of writing a comparison between a sledgehammer and jackhammer, without turning the latter on.

Re: What can Rust do for astrophysics?

#5
post #3

It's crazy for me to see that C is much slower than rust. I'm almost sure that there's something wrong there. In table 1 Rust Fortran C Go 0m13.660s 0m14.640s 2m32.910s 4m26.240s They did have a note that C could be faster if language specific features could be used. Is rust really that performant compared to C? Or did they neglect to even bother checking C's performance?

Maybe that C code was the safe version which is inline with the rest?

Re: What can Rust do for astrophysics?

#6
post #3

It's crazy for me to see that C is much slower than rust. I'm almost sure that there's something wrong there. In table 1 Rust Fortran C Go 0m13.660s 0m14.640s 2m32.910s 4m26.240s They did have a note that C could be faster if language specific features could be used. Is rust really that performant compared to C? Or did they neglect to even bother checking C's performance?

It depends heavily on the (micro-)benchmark used.

Rust is able to avoid allocations and de-allocations in many areas where C programmers would manually use alloc and free. I must admit though, that's less relevant to scientific programming, where the heaviest work is mainly matrix matrix multiplication and the sizes of everything is known in advance.

Without reading through the paper, I expect work on the Rust/Fortran side is being vectorized and/or being kept in L1/L2 caches, whereas the C and Go compilers don't use SIMD instructions and/or are generating code that triggers cache misses.

Re: What can Rust do for astrophysics?

#7
post #2

Where are the links to the sources and is there a chance to compare the versions (Fortran vs Rust doing the same calculations)? I wasn't able to find them. Where is the discussion of the library availability? The libraries for Fortran are maintained and improved during the decades?

You can find the code for the simple N-Body implemented in different languages here (the more advanced N-Body version with tides has not been released yet):

https://github.com/marblestation/benchmark-leapfrog

And indeed, Fortran has decades of advantage in terms of libraries.

Re: What can Rust do for astrophysics?

#8
post #3

It's crazy for me to see that C is much slower than rust. I'm almost sure that there's something wrong there. In table 1 Rust Fortran C Go 0m13.660s 0m14.640s 2m32.910s 4m26.240s They did have a note that C could be faster if language specific features could be used. Is rust really that performant compared to C? Or did they neglect to even bother checking C's performance?

There's something wrong there. Either a corner case, or they are multithreading and vectorizing the Rust/Fortran but not the C. Which would be the equivalent of writing a comparison between a sledgehammer and jackhammer, without turning the latter on.

The code is available here:

https://github.com/marblestation/benchmark-leapfrog

It would be great if somebody have a fresh look at the C version, since I completely agree that it is not normal that its execution time is so far away from Fortran or Rust.

Re: What can Rust do for astrophysics?

#9
post #3

It's crazy for me to see that C is much slower than rust. I'm almost sure that there's something wrong there. In table 1 Rust Fortran C Go 0m13.660s 0m14.640s 2m32.910s 4m26.240s They did have a note that C could be faster if language specific features could be used. Is rust really that performant compared to C? Or did they neglect to even bother checking C's performance?

I don't belive in this result! C slower than Rust in 11 times!!! Are they kidding?!

http://benchmarksgame.alioth.debian.org/u64q/compare.php?lan... -- in this benchmarks C in most cases faster than Rust, but only in few they have the same performance.

Re: What can Rust do for astrophysics?

#10
post #3

It's crazy for me to see that C is much slower than rust. I'm almost sure that there's something wrong there. In table 1 Rust Fortran C Go 0m13.660s 0m14.640s 2m32.910s 4m26.240s They did have a note that C could be faster if language specific features could be used. Is rust really that performant compared to C? Or did they neglect to even bother checking C's performance?

We do not claim that Rust is so much performant than C, we just showed that Rust can be as fast as Fortran or C. And indeed, there must be something wrong with the C implementation. Pull requests with improvements are welcome:

https://github.com/marblestation/benchmark-leapfrog

Post reply on HN