|
I'm interested in learning to develop more complex low-level systems. I thought about starting by learning database systems. I know how they work, having experience dealing with distributed systems and databases, and I have written some patches for considerably large databases here and there. I have started by giving this course a try: https://skyzh.github.io/mini-lsm/ , but I'm feeling it is overwhelming and extremely difficult. For instance, this is the "official solution" for the 1st day exercise: fn freeze_memtable_with_memtable(&self, memtable: Arc<MemTable>) -> Result<()> {
let mut guard = self.state.write();
// Swap the current memtable with a new one.
let mut snapshot = guard.as_ref().clone();
let old_memtable = std::mem::replace(&mut snapshot.memtable, memtable);
// Add the memtable to the immutable memtables.
snapshot.imm_memtables.insert(0, old_memtable.clone());
// Update the snapshot.
*guard = Arc::new(snapshot);
drop(guard);
old_memtable.sync_wal()?;
Ok(())
}
There are many folds of complexity and things you have to be aware of to write such a good solution. Rust concurrency primitives, COW state updates, subtle ownership moves (std::mem::replace) to avoid cloning big things, lock complexity, etc.I know enough C++ to read and contribute to big and complex projects, but probably not enough to write a project on my own. Rest aside, it's my first time reading/writing Rust. All this explanation to the real question... Does it make sense to keep grueling this tutorial by approximating it like the following: 1) try to write the code on my own, 2) go to the solution to discover everything I did wrong, and 3) invest as many hours as necessary until I understand what every single line of the solution does. Or does it make more sense to start with something a bit lighter, where I'll still learn a lot without all this suffering? |