IBM T.J. Watson Research Center Self-Tuning Memory Management of A Database System Yixin Diao diao@us.ibm.com Sigmetrics 2008 Tutorial: Introduction to Control Theory and Its Application to Computing Systems IBM T.J. Watson Research Center DB2 Self-Tuning Memory Management DB2 UDB Server Memory pools DB2 Clients Disks Technical problems – Large systems with varying workloads and many configuration parameters – Autonomic computing: systems self-management Agents Memory pools Challenges from systems aspects – Heterogeneous memory pools – Dissimilar usage characteristics Challenges from control aspects – Adaptation and self-design – Reliability and robustness 2 SIGMETRICS 2008: Introduction to Control Theory. Abdelzaher, Diao, Hellerstein, Lu, and Zhu. © 2008 IBM Corporation IBM T.J. Watson Research Center Load Balancing for Database Memory Measured Output 1 Resource Allocation 1 Load Balancing Resource Consumer 1 • Fairness optimal ? • Common measured output ? Load Balancer Resource Allocation N Resource Consumer N Saved System Time (xi ) BenefitPerPage (yi ) Measured Output N 0.16 0.14 0.12 0.1 0.08 0.06 0.04 0.02 00 Resource savedTime OLTP simPages xi pi 1 e qiui yi 1000 2000 3000 4000 dxi pi qi e qiui dui 5000 Entry size (Page) 3 SIGMETRICS 2008: Introduction to Control Theory. Abdelzaher, Diao, Hellerstein, Lu, and Zhu. Memory Pool Size (ui ) © 2008 IBM Corporation IBM T.J. Watson Research Center Constrained Optimization and Regulatory Control Saved System Disk Time Time ( xi(x )i ) Regulatory Control n J xi Overall O I d1(k) d1(k) i 1 Mem pool 1 (x1) + - u1(k) e1(k) + + Load Balancer BenefitPerPage (y1) - eN(k) + uN(k) + Resource y1(k) + + w1(k) 1N,1 N Resource Consumer N + + yN(k) w (k) wN(k) Mem pool 2 (x2) Mem size 1 (u1) MemoryPool1 Optimal memory allocation Constrained Optimization J f u1 , u 2 , , u N N g u1 , u 2 , , u N ui U 0 i 1 hu1 , u2 , , u N ui bi 0 dN(k) f 1 ui N Mem size 2 (u2) 4 O dNI (k) f 0 j 1 u j N Karush-Kuhn-Tucker conditions L f u1 , u2 , , u N g u1 , u2 , , u N hu1 , u2 , , u N L f i 0 ui ui i 0 if ui bi ; i 0 if ui bi SIGMETRICS 2008: Introduction to Control Theory. Abdelzaher, Diao, Hellerstein, Lu, and Zhu. © 2008 IBM Corporation IBM T.J. Watson Research Center Dynamic State Feedback Controller State space model y k 1 Ayk Buk d I k Control error 1 ek 1N , N I y k d O k N Integral control error eI k 1 eI k ek Feedback control law uk KPek KI eI k 5 SIGMETRICS 2008: Introduction to Control Theory. Abdelzaher, Diao, Hellerstein, Lu, and Zhu. © 2008 IBM Corporation IBM T.J. Watson Research Center Incorporating Const of Control into Controller Design Memory Pool A Remove these pages Benefit Pool Size h11-12b h11-12b 0.12 1600 1400 Ts=12449 0.1 1200 before write dirty pages to disk Disk Benefit Entry size (MB) 0.08 1000 800 0.06 600 0.04 400 0.02 200 0 0 50 100 0 150 0 50 Interval hc11-17 after 0.06 Ts=15703 1400 0.05 1200 0.04 1000 Benefit Entry size (MB) 150 hc11-17 1600 Memory Pool B 100 Interval 800 0.03 600 0.02 400 0.01 200 0 before 0 20 40 60 80 100 Interval 120 140 0 160 0 20 40 60 hc11-21 OS 140 160 180 0.05 0.045 1400 Ts=24827 0.04 1200 0.035 1000 0.03 Benefit Entry size (MB) 120 hc11-21 1600 allocate extra memory 80 100 Interval 800 0.025 0.02 600 0.015 Major cost: write dirty, move memory, victimize hot 400 0.01 200 0 0.005 0 10 20 30 40 50 60 Interval 70 80 90 100 0 0 20 40 60 Interval 80 100 120 Linear quadratic regulation (LQR) J = [eT(k) eTI(k)] Q [eT(k) eTI(k)]T + uT(k) R u(k) Define Q and R regarding to performance 6 • Cost of transient load imbalances • Cost of changing resource allocations SIGMETRICS 2008: Introduction to Control Theory. Abdelzaher, Diao, Hellerstein, Lu, and Zhu. © 2008 IBM Corporation IBM T.J. Watson Research Center Adaptive Controller Design Local linear model Decentralized integral control Response Time Benefit Interval Tuner DB2 Clients Step Tuner Model Builder Entry Size Accurate Y MIMO Control Algorithm N Memory Statistics Collector Greedy (Constraint) Fixed Step 4-Bit (Oscillation) Entry Size DB2 Memory Pool Response Time Benefit 7 SIGMETRICS 2008: Introduction to Control Theory. Abdelzaher, Diao, Hellerstein, Lu, and Zhu. © 2008 IBM Corporation IBM T.J. Watson Research Center squid.torolab.ibm.com Machine: IBM7028-6C4 CPU: 4x 1453MHz Memory: 16GB Disk: 25x 9.1G Experimental Assessment OLTP workload: multiple (20) buffer pools 0.05 2 0.04 Response time benefits 0.03 4 300 Memory sizes 1.5 200 50 100 150 200 0 0 Throughput 100 0.5 0.01 0 0 Increase TP from ~100 to ~250 1 0.02 x 10 50 100 150 0 0 200 50 100 150 200 DSS workload: various query lengths 800 0 20 40 hc09-09 Interval 60 80 6000 5000 0 20 40 Interval hc12-10 60 80 4000 > 2x improvement 3000 0.02 0.02 0.015 0.015 2000 0.01 1000 0.01 0.005 0 20 40 Interval 60 80 0 hc11-05 1500 Reduce 63% 1000 500 0 Some indexes dropped 0 20 40 60 80 100 Interval 120 140 160 avg = 2285 180 avg= 959 0 1 2 3 4 5 6 7 8 910111213141516171819202122232425262728293031323334 Order of execution 0.005 0 avg= 6206 7000 0.025 Benefit Benefit Execution time for Query 21 (10 stream avg) 200 0 0.025 8 400 DSS workload: index drop Entry size (MB) 200 STMM tuning Ts = 10680s 600 Time in seconds 400 Entry size (MB) Entry size (MB) ConfigAdvisor settings Ts = 26342s 600 0 hc12-10 hc09-09 800 0 20 40 Interval 60 80 SIGMETRICS 2008: Introduction to Control Theory. Abdelzaher, Diao, Hellerstein, Lu, and Zhu. © 2008 IBM Corporation IBM T.J. Watson Research Center Comparing Control and Optimization Techniques Control-based approach Local linear model Optimization-based approach Gradient method Decentralized integral control Projected gradient (quasi-Newton) Constraint enforcement (projection method) Step length (modified Armijo rule) Strictly applies constrained optimization Less dependence on the model Similarity in a simplified scenario 9 Differences in design considerations “Pure” average vs. convex sum Pole location vs. Armijo rule Steady-state gain vs. Hessian matrix SIGMETRICS 2008: Introduction to Control Theory. Abdelzaher, Diao, Hellerstein, Lu, and Zhu. © 2008 IBM Corporation IBM T.J. Watson Research Center Simulation Study: Comparison with Optimization Approach Control-based approach 4 2 Optimization-based approach PI x 10 u 1.5 Memory size WL change 1 0.5 0 0 20 40 60 80 100 120 140 160 180 200 350 Without noise (single run) 300 J Total saved time 250 200 150 0 20 40 60 80 100 k 120 140 160 180 200 Control intervals 4 2 PI x 10 u 1.5 1 0.5 0 0 20 40 60 80 100 120 140 160 180 200 0 20 40 60 80 100 k 120 140 160 180 200 350 J 300 Effect of noise (multiple runs) 250 200 150 More robust and better uncertainty management 10 Faster convergence, but more sensitive to noise SIGMETRICS 2008: Introduction to Control Theory. Abdelzaher, Diao, Hellerstein, Lu, and Zhu. © 2008 IBM Corporation IBM T.J. Watson Research Center Summary DB2 self-tuning memory management – Interconnection, heterogeneity, adaptation and robustness, cost of control Constrained optimization with a linear feedback controller Experimental assessment for OLTP and DSS workloads 11 SIGMETRICS 2008: Introduction to Control Theory. Abdelzaher, Diao, Hellerstein, Lu, and Zhu. © 2008 IBM Corporation