Live data from Hacker News

What can Rust do for astrophysics?

arxiv.org

61–70 of 115 posts

Re: What can Rust do for astrophysics?

#61

For those who are looking at doing data analysis with Rust in astrophysics, I have a crate fitsio ( https://crates.io/crates/fitsio ) which wraps cfitsio into rust, allowing the reading and writing of .fits files.

Nice. I mean I didn't wanna say but when I saw the headline my first thought was "basically nothing if you don't have a fits library"

Re: What can Rust do for astrophysics?

#62
post #30

I don't know the astrophysics domain at all but shouldn't there be more arguments for Go? * Safer than C * Almost as fast as C * Good concurrency support * High productivity due to simple abstractions and good tooling Is the downside of a GC language really relevant? Does astrophysics suffer from "stop the world interrupts" or is it just because of the performance? The Go GC is already really fast.

> * Almost as fast as C That's the key point. Judging by the (wrong) benchmark above where both C and Go seem to do some work, Go is about half as fast as C. A grad student (if paid properly) costs maybe 60k €/year. In comparison, we regularly spend more than 250k on new and faster computers, not including maintenance, the electricity bill etc. If you can make software even 50% faster by increasing development time,…

> languages are not interesting in the academic HPC crowd if they sacrifice speed for anything,

It depends. If it takes 8 weeks for the program to run using a high-level language, but 1 week for it to run using a faster language, dropping down to C to cut the running time down to 6.5 days doesn't help if it take several weeks to do it, and you are not sure that you won't have to rerun the program due to hard-to-find bugs.

Re: What can Rust do for astrophysics?

#63
post #55

Earlier quoted context omitted.

> Compile C version with better optimization flags or ask an expert to tweak it for faster performance. Part of the point they are trying to make is that you don't need to be an expert to reap performance benefits in certain languages. They explicitly state that they did not do things that C experts would know how to do. This is pretty reasonable in the context of astrophysics. The whole idea of the thing is that if…

You have a good criticism on my #1. I should drop "ask the expert" part but still maintain that when writing numerical computation software checking for compile flags is a reasonable request. Leave code as is, but still try -O3 / -Ofast. At this point it is not the language expertise, but knowing about your tools.

Agreed, mostly :-) The paper does state that they used -O3.

Re: What can Rust do for astrophysics?

#64

Earlier quoted context omitted.

> * Almost as fast as C That's the key point. Judging by the (wrong) benchmark above where both C and Go seem to do some work, Go is about half as fast as C. A grad student (if paid properly) costs maybe 60k €/year. In comparison, we regularly spend more than 250k on new and faster computers, not including maintenance, the electricity bill etc. If you can make software even 50% faster by increasing development time,…

I think you misunderstand what "safety" refers to in the context of programming. It's not about flaws in your program being attacked, it's about writing correct programs.

I think you are completely missing the point here. The HPC world is mostly concerned with the speed at which you get results, safety means almost nothing in this domain. What people typically do is to test their code against known input/output and check the relative error.

It is easier to debug and improve a fast program when you can have some result in 1 day versus same algorithm implemented in a slower language that takes one week.

Re: What can Rust do for astrophysics?

#65
post #48

Earlier quoted context omitted.

I looked at the Rust documentation's getting started page and it says: > If you’re using more than one word in your filename, use an underscore: hello_world.rs rather than helloworld.rs. Is the use of underscores a recommendation or a limitation?

Of course it's just a recommendation. Why would you think otherwise? To Rust, module name is just a bunch of characters, it doesn't recognize words anyhow.

[deleted]

Re: What can Rust do for astrophysics?

#66
post #56
post #46

Earlier quoted context omitted.

One wouldn't, generally, at least in the astrophysics domain. The kinds of guarantees Rust makes don't add anything.

Not getting incorrect results due to UB with signed arithmetic or corrupted data sets? Then again, Fortran would cover these scenarios and is better established.

Arithmetic in these contexts is done with floats. Any errors that would result in signed arithmetic issues would thrash so many other things about the problem that protections against UB would rarely be an issue. It's a legitimate possible use case, but not one to justify a choice in one language over another.

And your point about Fortran is great. I used that and C++ for my research and never once encountered an issue that Rust's guarantees would have helped with.

Re: What can Rust do for astrophysics?

#68
A little less than a year ago I worked on a bioinformatics project in rust, and I think it came out very well. My perception was that bio is a field where most practitioners rely on high speed code written by someone else that can be called from their perl or python code. I see something very empowering with rust, where people can write high performance analysis without having to shoehorn their workload into an existing toolkit or framework.

That said, while I'm really excited to see rust go more places, astrophysics seems like one of very few fields where practitioners learn a high performance language as a matter of course, and so rust may have a less empowering effect for them. I would wager that after paying the upfront cost to learn it, students and researchers may see improved iteration time from fewer bugs. But it seems like rust may have an incremental improvement to offer which is not as powerful as the transformative nature of its potential in other computationally intensive fields.

Re: What can Rust do for astrophysics?

#69
post #37

Earlier quoted context omitted.

I'd agree but > Judging by the (wrong) benchmark above where both C and Go seem to do some work, Go is about half as fast as C. I think this is what is most flawed in the paper. For (some) concurrent problems Go is about as fast as C [1]. But then again, I don't know what kind of computing requirements they have. Is there a reason why GRP computing isn't mentioned? They are really efficient and CUDA isn't that hard t…

> I think this is what is most flawed in the paper. For (some) concurrent problems Go is about as fast as C [1]. Certainly, this was really only taken as a ballpark estimate of the performance difference. Looking at your link, it seems to have been slightly overestimating the difference, though the general point still stands: C is (in most cases) faster and there is (nearly) no case in which Go beats C. > Is there a…

> if you can throw someone with gdb at the problem and get essentially the same "safety".

That's an odd tradeoff. That time of debugging could be significantly longer than just writing the software in a safe language. Seems like a bad tradeoff, and in many scenarios, bugs can lead to very bad things that you can't recover from. I've experienced all of these, having to fix them over long periods of time (not all my code, but sadly some was): data loss, concurrency (tough to debug in gdb), major memory leaks (even from std libs), corrupted data because of misused non null terminated c strings, array out of bound issues. Each one of these took weeks to track down, maybe because I'm not smart, which is a valid criticism; with Rust I've never had issues with any of those (2 years and running), and given that I'm not smart, it helps me by telling me where I got something wrong.

Be safe out there people...

Re: What can Rust do for astrophysics?

#70
post #30

I don't know the astrophysics domain at all but shouldn't there be more arguments for Go? * Safer than C * Almost as fast as C * Good concurrency support * High productivity due to simple abstractions and good tooling Is the downside of a GC language really relevant? Does astrophysics suffer from "stop the world interrupts" or is it just because of the performance? The Go GC is already really fast.

I looked at the Rust documentation's getting started page and it says: > If you’re using more than one word in your filename, use an underscore: hello_world.rs rather than helloworld.rs. Is the use of underscores a recommendation or a limitation?

It's kinda both. Since module names are identifiers, you can't use -s in them. You can still make it work, I believe, with the path attribute, but you'd need to do it on every mod declaration.
Post reply on HN