Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

Whoops! I Rewrote it in Rust

Strange Loop Conference via YouTube

Overview

Explore a conference talk that delves into the journey of rewriting Pelikan, Twitter's open-source caching framework, in Rust. Learn how three engineers progressively integrated Rust into a C codebase, starting with replacing the server's networking and event loop. Discover the challenges and benefits of this transition, including performance comparisons, implementation of new features like TLS support, and the creation of a Rust-based storage library. Gain insights into the process of performance testing, addressing throughput and latency issues, and leveraging Rust tooling for microbenchmarking. Understand the implementation of new features such as efficient TTL sorting and PMEM support. Examine the costs and benefits of rewriting, including potential missed deadlines and duplicated work, balanced against the exciting future possibilities for Pelikan with Rust. This talk provides valuable lessons for engineers considering similar rewrites and showcases the potential of Rust in high-performance, critical infrastructure projects.

Syllabus

Intro
Pelikan • open source caching framework • single codebase • multiple solutions
Use Rust to: • add Transport Layer Security (TLS) • match performance of Cimplementation
Rust Storage in Pelikan: 2018 Engineer wants to add storage to Pelikan and write the library in Rust . Used the framework with FFI to use Rust Storage • First commit of Rust to Pelikan!
Rust Server in Pelikan: 2019 Engineer wants to use Rust for server code • Tokio / async server • Reuse components for Storage / Parser/Buffers/Metrics
Performance Testing Apply synthetic workloads with ratelimit to measure latency at a specific requestrate
Performance Problems . Throughput 10-15% slower a need more instances to match throughput requirements . Latency 25-30% higher l@p999/99.9th Percentile
Prototype • Memcached protocol compatible • wrapped std::collections::HashMap as temporary storage • benchmarking looked good • next step: FFI for storage library
Whoops! All Rust • Implemented new research storage design
Rust Tooling Benefits • cargo bench & criterion o microbenchmarking of critical components
Sorting by TTL • Enables efficient eager expiration no need to expire on read • New eviction strategies o closest to expiration
PMEM Support • Intel Optane Persistent Memory IPMEMI • Metadata in DRAM
Next Steps Path to Production • feature complete • more testing • production canary • deployment
Rewriting: Costs and Benefits Costs • Extra time would have caused missed deadlines • Duplicating work that's been paid for
Cand Rust are both very fast Profiling and benchmarking helped get us match the performance of the implementation
Pelikan has an exciting future with Rust!

Taught by

Strange Loop Conference

Reviews

Start your review of Whoops! I Rewrote it in Rust

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.