Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why Not Rust? #8279

Open
guevara opened this issue Jan 27, 2022 · 0 comments
Open

Why Not Rust? #8279

guevara opened this issue Jan 27, 2022 · 0 comments

Comments

@guevara
Copy link
Owner

guevara commented Jan 27, 2022

Why Not Rust?



https://ift.tt/3iPgp7A






“Using LLVM” is not a universal solution to all performance problems. While I am not aware of benchmarks comparing performance of C++ and Rust at scale, it’s not to hard to come up with a list of cases where Rust leaves some performance on the table relative to C++.

The biggest one is probably the fact that Rust’s move semantics is based on values (memcpy at the machine code level). In contrast, C++ semantics uses special references you can steal data from (pointers at the machine code level). In theory, compiler should be able to see through chain of copies; in practice it often doesn’t: #57077. A related problem is the absence of placement new — Rust sometimes need to copy bytes to/from the stack, while C++ can construct the thing in place.

Somewhat amusingly, Rust’s default ABI (which is not stable, to make it as efficient as possible) is sometimes worse than that of C: #26494.

Finally, while in theory Rust code should be more efficient due to the significantly richer aliasing information, enabling aliasing-related optimizations triggers LLVM bugs and miscompilations: #54878.

But, to reiterate, these are cherry-picked examples, sometimes the field is tilted the other way. For example, std::unique_ptr has a performance problem which Rust’s Box lacks.

A potentially bigger issue is that Rust, with its definition time checked generics, is less expressive than C++. So, some C++ template tricks for high performance are not expressible in Rust using a nice syntax.







via GitHub Pages | Websites for you and your projects, hosted directly from your GitHub repository. Just edit, push, and your changes are live.

January 27, 2022 at 09:17PM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant