Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 08 · From Scratch · LSM Tree · with code: Go · about 13 min to read

Watch: What stays the same when the database changes: Discord's message store
▶ VideoPlay it as a journeyTutor comes with a plan

LSM 06-07: Compaction and Levels

The Message Store Saga
The Message Store Saga · Open board

The Discord case-study board on a message store whose trouble came from the thing this lesson builds. Part of the LSM series, Build Your Own LSM Tree.

Before you start. This series builds a small copy of a storage engine that never edits a file in place. LSM 03-04: Table Files and the Sparse Index made flushing safe and lookups cheap per file, and LSM 05: The Bloom Filter let a lookup skip files that cannot hold a key. Neither stops the number of files growing with every flush. This lesson builds the background job that merges them, then arranges the files in levels so a lookup touches about one.

Lesson 59 of 117 in From Scratch

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • 6 March 2023: a database that could not keep up with its own housekeeping
  • Stage 06: merge everything
  • Stage 07: levels
  • Stage 06: merge and compact
  • Stage 07: levels
  • The tests
  • Break it, four ways

Terms it explains: Level 0, not, Write amplification, worse.

Related paper

Review From Scratch