0% found this document useful (0 votes)
6 views30 pages

Rust Introduction

The document presents an introduction to using Rust to enhance the performance of Python applications, highlighting the benefits of Rust's performance, safety, and concurrency features. It discusses pipeline performance issues, the integration of Rust with Python through bindings, and provides benchmarks showing significant performance improvements when using Rust. Additionally, it outlines a Rust project for a Network Monitor and includes a Q&A section.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views30 pages

Rust Introduction

The document presents an introduction to using Rust to enhance the performance of Python applications, highlighting the benefits of Rust's performance, safety, and concurrency features. It discusses pipeline performance issues, the integration of Rust with Python through bindings, and provides benchmarks showing significant performance improvements when using Rust. Additionally, it outlines a Rust project for a Network Monitor and includes a Q&A section.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

Rust Introduction - Speeding up

Python with Rust


Albert Sendrós
12th July 2024

Classification: Public | Internal | Confidential


1. Who I am?
2. Pipeline Performance issues
3. Why Rust? Concepts
• Features
• Rust & Python
Agenda 4. Rust vs Python
• Binding (Rust integration)
• Benchmarks
5. Rust Project - Network Monitor
6. Q&A
1. Who I am?
1. Who I am?

Enthusiastic about
software with a
background in AI.
Keen on embracing
challenges since May
1994.

Albert Sendrós
PDO | Software Engineer v3.0
2. Pipeline performance
issues
2. Pipeline performance issues

MongoDB Python scripts Autoupgrade

We need a review All the scripts Huge component


on indexes since related to search that performs critical
DB operations dependencies functions on our
block main thread need to be pipeline, subject to
too much time and improved because be reviewed and
are using all the they use all the improved if possible.
I/O resources. CPU resources.
3. Rust Introduction
3. Why Rust? Introduction
Features

Performance Safety Concurrency

Comparable to C Unique concept of Can use


and C++ and ownership and async/await, mutex,
zero-cost borrow checker channels and
abstraction Futures
3. Rust introduction
Code snippets 1/2

1. Functional programming 2. Typical POJO enhanced with


(Option pattern) Python integrations
3. Rust introduction
Code snippets 2/2

1. Borrow checker 2. Ownership system


3. Rust & Python
Mixing Project Structure
• Mixing Python and Rust creates a clean
working environment
• Using Maturin results in a seamless
integration
• All Rust and Python can be handled using
Cargo, the equivalent of Gradle in Rust
4. Rust vs Python
4. Rust vs Python
Binding
• Bindings between Python & Rust are completely interoperable using PyO3
backend which compiles Rust into Python C API using native code that depends
on the architecture of the machine.

Calls Rust binaries


Invokes Python C API
4. Rust vs Python
Benchmark in seconds
4. Rust vs Python
(PCF Script Execution) => Time | CPU | RAM

Language Total time (s) Mean CPU Usage Mean RAM Usage (Mb)

Python 620 119% 582

Rust 6 105% 8
4. Benchmarks | Intel Profiler
Python
4. Benchmarks | Intel Profiler
Rust
5. Rust project
Network Monitor
5. Network Monitor
Diagram
React Dashboard

NATS

PostgreSQL

NATS Key Value Store NATS Queue

Settings for Host Host Discovery


Settings for Metrics Metrics Service DB Replica
Discovery Service
5. Network Monitor
Screenshots
5. Network Monitor
Screenshots
5. Network Monitor
Screenshots
5. Network Monitor
Demo (video)
Network Monitor URL

Classification: Public | Internal | Confidential


URL

Classification: Public | Internal | Confidential


6. Q&A
Thank you!

Classification: Public | Internal | Confidential


Classification: Public | Internal | Confidential

You might also like