The PGM-index: a fully-dynamic compressed learned index with - - PowerPoint PPT Presentation

β–Ά
the pgm index a fully dynamic compressed learned index
SMART_READER_LITE
LIVE PREVIEW

The PGM-index: a fully-dynamic compressed learned index with - - PowerPoint PPT Presentation

The PGM-index: a fully-dynamic compressed learned index with provable worst-case bounds Paolo Giorgio Ferragina Vinciguerra pgm.di.unipi.it The predecessor search problem Given sorted input keys (e.g. integers), implement


slide-1
SLIDE 1

The PGM-index: a fully-dynamic compressed learned index with provable worst-case bounds

Paolo Ferragina Giorgio Vinciguerra

slide-2
SLIDE 2

pgm.di.unipi.it

The predecessor search problem

  • Given π‘œ sorted input keys (e.g. integers), implement

π‘žπ‘ π‘“π‘’π‘“π‘‘π‘“π‘‘π‘‘π‘π‘  𝑦 = β€œlargest key ≀ 𝑦”

  • Range queries and joins in DBs, conjunctive queries in search

engines, IP routing…

  • Lookups alone are much easier; just use Cuckoo hashing for

lookups at most 2 memory accesses (without sorting data!)

2

π‘žπ‘ π‘“π‘’π‘“π‘‘π‘“π‘‘π‘‘π‘π‘  36 = 36 π‘žπ‘ π‘“π‘’π‘“π‘‘π‘“π‘‘π‘‘π‘π‘  50 = 48

2 11 13 15 18 23 24 29 31 34 36 44 47 48 55 59 60 71 73 74 76 88 95

1 π‘œ

slide-3
SLIDE 3

pgm.di.unipi.it

Indexes

3

2 11 13 15 18 23 24 29 31 34 36 44 47 48 55 59 60 71 73 74 76 88 95

1 π‘œ π‘žπ‘π‘‘π‘—π‘’π‘—π‘π‘œ = 11 𝑙𝑓𝑧 = 36

B-tree

(values associated to keys are not shown)

slide-4
SLIDE 4

pgm.di.unipi.it

Input data as pairs (𝑙𝑓𝑧, π‘žπ‘π‘‘π‘—π‘’π‘—π‘π‘œ)

4 positions keys

2 11 13 15 18 23 24 29 31 34 36 44 47 48 55 59 60 71 73 74 76 88 95

1 π‘œ

Ao et al. [VLDB 2011]

slide-5
SLIDE 5

pgm.di.unipi.it

Input data as pairs (𝑙𝑓𝑧, π‘žπ‘π‘‘π‘—π‘’π‘—π‘π‘œ)

5 positions keys

2 11 13 15 18 23 24 29 31 34 36 44 47 48 55 59 60 71 73 74 76 88 95

1 π‘œ 2 3 4

2 11 13 15 1 2 3 4

Ao et al. [VLDB 2011]

slide-6
SLIDE 6

pgm.di.unipi.it

Learned indexes

6

π‘žπ‘π‘‘π‘—π‘’π‘—π‘π‘œ 𝑙𝑓𝑧 Black-box trained on a dataset of pairs (key, pos) 𝒠 = { 2,1 , 11,2 , … , (95, π‘œ)} Binary search in [π‘žπ‘π‘‘π‘—π‘’π‘—π‘π‘œ βˆ’ 𝑓𝑠𝑠𝑝𝑠, π‘žπ‘π‘‘π‘—π‘’π‘—π‘π‘œ + 𝑓𝑠𝑠𝑝𝑠] (approximate)

positions keys

2 11 13 15 18 23 24 29 31 34 36 44 47 48 55 59 60 71 73 74 76 88 95

1 π‘œ

Ao et al. [VLDB 2011], Kraska et al. [SIGMOD 2018]

slide-7
SLIDE 7

pgm.di.unipi.it

The problem with learned indexes

Fast query time and excellent space usage in practice, but no worst-case guarantees

7

Very slow to train

Vulnerable to adversarial inputs and queries

Must be tuned for each new dataset

Too much I/O when data is on disk

Unscalable to big data

Unpredictable latency

Blind to the query distribution

slide-8
SLIDE 8

pgm.di.unipi.it

Introducing the PGM-index

Fast query time and excellent space usage in practice, and guaranteed worst-case bounds

8

Predictable latency

Resistant to adversarial inputs and queries

Scalable to big data

Very fast to build

Constant I/O when data is on disk

No additional tuning needed

Query distribution aware

slide-9
SLIDE 9

pgm.di.unipi.it

Ingredients of the PGM-index

Fixed model β€œerror” Ξ΅

Control the size of the search range (like the page size in a B-tree)

  • Opt. piecewise linear model

Fast to construct, best space usage for linear learned indexes

Recursive design

Adapt to the memory hierarchy and enable query-time guarantees

9

slide-10
SLIDE 10

pgm.di.unipi.it

PGM-index construction

Step 1. Compute the

  • ptimal piecewise linear

𝜁-approximation in Ο(π‘œ) time

10

2 11 12 15 18 23 24 29 31 34 36 44 47 48 55 59 60 71 73 74 76 88 95 99 102 115 122 123 128 140 145 146

1 π‘œ

slide-11
SLIDE 11

pgm.di.unipi.it

2 11 12 15 18 23 24 29 31 34 36 44 47 48 55 59 60 71 73 74 76 88 95 99 102 115 122 123 128 140 145 146

PGM-index construction

Step 1. Compute the

  • ptimal piecewise linear

𝜁-approximation in Ο(π‘œ) time

11

Step 2. Store the segments as triples

𝑑! = 𝑙𝑓𝑧, π‘‘π‘šπ‘π‘žπ‘“, π‘—π‘œπ‘’π‘“π‘ π‘‘π‘“π‘žπ‘’ 1 π‘œ

slide-12
SLIDE 12

pgm.di.unipi.it

Partial memory layout of the PGM-index

Segments

(2, sl, ic) (23, sl, ic) (31, sl, ic) (48, sl, ic) (71, sl, ic) (88, sl, ic) (122, sl, ic) (145, sl, ic)

12

2 11 12 15 18 23 24 29 31 34 36 44 47 48 55 59 60 71 73 74 76 88 95 99 102 115 122 123 128 140 145 146

1 π‘œ Each segment indexes a variable and potentially large sequence of keys while guaranteeing a search range size of 2𝜁 + 1 Binary search in [π‘žπ‘π‘‘ βˆ’ 𝜁, π‘žπ‘π‘‘ + 𝜁]

slide-13
SLIDE 13

pgm.di.unipi.it

2 11 12 15 18 23 24 29 31 34 36 44 47 48 55 59 60 71 73 74 76 88 95 99 102 115 122 123 128 140 145 146

PGM-index construction

Step 1. Compute the

  • ptimal piecewise linear

𝜁-approximation in Ο(π‘œ) time

13

Step 2. Store the segments as triples

𝑑! = 𝑙𝑓𝑧, π‘‘π‘šπ‘π‘žπ‘“, π‘—π‘œπ‘’π‘“π‘ π‘‘π‘“π‘žπ‘’

Step 3. Keep only 𝑑!. 𝑙𝑓𝑧

1 π‘œ

slide-14
SLIDE 14

pgm.di.unipi.it

PGM-index construction

Step 1. Compute the

  • ptimal piecewise linear

𝜁-approximation in Ο(π‘œ) time

14

Step 2. Store the segments as triples

𝑑! = 𝑙𝑓𝑧, π‘‘π‘šπ‘π‘žπ‘“, π‘—π‘œπ‘’π‘“π‘ π‘‘π‘“π‘žπ‘’

Step 3. Keep only 𝑑!. 𝑙𝑓𝑧

2 23 31 48 71 88 122 145

slide-15
SLIDE 15

pgm.di.unipi.it

PGM-index construction

Step 1. Compute the

  • ptimal piecewise linear

𝜁-approximation in Ο(π‘œ) time

15

Step 2. Store the segments as triples

𝑑! = 𝑙𝑓𝑧, π‘‘π‘šπ‘π‘žπ‘“, π‘—π‘œπ‘’π‘“π‘ π‘‘π‘“π‘žπ‘’

Step 3. Keep only 𝑑!. 𝑙𝑓𝑧 Step 4. Repeat recursively

2 23 31 48 71 88 122 145

slide-16
SLIDE 16

pgm.di.unipi.it

Memory layout of the PGM-index

(2, sl, ic) (31, sl, ic) (88, sl, ic) (145, sl, ic) (2, sl, ic)

16

(2, sl, ic) (23, sl, ic) (31, sl, ic) (48, sl, ic) (71, sl, ic) (88, sl, ic) (122, sl, ic) (145, sl, ic)

2 11 12 15 18 23 24 29 31 34 36 44 47 48 55 59 60 71 73 74 76 88 95 99 102 115 122 123 128 140 145 146

1 π‘œ It can also be constructed in a single pass Very fast construction, a couple

  • f seconds for 1 billion keys
slide-17
SLIDE 17

pgm.di.unipi.it (2, sl, ic) (23, sl, ic) (31, sl, ic) (48, sl, ic) (71, sl, ic) (88, sl, ic) (122, sl, ic) (145, sl, ic) (2, sl, ic) (31, sl, ic) (88, sl, ic) (145, sl, ic) (2, sl, ic)

Predecessor search with 𝜁 = 1

π‘žπ‘ π‘“π‘’π‘“π‘‘π‘“π‘‘π‘‘π‘π‘  57 ?

17

2 11 12 15 18 23 24 29 31 34 36 44 47 48 55 59 60 71 73 74 76 88 95 99 102 115 122 123 128 140 145 146

1 π‘œ

𝐢 = disk page-size Set 𝜁 = Θ 𝐢 for queries in 𝑃(log! π‘œ) I/Os 𝑃(π‘œ/𝜁) space

The PGM-index is never worse in time and space than a B-tree

2𝜁 + 1 2𝜁 + 1 2𝜁 + 1

slide-18
SLIDE 18

Experiments

slide-19
SLIDE 19

pgm.di.unipi.it

Experiments

Intel Xeon Gold 5118 CPU @ 2.30GHz, data held in main memory

Fastest CSS-tree 128-byte pages β‰ˆ350 MB Matched by PGM with 2Ξ΅ set to 256 β‰ˆ4 4 MB (βˆ’83Γ—)

19

Page size 2Ξ΅ Avg search range

slide-20
SLIDE 20

pgm.di.unipi.it

Experiments on updates

20 Intel Xeon Gold 5118 CPU @ 2.30GHz, data held in main memory

slide-21
SLIDE 21

pgm.di.unipi.it

Experiments on updates

21

3891Γ— 2051Γ— 1140Γ— 611Γ—

B+-tree page size Index size 128-byte 5.65 GB 256-byte 2.98 GB 512-byte 1.66 GB 1024-byte 0.89 GB Dynamic PGM-index: 1.45 MB

Intel Xeon Gold 5118 CPU @ 2.30GHz, data held in main memory

slide-22
SLIDE 22

pgm.di.unipi.it

Why the PGM is so effective?

A B-tree node

(𝑙, π‘‘π‘š, 𝑗𝑑) 𝑙! 𝑙" … 𝑙#

In one I/O and 𝑃 log" 𝐢 steps the search range is reduced by 1/𝐢

…

w.h.p. 1/𝐢F

Page size 𝐢 2𝜁 = 𝐢

A PGM-index node

Here the search range is reduced by at least 1/𝐢

Ferragina et al. [ICML 2020]

22

slide-23
SLIDE 23

pgm.di.unipi.it

New experiments with tuned Linear RMI

  • 8-byte keys, 8-byte payload
  • Tuned Linear RMI and PGM have the same size
  • 10M predecessor searches, uniform query workload

New tuned Linear RMI implementation and datasets from Marcus et al., 2020 [arXiv:2006.12804]

PGM improved the empirical performance of a tuned Linear RMI Each PGM took about 2 seconds to construct RMI took 30Γ— more!

23

They tested positive lookups. Here we test predecessor queries

slide-24
SLIDE 24

pgm.di.unipi.it

New experiments with tuned Hybrid RMI

24

  • 8-byte keys, 8-byte payload
  • RMI with non-linear models, tuned via grid search
  • 10M predecessor searches, uniform query workload

New tuned Hybrid RMI implementation and datasets from Marcus et al., 2020 [arXiv:2006.12804]

Each PGM took about 2 seconds to construct Hybrid RMI took 40Γ— (90Γ— with tuning) more! Avg search range 28 Max search range 28

Avg 215 Max 229

slide-25
SLIDE 25

pgm.di.unipi.it

New experiments

25

  • 8-byte keys, 8-byte payload
  • RMI with non-linear models, tuned via grid search
  • 10M predecessor searches

New tuned Hybrid RMI implementation and datasets from Marcus et al., 2020 [arXiv:2006.12804]

Adversarial query workload

About adversarial data inputs, see Kornaropoulos et al., 2020 [arXiv:2008.00297]

slide-26
SLIDE 26

pgm.di.unipi.it

More results in the paper

26

Index compression

Reduce the space of the index by a further 52% via the compression of slopes and intercepts

Query-distribution aware

Minimise average query time wrt a given query workload

Multicriteria tuner

Minimise query time under a given space constraint and vice versa in a few dozens of seconds

slide-27
SLIDE 27