Async Rust in practice: Performance, pitfalls, profiling

Click for: original source

A few weeks ago, an interesting issue appeared on our GitHub tracker. It was reported that, despite our care in designing the driver to be efficient, it proved to be unpleasantly slower than one of the competing drivers, cassandra-cpp, which is a Rust wrapper of a C++ CQL driver. By Piotr Sarna.

Brendan Gregg’s flamegraphs are indispensable for performance investigations. What’s even better is that the Rust ecosystem already has fantastic support for generating flamegraphs integrated into the build system: cargo-flamegraph.

A flamegraph generated from one of the test runs shows that our driver indeed spends an unnerving amount of total CPU time on sending and receiving packets, with a fair part of it being spent on handling syscalls.

The article then describe how author was investigating reported issue with driver performance:

  • Reproducing the problem
  • Profiling
  • Hint
  • Root cause No1
  • Root Cause No2: Pitfall in Async Rust
  • Quadratic behavior?

You will find the solution in provided GitHub repository. The world of async programming in Rust is still young, but very actively developed. Investigating and getting rid of bottlenecks and pitfalls is a very useful skill, so don’t hesitate in joining in the effort — e.g. by becoming a contributor to our brand new, native Scylla driver!. Good read!

[Read More]

Tags programming performance software-architecture cio how-to