I was finally able to write a Rust program that is 165 times faster than the C equivalent. It builds an AVL tree from a stream of 10,000 integers and then does an in-order traversal. Just a fancy way to sort a list.


I believe the reason is due to the way Rust handles memory it forces you to write self-referenced data structures (like a tree) without using pointers but using handles. Thus this achieves a lot better data locality which is really important for performance.

· · Web · 0 · 0 · 0

To be honest, it doesn't "force" you as long as you don't have cycles. But doing the tree in a Rust way it's not only safer for memory management but also faster. Pretty satisfied with this result and the learning experience overall.

Show thread
Sign in to participate in the conversation

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!