Skip to content

Commit

Permalink
migrate to v2 tutorial
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Chi Z <[email protected]>
  • Loading branch information
skyzh committed Jan 19, 2024
1 parent 6f262d6 commit cf1d0b4
Show file tree
Hide file tree
Showing 72 changed files with 2,139 additions and 182 deletions.
1 change: 0 additions & 1 deletion mini-lsm-book-wip/.gitignore

This file was deleted.

6 changes: 0 additions & 6 deletions mini-lsm-book-wip/book.toml

This file was deleted.

1 change: 0 additions & 1 deletion mini-lsm-book-wip/src/00-get-started.md

This file was deleted.

41 changes: 0 additions & 41 deletions mini-lsm-book-wip/src/00-overview.md

This file was deleted.

1 change: 0 additions & 1 deletion mini-lsm-book-wip/src/00-v1.md

This file was deleted.

3 changes: 0 additions & 3 deletions mini-lsm-book-wip/src/01-block.md

This file was deleted.

3 changes: 0 additions & 3 deletions mini-lsm-book-wip/src/02-sst.md

This file was deleted.

3 changes: 0 additions & 3 deletions mini-lsm-book-wip/src/03-memtable.md

This file was deleted.

3 changes: 0 additions & 3 deletions mini-lsm-book-wip/src/04-engine.md

This file was deleted.

3 changes: 0 additions & 3 deletions mini-lsm-book-wip/src/05-compaction.md

This file was deleted.

3 changes: 0 additions & 3 deletions mini-lsm-book-wip/src/06-recovery.md

This file was deleted.

3 changes: 0 additions & 3 deletions mini-lsm-book-wip/src/07-bloom-filter.md

This file was deleted.

3 changes: 0 additions & 3 deletions mini-lsm-book-wip/src/08-key-compression.md

This file was deleted.

3 changes: 0 additions & 3 deletions mini-lsm-book-wip/src/09-whats-next.md

This file was deleted.

41 changes: 0 additions & 41 deletions mini-lsm-book-wip/src/SUMMARY.md

This file was deleted.

1 change: 0 additions & 1 deletion mini-lsm-book-wip/src/week1-01-memtable.md

This file was deleted.

1 change: 0 additions & 1 deletion mini-lsm-book-wip/src/week1-02-block.md

This file was deleted.

1 change: 0 additions & 1 deletion mini-lsm-book-wip/src/week1-03-sst.md

This file was deleted.

1 change: 0 additions & 1 deletion mini-lsm-book-wip/src/week1-04-merge-iterator.md

This file was deleted.

1 change: 0 additions & 1 deletion mini-lsm-book-wip/src/week1-05-read-path.md

This file was deleted.

1 change: 0 additions & 1 deletion mini-lsm-book-wip/src/week1-06-write-path.md

This file was deleted.

4 changes: 0 additions & 4 deletions mini-lsm-book-wip/src/week1-overview.md

This file was deleted.

1 change: 0 additions & 1 deletion mini-lsm-book-wip/src/week2-01-compaction.md

This file was deleted.

1 change: 0 additions & 1 deletion mini-lsm-book-wip/src/week2-02-simple.md

This file was deleted.

1 change: 0 additions & 1 deletion mini-lsm-book-wip/src/week2-03-tiered.md

This file was deleted.

1 change: 0 additions & 1 deletion mini-lsm-book-wip/src/week2-04-leveled.md

This file was deleted.

1 change: 0 additions & 1 deletion mini-lsm-book-wip/src/week2-05-manifest.md

This file was deleted.

1 change: 0 additions & 1 deletion mini-lsm-book-wip/src/week2-06-wal.md

This file was deleted.

6 changes: 5 additions & 1 deletion mini-lsm-book/book.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[book]
authors = ["Alex Chi"]
authors = ["Alex Chi Z"]
language = "en"
multilingual = false
src = "src"
Expand All @@ -8,3 +8,7 @@ title = "LSM in a Week"
[preprocessor.toc]
command = "mdbook-toc"
renderer = ["html"]

[output.html]
additional-css = ["custom.css"]
git-repository-url = "https://github.com/skyzh/mini-lsm"
5 changes: 5 additions & 0 deletions mini-lsm-book/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.content img {
margin-left: auto;
margin-right: auto;
display: block;
}
71 changes: 44 additions & 27 deletions mini-lsm-book/src/00-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ systems.

## Write Flow

![Write Flow](figures/lsm-tutorial/00-lsm-write-flow.svg)
![Write Flow](lsm-tutorial/00-lsm-write-flow.svg)

The write flow of LSM contains 4 steps:

Expand All @@ -80,38 +80,13 @@ The write flow of LSM contains 4 steps:

## Read Flow

![Read Flow](figures/lsm-tutorial/00-lsm-read-flow.svg)
![Read Flow](lsm-tutorial/00-lsm-read-flow.svg)

When we want to read a key,

1. We will first probe all the memtables from latest to oldest.
2. If the key is not found, we will then search the entire LSM tree containing SSTs to find the data.

## Tutorial Overview

![Tutorial Overview](figures/lsm-tutorial/00-lsm-tutorial-overview.svg)

In this tutorial, we will build the LSM tree structure in 7 days:

* Day 1: Block encoding. SSTs are composed of multiple data blocks. We will implement the block encoding.
* Day 2: SST encoding.
* Day 3: MemTable and Merge Iterators.
* Day 4: Block cache and Engine. To reduce disk I/O and maximize performance, we will use moka-rs to build a block cache
for the LSM tree. In this day we will get a functional (but not persistent) key-value engine with `get`, `put`, `scan`,
`delete` API.
* Day 5: Compaction. Now it's time to maintain a leveled structure for SSTs.
* Day 6: Recovery. We will implement WAL and manifest so that the engine can recover after restart.
* Day 7: Bloom filter and key compression. They are widely-used optimizations in LSM tree structures.

## Development Guide

We provide you starter code (see `mini-lsm-starter` crate), where we simply replace all function body with
`unimplemented!()`. You can start your project based on this starter code. We provide test cases, but they are very
simple. We recommend you to think carefully about your implementation and write test cases by yourself.

* You can use `cargo x scheck` to run all test cases and do style check in your codebase.
* You can use `cargo x copy-test dayX` to copy test cases to the starter code.

## Community

You may join skyzh's Discord server and study with the mini-lsm community.
Expand All @@ -138,3 +113,45 @@ vectorized expression framework if you are also interested in that topic.
[tweet]: https://twitter.com/andy_pavlo/status/1598137241016360961
[type-exercise]: https://github.com/skyzh/type-exercise-in-rust
[bustub]: https://github.com/cmu-db/bustub

<!--
## Structure
chapters + snacks, clear goal
implement, think, try by yourself
required tasks, check your understanding questions, bonus tasks
## Testing
exploring and understanding is more important than passing all the test cases
testing basic requirements, not the internal structure or something
## Solution
### Checkpoints
the final version, but many things can be simplified, read the docs
comments / tests / not up-to-date with the starter code
### How to use the solutions
## Feedbacks
join the Discord server, your feedback is important, thank GitHub users
## License
### Free forever?
### Video lectures + Review Service + Office Hour?
should have a separate preface (before you start) chapter? and what's new with v2?
## Target audience?
## What will you get after taking this course...
-->
28 changes: 28 additions & 0 deletions mini-lsm-book/src/00-v1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Mini-LSM v1

This is a legacy version of the Mini-LSM tutorial and we will not maintain it anymore. We are working on a new version of the tutorial. We keep the legacy version in this book so that the search engine can keep the pages in the index and users can follow the links to the new version of the tutorial.

## V1 Tutorial Overview

![Tutorial Overview](legacy-lsm-tutorial/00-lsm-tutorial-overview.svg)

In this tutorial, we will build the LSM tree structure in 7 days:

* Day 1: Block encoding. SSTs are composed of multiple data blocks. We will implement the block encoding.
* Day 2: SST encoding.
* Day 3: MemTable and Merge Iterators.
* Day 4: Block cache and Engine. To reduce disk I/O and maximize performance, we will use moka-rs to build a block cache
for the LSM tree. In this day we will get a functional (but not persistent) key-value engine with `get`, `put`, `scan`,
`delete` API.
* Day 5: Compaction. Now it's time to maintain a leveled structure for SSTs.
* Day 6: Recovery. We will implement WAL and manifest so that the engine can recover after restart.
* Day 7: Bloom filter and key compression. They are widely-used optimizations in LSM tree structures.

## Development Guide

We provide you starter code (see `mini-lsm-starter` crate), where we simply replace all function body with
`unimplemented!()`. You can start your project based on this starter code. We provide test cases, but they are very
simple. We recommend you to think carefully about your implementation and write test cases by yourself.

* You can use `cargo x scheck` to run all test cases and do style check in your codebase.
* You can use `cargo x copy-test dayX` to copy test cases to the starter code.
12 changes: 9 additions & 3 deletions mini-lsm-book/src/01-block.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Block Builder and Block Iterator

<div class="warning">

This is a legacy version of the Mini-LSM tutorial and we will not maintain it anymore. We are working on a new version of this tutorial and this chapter is now part of [Mini-LSM Week 1 Day 2: Blocks](./week1-02-block.md).

</div>

<!-- toc -->

In this part, you will need to modify:
Expand All @@ -23,9 +29,9 @@ The block contains two parts: data and offsets.

```
---------------------------------------------------------------------
| data | offsets | meta |
|-----------------------|---------------------------|---------------|
|entry|entry|entry|entry|offset|offset|offset|offset|num_of_elements|
| data | offsets | meta |
| ----- | ------- | ----- |
| entry | entry | entry | entry | offset | offset | offset | offset | num_of_elements |
---------------------------------------------------------------------
```

Expand Down
6 changes: 6 additions & 0 deletions mini-lsm-book/src/02-sst.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# SST Builder and SST Iterator

<div class="warning">

This is a legacy version of the Mini-LSM tutorial and we will not maintain it anymore. We are working on a new version of this tutorial and this chapter is now part of [Mini-LSM Week 1 Day 3: Sorted String Table (SST)](./week1-03-sst.md).

</div>

<!-- toc -->

In this part, you will need to modify:
Expand Down
6 changes: 6 additions & 0 deletions mini-lsm-book/src/03-memtable.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Mem Table and Merge Iterators

<div class="warning">

This is a legacy version of the Mini-LSM tutorial and we will not maintain it anymore. We are working on a new version of this tutorial and this chapter is now part of [Mini-LSM Week 1 Day 1: Memtable](./week1-01-memtable.md) and [Mini-LSM Week 1 Day 4: Merge Iterator](./week1-04-merge-iterator.md)

</div>

<!-- toc -->

In this part, you will need to modify:
Expand Down
5 changes: 5 additions & 0 deletions mini-lsm-book/src/04-engine.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Storage Engine and Block Cache

<div class="warning">

This is a legacy version of the Mini-LSM tutorial and we will not maintain it anymore. We are working on a new version of this tutorial and this chapter is now part of [Mini-LSM Week 1 Day 5: Read Path](./week1-05-read-path.md) and [Mini-LSM Week 1 Day 6: Write Path](./week1-06-write-path.md)

</div>

<!-- toc -->

Expand Down
15 changes: 15 additions & 0 deletions mini-lsm-book/src/05-compaction.md
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
# Leveled Compaction


<div class="warning">

This is a legacy version of the Mini-LSM tutorial and we will not maintain it anymore. We are working on a new version of this tutorial
and this chapter is now part of:

- [Mini-LSM Week 2 Day 1: Compaction Implementation](./week2-01-compaction.md)
- [Mini-LSM Week 2 Day 2: Simple Compaction Strategy](./week2-02-simple.md)
- [Mini-LSM Week 2 Day 3: Tiered Compaction Strategy](./week2-03-tiered.md)
- [Mini-LSM Week 2 Day 4: Leveled Compaction Strategy](./week2-04-leveled.md)

</div>

We did not finish this chapter as part of Mini-LSM v1.
Loading

0 comments on commit cf1d0b4

Please sign in to comment.