News for hackers. Stuff that matters.
Re:Speed of Rust vs. C by amelius on Saturday March 13, 2021 @08:57AM (#26446579)
But that may be of little solace. If you snapshot your entire heap into an mmapped file for fast I/O, then basically the entire advantage of Rust is gone.
Re:Speed of Rust vs. C by bluejekyll on Saturday March 13, 2021 @09:08AM (#26446658)
Is there literally no other code in the application?

Rust has plenty of situations where you do unsafe things but wrap that in safe APIs. If you’re returning regions of that mmapped file, for example, a lifetime can be associated to those references to ensure that those are valid for the duration of the file being mmapped in the program.

It can be used to ensure that if you need to write back to that mmapped file (inside the same program) that there are no existing references to it, because those would be invalid after an update to the file. You need to do the same in C, but there are no guardrails you can build in C to make that same assurance.

Re:Speed of Rust vs. C by ReactiveJelly on Saturday March 13, 2021 @09:30AM (#26446771)
> If you snapshot your entire heap into an mmapped file for fast I/O,

I've never heard of this trick. And my first reaction is "That would be a nightmare of memory unsafety if I did it in C++"

What's it used for? IPC?

Re:Speed of Rust vs. C by loeg on Saturday March 13, 2021 @11:13AM (#26447498)
I think emacs (used to?) do something awful like this. https://lwn.net/Articles/707615/
Re:Speed of Rust vs. C by howinteresting on Saturday March 13, 2021 @12:09PM (#26447941)
I'd call mmaping data structures into memory an advanced systems programming trick which can result in a nice performance boost but which also has some severe drawbacks (portability across big/little endian architectures and internal pointers being two examples).

I know some very skilled C++ and Rust developers who can pull it off. If you're at that skill level, Rust is not going to get in your way because you're just going to use unsafe and throw some sanitizers and fuzzers at it. I wouldn't trust myself to implement it.

Re:Speed of Rust vs. C by amelius on Saturday March 13, 2021 @09:44AM (#26446870)
You have to combine it with other techniques, e.g. journaling to make it safe, but this is not always necessary (e.g. when using large read-only data-structures)