Moment-Based Quantile Sketches for Efficient Aggregation Queries - - PowerPoint PPT Presentation

moment based quantile sketches for efficient aggregation
SMART_READER_LITE
LIVE PREVIEW

Moment-Based Quantile Sketches for Efficient Aggregation Queries - - PowerPoint PPT Presentation

Moment-Based Quantile Sketches for Efficient Aggregation Queries Edward Gan, Jialin Ding, Kai Sheng Tai, Vatsal Sharan, Peter Bailis Stanford University 1 Motivation: Monitoring production data streams Billions of events / day of mobile app


slide-1
SLIDE 1

Moment-Based Quantile Sketches for Efficient Aggregation Queries

Edward Gan, Jialin Ding, Kai Sheng Tai, Vatsal Sharan, Peter Bailis

1

Stanford University

slide-2
SLIDE 2

Motivation: Monitoring production data streams

Spike in response latency, need to issue queries: Billions of events / day of mobile app telemetry data

2

p99 latency time Android time iOS p99 latency

Group By Operating system Query for 99-th percentile Where Location = USA

Quantile Query Percentiles are targeted: single metric, for specific sub-populations

slide-3
SLIDE 3

Goal: Enabling fast quantile queries at scale

Large Datasets

Billions of events per day Users expect interactive response

Baseline: Scan and sort billions of rows, multi-second latencies

Data Summaries Statistics

3

Optimization

Scalable Queries

µi = 1 n X

x∈X

xi

<latexit sha1_base64="JdL0ONVIGUSTCqe1v65tOHdGSA=">ACDnicbVDLSsNAFJ3UV62vqEs3g6XgqiQi6EYounFZwT6giWEynbRDZyZhZiItIV/gxl9x40IRt67d+TdO2y09cCFwzn3cu89YcKo0o7zbZVWVtfWN8qbla3tnd09e/+greJUYtLCMYtlN0SKMCpIS1PNSDeRBPGQkU4up76nQciFY3FnZ4kxOdoIGhEMdJGCuyax9OAwkvoRLhzM0zkXsq5UE2h4VsJvD8T0N7KpTd2aAy8QtSBUaAb2l9ePcqJ0JghpXquk2g/Q1JTzEhe8VJFEoRHaEB6hgrEifKz2Ts5rBmlD6NYmhIaztTfExniSk14aDo50kO16E3F/7xeqMLP6MiSTUReL4oShnUMZxmA/tUEqzZxBCEJTW3QjxEJhdtEqyYENzFl5dJ+7TuOnX39qzauCriKIMjcAxOgAvOQPcgC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+q+EpifAbGjpKek=">ACKXicbZBNS8NAEIY3ftb6VfXoZbGI9WBJiqAXoSiIRwWrQlPLZLtpl242YXcilNC/48W/4kVBUa/+EbdtDn4NLDy87wyz8waJFAZd92Zmp6ZnZsvLBQXl5ZXVktr61cmTjXjDRbLWN8EYLgUijdQoOQ3ieYQBZJfB/2TkX9x7URsbrEQcJbEXSVCAUDtFK7VPexF26BGdEN2jfqiBZb6CQEJ2OqxMjN1hLt3WvovtUtmtuOif8HLoUzyOm+Xnv1OzNKIK2QSjGl6boKtDQKJvmw6KeGJ8D60OVNiwoiblrZ+NIh3bZKh4axtk8hHavfJzKIjBlEge2MAHvmtzcS/OaKYaHrUyoJEWu2GRmEqKMR3FRjtCc4ZyYAGYFvavlPXA5oQ23KINwft98l+4qlU9t+pd7Jfrx3kcBbJtkiFeOSA1MkZOScNwsg9eSQv5NV5cJ6cN+dj0jrl5DMb5Ec5n1+r2qZO</latexit>

+ +

Group By Operating System Query for 99-th percentile Where Location = USA

=

slide-4
SLIDE 4

Systems make use of summaries to scale

4

Raw values Summary

Summaries represent a dataset using sublinear space (e.g. histogram) Quantile estimates can be extracted from a quantile summary Commonly used to avoid sorting large datasets

99-th percentile: 401ms 95-th percentile: 197ms 50-th percentile: 48ms Quantiles

slide-5
SLIDE 5

Pre-aggregating summaries reduces latency

5

Mergeable summaries1 can be combined without loss of accuracy

1: [Agarwal et al, PODS ‘12]

Systems can pre-aggregate summaries for populations ahead of time

Day=Sat Day=Sun 99-th percentile: 105ms 95-th percentile: 87ms 50-th percentile: 40ms Day=Weekend

Improved query response time

Data associated with day of week

slide-6
SLIDE 6

Challenge: aggregations bottlenecked by merge

Many attributes means potentially more pre-aggregated subpopulations

6

Queries bottlenecked when merging pre-aggregated summaries 5 columns x 20 distinct values each = 3.2M combinations Greenwald Khanna Sketch: updatable equi-depth histogram GK Performance: 3 µs x 1 million merges = 3 seconds

App Version OS Version Location Day HW Make × × × ×

How can we optimize quantile summaries for aggregation?

slide-7
SLIDE 7

Talk Outline

  • 1. Setting: Quantile roll-ups at scale
  • 2. Challenge: merging pre-aggregated summaries
  • 3. Summarizing data using statistics (moments sketch)
  • 4. Improving sketch performance
  • 5. Results: benchmark + integrated into data systems

7

slide-8
SLIDE 8

Efficient data summaries using statistics

8

How can we optimize quantile summaries for aggregation? Use statistics to summarize sub-populations (indexing) Aggregate statistics using arithmetic (query time)

1 3 2 4 2 2 1 3 2 4 2 2 10

slide-9
SLIDE 9

Moments: statistics that capture distribution shape

9

Intuition: Averages bound the number of “large” values Moments: averages of powers of the data values. ith moment: The first moment is the mean.

µi = 1 n X

x∈X

xi

<latexit sha1_base64="BDk/+7hWptUECFJ5XHazKJjmM=">ACD3icbVDLSsNAFJ3UV62vqEs3g0VxVRIRdCMU3bisYB/QxDCZTtqhM5MwM5GWkD9w46+4caGIW7fu/BunbRbaeuDC4Zx7ufeMGFUacf5tkpLyura+X1ysbm1vaOvbvXUnEqMWnimMWyEyJFGBWkqalmpJNIgnjISDscXk/89gORisbiTo8T4nPUFzSiGkjBfax9OAwkvoRLhzM0zkUNPpTzIRtCjAnZyOLqngV1as4UcJG4BamCAo3A/vJ6MU45ERozpFTXdRLtZ0hqihnJK16qSILwEPVJ1CBOF+Nv0nh0dG6cEolqaEhlP190SGuFJjHpOjvRAzXsT8T+vm+rows+oSFJNBJ4tilIGdQwn4cAelQRrNjYEYUnNrRAPkAlGmwgrJgR3/uVF0jqtuU7NvT2r1q+KOMrgAByCE+Cc1AHN6ABmgCDR/AMXsGb9WS9WO/Wx6y1ZBUz+APrM8f+oub+w=</latexit><latexit sha1_base64="BDk/+7hWptUECFJ5XHazKJjmM=">ACD3icbVDLSsNAFJ3UV62vqEs3g0VxVRIRdCMU3bisYB/QxDCZTtqhM5MwM5GWkD9w46+4caGIW7fu/BunbRbaeuDC4Zx7ufeMGFUacf5tkpLyura+X1ysbm1vaOvbvXUnEqMWnimMWyEyJFGBWkqalmpJNIgnjISDscXk/89gORisbiTo8T4nPUFzSiGkjBf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CAo3A/vJ6MU45ERozpFTXdRLtZ0hqihnJK16qSILwEPVJ1CBOF+Nv0nh0dG6cEolqaEhlP190SGuFJjHpOjvRAzXsT8T+vm+rows+oSFJNBJ4tilIGdQwn4cAelQRrNjYEYUnNrRAPkAlGmwgrJgR3/uVF0jqtuU7NvT2r1q+KOMrgAByCE+Cc1AHN6ABmgCDR/AMXsGb9WS9WO/Wx6y1ZBUz+APrM8f+oub+w=</latexit>

! " ∑ $% = 1 limits size of the tail ! " ∑ $( = 6 further limits size of tail

Given * moments, distribution known to within +(1/*), Can estimate quantiles

slide-10
SLIDE 10

Quantile estimates from moments

Given ! moments, we solve for the unique distribution that: 1. Matches all ! moments 2. Minimizes unwarranted assumptions about the data (maximizes entropy)

10

Method-of-moments1: technique for estimating distribution parameters given moments. Used in statistics, econometrics, physics

1: [Wasserman, 2004], 2: [Jaynes, Phys. Rev. 1957]

With 14 moments, can estimate quantiles with 1% error on real data

slide-11
SLIDE 11

Moments for fast quantile queries

min max count P x P x2

Moments

k

The moments sketch: an array tracking the min, max, count, and ! sums of powers (2 ≤ ! ≤ 15)

11

Our contribution: method of moments can be used for compact, efficiently mergeable, and accurate sketches

Goals: low-memory footprint, fast to aggregate, fast to compute quantiles

slide-12
SLIDE 12

Talk Outline

  • 1. Setting: Quantile roll-ups at scale
  • 2. Challenge: merging pre-aggregated summaries
  • 3. Summarizing data using statistics (moments sketch)
  • 4. Improving sketch performance
  • 5. Results: benchmark + integrated into data systems

12

slide-13
SLIDE 13

Moments sketch has low aggregation overhead

13

! + 3 primitive floating point operations < 200 bytes in practice, k < 20

min=0 max=5.0 count=20 ∑% = 22.3 ∑%) = 323.5 ∑%+ = 1017.0 min=1 max=3.6 count=4 ∑% = 10.3 ∑%) = 18.3 ∑%+ = 81.7

min max add add add add

min=0 max=5.0 count=24 ∑% = 32.6 ∑%) = 341.8 ∑%+ = 1098.7

Merged

slide-14
SLIDE 14

Method-of-moments is now a bottleneck

Solving quantiles from moments requires iterative optimization

14

Challenge: Off the shelf solver routines too slow for interactive use Convex optimization packages (cvxpy): 300ms to solve

Increasingly precise agreement with known moments Iteration 1 Iteration 2 Iteration 3

slide-15
SLIDE 15

Improvement: Accelerating method-of-moments

15

Practical improvements to a specialized optimization routine bring solve time down to 1ms

  • Improved numeric stability using Chebyshev polynomials
  • Fast integration using polynomial approximation
  • Selection of most informative moments
  • Cascades for short-circuiting percentile estimation

See paper (VLDB 2018) for details!

slide-16
SLIDE 16

Talk Outline

  • 1. Setting: Quantile roll-ups at scale
  • 2. Challenge: merging pre-aggregated summaries
  • 3. Summarizing data using statistics (moments sketch)
  • 4. Improving sketch performance
  • 5. Results: benchmark + integrated into data systems

16

slide-17
SLIDE 17

Moments sketch enables fast roll-up queries

17

Milan: Single quantile query on cellular internet usage measurements

500 1000 1500 2000 2500 Greenwald Khanna Low-discrepancy Random Moments Sketch

Single quantile query (800k merges)

Query Time (ms)

Moments Sketch: 23ms total query time on 800k merges Comparably accurate mergeable summaries 15x slower

Random: [Wang et al, SIGMOD'13], Low-discrepancy: [Agarwal et al, TODS'13], Greenwald Khanna: [Greenwald et al, SIGMOD'01]

slide-18
SLIDE 18

15x speedup Break-even at 1000 merges

Moments sketch has fixed query overhead: method-of-moments solver

18

Performance scales with number of merges

Milan Query Time

Varying the number of merges in a single query

Poor performance for few merges

slide-19
SLIDE 19

Accurate estimates with low space overhead

19

Accuracy of sketch varies with space used (bytes): error decreases Moments sketch achieves 1% error with less space than other summaries

slide-20
SLIDE 20

Performance translates to real-world systems

20

2 4 6 8 10 12 14 Moments Sketch Streaming-Histogram

Druid Query (10M merges)

Runtime (s)

Single quantile query over 10M summaries from the Milan data Integrated moments sketch as a user defined aggregate in Druid: Better accuracy, 7x faster end-to-end queries Default streaming-histogram1 sketch performance is poor

1: [Ben-Haim et al, JMLR'10]

slide-21
SLIDE 21

Moments Sketch in MacroBase

MacroBase1 uses quantile queries to search for explanations: Find attribute values which have 97th percentile latency > 100ms Using sketches lets us ingest pre-aggregated data: less network bandwidth vs raw event logs Challenge: solve for quantiles on many attribute combinations

21

1: [Bailis et al, SIGMOD'17] App Ver 7.0: p97 = 125ms App Ver 6.5: p97 = 60ms USA, Android: p97 = 250ms …

slide-22
SLIDE 22

Performance translates to real-world systems

22

5 10 15 20 25 30 35 40 45 Moments Sketch + Cascade Moments Sketch Low-Discrepancy

MacroBase Query (13M merges)

Merge Time (s) Estimation Time (s)

Percentile(latency, 97) > 100ms Naïve moments sketch usage expensive due to repeated search queries Cascades for short circuit evaluation reduce query time by 17x

slide-23
SLIDE 23

Conclusion: Efficient sketches for quantile queries

Setting: Quantile queries bottlenecked by slow summary data structures Quantiles via Moments Sketch: Statistical moments enable compact + efficient sketches Method-of-moments + Entropy to recover distribution Results: 15x faster query times, 7x integrated with Druid

Edward Gan, edgan8.github.io Blog: dawn.cs.stanford.edu/2018/08/29/moments/ Code: github.com/stanford-futuredata/msketch

24