1 of 24

The Bw-Tree

A B-tree for New Hardware Platforms

Presented by Liming Deng

2 of 24

Part I - Introduction

3 of 24

The New Environment

  1. Multi-core CPU
  2. Flash storage

4 of 24

The New Environment

Multi-core CPU

  1. Latch-free
  2. Cache-friendly

5 of 24

The New Environment

Flash storage ( Providing FTL)

  • Host log structuring for itself

6 of 24

Part II - Architecture

7 of 24

Architecture

  1. Focus on Bw-tree layer
  2. Compare to other in-memory index structure

8 of 24

Architecture

  1. Latch-free
    1. Install state via CAS
  2. Cache-friendly
    • Delta update

put(x, a):

v = read(x)

return v == cas(x, v, a)

9 of 24

Part II - IN-MEMORY

LATCH FREE PAGES

10 of 24

IN-MEMORY LATCH FREE PAGES

Elastic Virtual Pages

LPID

PTR

P

Memory Address

Q

Flash Offset

Node

Internal index:

Separator key

Record or

Memory pointer to other

PID

11 of 24

IN-MEMORY LATCH FREE PAGES

Updates

  1. Create a `update delta record`.
  2. Use CAS to prepend `update delta` to Page P.
  3. Use CAS to install the memory address of D to mapping table.

12 of 24

IN-MEMORY LATCH FREE PAGES

Consolidation

  • Apply delta to base page P
  • Use CAS to install new page P’ to mapping table.

How to search?

  1. Traverse the delta chain
  2. Not found? Go for the base page via a binary search.

13 of 24

IN-MEMORY LATCH FREE PAGES

Garbage Collection

  1. Using Epoch-based reclamation: https://aturon.github.io/blog/2015/08/27/epoch/#epoch-based-reclamation
  1. A global epoch counter (taking on values 0, 1, and 2);
  2. A global list of garbage for each epoch;
  3. An “active” flag for each thread;
  4. An epoch counter for each thread.

14 of 24

Part III - SMO

15 of 24

SMO =

structure modification operation

Split

  1. Child Split
  2. Parent Update

16 of 24

SMO =

structure modification operation

Split

  • Child Split
    1. Create right sibling Q with Kp

17 of 24

SMO =

structure modification operation

Split

  • Child Split
    • Create sibling Q
    • Install split delta.

Split delta = {

Kp, AddressOfQ

}

18 of 24

SMO =

structure modification operation

Split

  • Child Split
    • Create sibling Q
    • Install split delta.
  • Parent update
    • Install index entry delta

19 of 24

SMO =

structure modification operation

Split

  • Child Split
    • Create sibling Q
    • Install split delta.
  • Parent update
    • Install index entry delta

20 of 24

SMO =

structure modification operation

Merge

  • Mark for delete: remove node delta for R
  • Merging Children: merge delta for L
  • Parent Update.
    • index term delete delta

21 of 24

Last Part - Performance

22 of 24

Cache

23 of 24

Throughput

24 of 24

Thank You !