"Whoops! I Rewrote it in Rust" by Brian Martin

  Рет қаралды 89,576

Strange Loop Conference

Strange Loop Conference

Күн бұрын

Three engineers, at various points, each take their own approach adding Rust to a C codebase, each being more and more ambitious. I initially just wanted to replace the server’s networking and event loop with an equally fast Rust implementation. We’d reuse many core components that were in C and just call into them from Rust. Surely it wouldn’t be that much code…
Pelikan is Twitter’s open source and modular framework for in-memory caching, allowing us to replace Memcached and Redis forks with a single codebase and achieve better performance. At Twitter, we operate hundreds of cache clusters storing hundreds of terabytes of small objects in memory. In-memory caching is critical, and demands performance, reliability, and efficiency.
In this talk, I’ll share my adventures in working on Pelikan and how rewriting it in Rust can be more than just a meme.
Brian Martin
Twitter
@brayniac
Brian is a software engineer at Twitter where he focuses on performance and optimization projects. He contributes to several Twitter open source projects including: Pelikan, Rezolus, and rpc-perf. Brian is passionate about high performance software, systems tuning, monitoring, benchmarking, and Rust. When not hacking on code, Brian volunteers in his local search and rescue unit and is training his dog to find people who get lost in the wilderness.
Recorded at Strange Loop 2021
thestrangeloop.com

Пікірлер: 28
@konga8165
@konga8165 Жыл бұрын
Watching this on 2022 just after Elon fired half of Twitter
@rutabega306
@rutabega306 Жыл бұрын
Lol he looks so happy when he says he's an engineer at Twitter 🥲
@KirinDave
@KirinDave Жыл бұрын
Watching this later in 2022 when Elon fired half of Twitter, then half the remainder quit, then 10% came back, and half the remaining people got fired.
@frikkied2638
@frikkied2638 Жыл бұрын
Would be nice to at least give the PhD student a name to recognize their effort.
@DavidLindes
@DavidLindes Жыл бұрын
According to another comment, Albert Rustein. Agree, though, that at 27:30, it would have been nice to name that person.
@PaulSebastianM
@PaulSebastianM Жыл бұрын
@@DavidLindes Rust-stein! EPIC!
@hamu_sando
@hamu_sando Жыл бұрын
​@@PaulSebastianM 'ein' translates (German->English) to 'one'.
@nekomakhea9440
@nekomakhea9440 Жыл бұрын
It's not "duplicating previous efforts" it's "paying technical debt" lol
@rocketnewton
@rocketnewton Жыл бұрын
Or to rephrase the title - own the whole stack if you care about performance.
@jebarchives
@jebarchives Жыл бұрын
I guess he no longer works at twitter
@garfieldnate
@garfieldnate Жыл бұрын
Would have been nice to dig into why the performance of your Rust implementation was better than Memached in the tail end.
@pas.
@pas. 2 жыл бұрын
That PhD student? Albert Rustein! :) Also ~2 months to get better than memcached performance? (And more importantly safer, simpler, a lot more maintainable software!) Ridiculous. Especially considering that Memcached has been painstakingly optimized by pouring years and years into it. (Since ~2003.) These rewrites pay for themselves in months.
@julkiewicz
@julkiewicz 2 жыл бұрын
I don't think that's what was said here. They had an internal Memcached alternative, written in C. They rewrote it in Rust.
@Spiritusp
@Spiritusp 2 жыл бұрын
@@julkiewicz I think he said memcached fork, so based on the real memcached
@PaulFisher
@PaulFisher 2 жыл бұрын
It’s pretty common for the tech majors to have internal forks of external software. Often (in my experience) it’s largely about adapting it to their particular tech infrastructure.
@markotikvic
@markotikvic 2 жыл бұрын
Most of the rewrite benefits come from having a better picture of what needs to be done going second time around. You fix existing bugs, optimize code that had been sitting there for years, you make incremental improvements as you're rewriting it and there you have it. You end up with a faster software. People usually don't change the existing, working codebase because that software has already been paid for and, more important, it's getting the job done. Also, no sane professional is going to start rewriting perfectly fine, working code just for the fun of it :) That's the main reason why you can see these drastic improvements over decades old codebases in just a few months of work. Don't get me wrong, having a more modern language and tooling helps with this (and I would argue is even worth sacrificing a couple of benchmark points for), but that's only part of the story. Anyway, people should be very cautions about trying to rewrite their software in a different language because they think it's somehow magically going to make their code faster if they do a 1:1 port. It would be interesting to see the benchmarks of 1:1 feature-complete implementation when they're done with it.
@ABaumstumpf
@ABaumstumpf 2 жыл бұрын
memcached is a general-purpose solution that is written in C.... it would be a sad story if creating your own purpose-build solution in a more modern language would not work out. (and even for the general-purpose solutions memcached is not bad, but also not outstanding either). We did try memcached but just the overhead of adding more C-code was not worth it, and it didn't take a month to write a custom solution in C++ that is way easier to handle and faster. Could you use out code for more general stuff? Sure, but it would then not really have the benefit anymore.
@xy4489
@xy4489 Жыл бұрын
Excellent talk.
@ujin981
@ujin981 2 жыл бұрын
All you need to know is at 14:18. The choice of programming language is a religious act.
@musicdev
@musicdev 2 жыл бұрын
While I widely agree with the sentiment, I think it tends to be a bit more pragmatic (or not depending on how you look at it) than that. I’ve found that often, the choice of programming language boils down to one thing: What language do I know best? Seriously, that’s the story behind Quora, Facebook, Twitter, university research, hell, even at my lab our choice of language is literally just what do we know? Unfortunately this means pretty much everything I write is in TypeScript…luckily we do a lot of web stuff anyway
@antonlee0
@antonlee0 2 жыл бұрын
Prob wouldn't even happened w/o storage algorithm change 22:37. They've swapped to better suited storage algorithm got same performance as with C on old algorithm.
@GeorgeTsiros
@GeorgeTsiros Жыл бұрын
1:25 does the database have no caching itself? Why would the database need "protection" from frequent requests?
@DavidLindes
@DavidLindes Жыл бұрын
It may, but it would still likely benefit, because the database is going to be designed to be able to handle arbitrary queries, whereas the caching solution will be tailored to a particular frequent query. For example, an SQL database for a social networking site might theoretically have tables for users, posts, responses, etc., and be able to query based on username, user id, post id, post content, etc. etc. etc... and might use complicated joins to answer a query. A cache could be built in front of that for just looking up, say, all the information about a post based on its id, and that would include all the joined-in data. For example.
@tissuepaper9962
@tissuepaper9962 Жыл бұрын
Separation of concerns. You already need a separate server to receive and redirect incoming requests to individual database machines, why not avoid routing the request entirely by just storing the most frequently used data right on the "greeter" server? It needs to be an infinitely scalable solution, routing a bunch of packets to get the same exact data between the same two machines over and over is obviously wasteful.
@z11i
@z11i Жыл бұрын
Database caching is in most cases useless. Any changes to a table invalidates all cache on the table.
@OMGclueless
@OMGclueless Жыл бұрын
@@z11i 1. A change to a table does not invalidate all caches on that table. Just the ones that were dependent on that data. Updating a row with id=5 does not invalidate a cache of the row with id=6. 2. Not all requests need fresh data. e.g. Your Netflix profile name needs to be updated immediately in a DB somewhere when you submit a change on your profile page, but it's OK if your TV still uses your old name for a few minutes even for new requests.
"Type-Driven API Design in Rust" by Will Crichton
40:57
Strange Loop Conference
Рет қаралды 117 М.
"Performance Matters" by Emery Berger
42:15
Strange Loop Conference
Рет қаралды 480 М.
Which one is the best? #katebrush #shorts
00:12
Kate Brush
Рет қаралды 27 МЛН
1❤️#thankyou #shorts
00:21
あみか部
Рет қаралды 88 МЛН
Which one of them is cooler?😎 @potapova_blog
00:45
Filaretiki
Рет қаралды 10 МЛН
She ruined my dominos! 😭 Cool train tool helps me #gadget
00:40
Go Gizmo!
Рет қаралды 57 МЛН
"Outperforming Imperative with Pure Functional Languages" by Richard Feldman
34:55
Strange Loop Conference
Рет қаралды 86 М.
"Concatenative programming and stack-based languages" by Douglas Creager
40:30
Strange Loop Conference
Рет қаралды 13 М.
The Truth about Rust/WebAssembly Performance
29:47
Greg Johnston
Рет қаралды 173 М.
"Game Development in Eight Bits" by Kevin Zurawel
39:41
Strange Loop Conference
Рет қаралды 537 М.
"Why Programming Languages Matter" by Andrew Black
56:39
Strange Loop Conference
Рет қаралды 26 М.
Rust Before Main - Ryan Levick - Rust Linz, July 2022
31:34
Rust for TypeScript devs : Borrow Checker
8:49
ThePrimeagen
Рет қаралды 214 М.
The Unreasonable Effectiveness of Linux Workstations
12:47
No Boilerplate
Рет қаралды 572 М.
iOS 18 vs Samsung, Xiaomi,Tecno, Android
0:54
AndroHack
Рет қаралды 80 М.
Hisense Official Flagship Store Hisense is the champion What is going on?
0:11
Special Effects Funny 44
Рет қаралды 1,3 МЛН
1$ vs 500$ ВИРТУАЛЬНАЯ РЕАЛЬНОСТЬ !
23:20
GoldenBurst
Рет қаралды 660 М.
Купил этот ваш VR.
37:21
Ремонтяш
Рет қаралды 293 М.