Implementing Hazard Pointers in Rust
source link: https://www.youtube.com/watch?v=fvcbyCYdR10
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Implementing Hazard Pointers in Rust
4,705 views • Jun 26, 2021 • This time, we take a stab at implementing Hazard Pointers (https://erdani.org/publications/cuj-2...) in Rust. We follow along with the C++ implementation in Facebook's Folly library (https://github.com/facebook/folly/blo...), as well as the C++ standardization proposal (http://www.open-std.org/jtc1/sc22/wg2...).
0:00:00 Introduction 0:00:37 Rust for Rustaceans 0:01:00 Concurrent Memory Reclamation 0:10:32 Hazard Pointers 0:35:27 Folly's Hazard Pointer Interface 0:54:08 Delayed Reclamation 0:58:18 More Folly Interface 1:11:56 A Wild Entity Diagram Appears 1:16:40 Memory Use 1:21:12 More Folly Interface 1:27:50 Starting the Rust Code 1:35:24 Testing Out the Rust Interface 1:42:32 HazPtrHolder::load 2:02:15 HazPtrObject::retire 2:19:43 HazPtrHolder::reset 2:22:50 Unsafe Blocks in Unsafe Fns 2:25:04 Borrow Checker Prevents Misuse 2:27:45 Bad Drop Lint 2:34:15 Dropping in HazPtrDomain::retire 2:46:00 Intermission 2:47:57 Reading Folly's HazPtrDomain::retire 2:59:02 HazPtrDomain::acquire 3:17:32 HazPtrDomain::retire 3:45:57 Specifying a Deleter 4:32:26 Tests Pass? 4:36:12 Eager Reclaiming 4:37:32 Checking Reclamation Behavior 4:52:04 Final Thoughts
You can find the code for the implementation at https://github.com/jonhoo/haphazard.
Live version with chat: https://youtu.be/4PuE6oMYxeM
19 Comments
Just started watching this and not sure if anyone asked or if it came up but was wondering, the writers have to check eventually to see if the hazard LL is empty after it made its CAS, but my question is, couldn't this be made wait-free in a way, if the writer doesn't wait, and instead the reader does the cleanup when it's done?
Can't the reader before it clears it hazard, check the original atomic, and if it no longer points to the held address, then the reader checks if it's the last user in the LL and if so then it does the reclamation, maybe this is explained later :X Just seemed like a possibility existed, i mean the hazard LL would have to hold both addresses (atomic location + actual data location)?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK