Top Banner
Say Goodbye to Off-heap Caches! On-heap Caches Using Memory-Mapped I/O Iacovos G. Kolokasis 1 , Anastasios Papagiannis 1 , Foivos Zakkak 2 , Polyvios Pratikakis 1 , and Angelos Bilas 1 1 University of Crete & Foundation of Research and Technology Hellas (FORTH), Greece 2 University of Manchester (Currently at Red Hat, Inc.)
19

Say Goodbye to Off-heap Caches! On-heap Caches Using ...Spark: Caching Impacts Performance 4 •Jobs cache intermediate data in memory •Subsequent jobs reuse cached data •Caching

Jul 19, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Say Goodbye to Off-heap Caches! On-heap Caches Using ...Spark: Caching Impacts Performance 4 •Jobs cache intermediate data in memory •Subsequent jobs reuse cached data •Caching

Say Goodbye to Off-heap Caches! On-heap Caches Using Memory-Mapped I/O

Iacovos G. Kolokasis1, Anastasios Papagiannis1, Foivos Zakkak2, Polyvios Pratikakis1, and Angelos Bilas1

1University of Crete & Foundation of Research and Technology Hellas (FORTH), Greece

2University of Manchester (Currently at Red Hat, Inc.)

Page 2: Say Goodbye to Off-heap Caches! On-heap Caches Using ...Spark: Caching Impacts Performance 4 •Jobs cache intermediate data in memory •Subsequent jobs reuse cached data •Caching

Outline

• Motivation

• TeraCache design for multiple heaps with different properties• How we reduce GC time?

• How we grow TeraCache over a device?

• Evaluation

• Conclusions

2

Page 3: Say Goodbye to Off-heap Caches! On-heap Caches Using ...Spark: Caching Impacts Performance 4 •Jobs cache intermediate data in memory •Subsequent jobs reuse cached data •Caching

Increasing Memory Demands!

• Big data systems cache large intermediate results in-memory• Speed-up iterative workloads

• Analytics datasets grow at a high rate

3

[Source: www.seagate.com | Seagate]

• Today ~50ZB

• By 2025 ~175ZB

50ΖΒ

175ΖΒ

3x

• Big data systems request TBs of memory per server

Page 4: Say Goodbye to Off-heap Caches! On-heap Caches Using ...Spark: Caching Impacts Performance 4 •Jobs cache intermediate data in memory •Subsequent jobs reuse cached data •Caching

Spark: Caching Impacts Performance

4

• Jobs cache intermediate data in memory

• Subsequent jobs reuse cached data

• Caching reduces execution time by orders of magnitude

• Naively, caching data needs large heaps which implies a lot of DRAM

90%

Page 5: Say Goodbye to Off-heap Caches! On-heap Caches Using ...Spark: Caching Impacts Performance 4 •Jobs cache intermediate data in memory •Subsequent jobs reuse cached data •Caching

Caching Beyond Physical DRAM

5

• DRAM capacity scaling reaches its limit [Mutlu-IMW 2013]

• DRAM scales to GB / DIMM

• DRAM capacity is limited by DIMM slots / servers

• NVMe SSDs scale to TBs / PCIe slot at lower cost

• Already Today: Spark uses off-heap store on fast devices

Page 6: Say Goodbye to Off-heap Caches! On-heap Caches Using ...Spark: Caching Impacts Performance 4 •Jobs cache intermediate data in memory •Subsequent jobs reuse cached data •Caching

Between a Rock and a Hard Place!GC vs Serialization Overhead

6

Execution Memory Storage Memory(on-heap cache)

Pros Cons

On-heapCache

No Serialization High GC

Off-heapCache

Low GC High Serialization

Merge the benefits from both worlds!

ExecutorMemory

ExecutorMemory

Execution Memory Storage Memory

(on-heap cache) (off-heap cache)

Disk

serialize/deserialize

Page 7: Say Goodbye to Off-heap Caches! On-heap Caches Using ...Spark: Caching Impacts Performance 4 •Jobs cache intermediate data in memory •Subsequent jobs reuse cached data •Caching

Outline

• Motivation

• TeraCache design for multiple heaps with different properties

• How we reduce GC time?

• How we grow TeraCache over a device?

• Evaluation

• Conclusions

7

Page 8: Say Goodbye to Off-heap Caches! On-heap Caches Using ...Spark: Caching Impacts Performance 4 •Jobs cache intermediate data in memory •Subsequent jobs reuse cached data •Caching

Different Heaps for Different Object Types

• Analytics computations generate mainly two types of objects• Short-lived, (runtime managed)• Long-lived, similar life-time, (application managed)

• JVM-heap on DRAM which is garbage collected• Locate short-lived objects• For computation usage (task memory usage)

• TeraCache-heap which is never garbage collected• Contains group of similar life-span objects (e.g., cached data)• Grow over a storage device (no serialization)

8

Page 9: Say Goodbye to Off-heap Caches! On-heap Caches Using ...Spark: Caching Impacts Performance 4 •Jobs cache intermediate data in memory •Subsequent jobs reuse cached data •Caching

Split Executor Memory In Two Heaps

9

Execution Memory

StorageMemory

JVM-heap (GC) TeraCache (non-GC)

region0 regionN. . .

Executor Memory• JVM-heap (GC)

• TeraCache (non-GC)

Organize TeraCache in regions• Bulk free: Similar life-time objects into the same region

• Dynamic size

Tera-heapJVM-heap

We make the JVM aware of cached data• Spark notifies JVM• Finds the transitive closure of the object• Move and migrate object into a region

Page 10: Say Goodbye to Off-heap Caches! On-heap Caches Using ...Spark: Caching Impacts Performance 4 •Jobs cache intermediate data in memory •Subsequent jobs reuse cached data •Caching

We Preserve JAVA Memory Safety

10

TeraCache-heap (no GC)Old GenNew Gen Region Region Region

JVM-heap (GC)

Avoid pointer corruption between objects in two heaps

No backward pointers: TeraCache → JVM-heap• Stop GC to reclaim objects used by TeraCache objects• Move transitive closure of the object

Page 11: Say Goodbye to Off-heap Caches! On-heap Caches Using ...Spark: Caching Impacts Performance 4 •Jobs cache intermediate data in memory •Subsequent jobs reuse cached data •Caching

We Preserve JAVA Memory Safety

11

TeraCache-heap (no GC)Old GenNew Gen Region Region Region

JVM-heap (GC)

Avoid pointer corruption between objects in two heaps

No backward pointers: TeraCache → JVM-heap• Stop GC to reclaim objects used by TeraCache objects• Move transitive closure of the object

Allow forward pointers: JVM-heap → TeraCache• But stop GC to traverse TeraCache

Allow internal pointers: TeraCache↔TeraCache

Page 12: Say Goodbye to Off-heap Caches! On-heap Caches Using ...Spark: Caching Impacts Performance 4 •Jobs cache intermediate data in memory •Subsequent jobs reuse cached data •Caching

Outline

• Motivation

• TeraCache design for multiple heaps with different properties

• How we reduce GC time?

• How we grow TeraCache over a device?

• Evaluation

• Conclusions

12

Page 13: Say Goodbye to Off-heap Caches! On-heap Caches Using ...Spark: Caching Impacts Performance 4 •Jobs cache intermediate data in memory •Subsequent jobs reuse cached data •Caching

Dividing DRAM Between Heaps

13

ExecutorMemory

JVM

DRAM

Execution Memory

DR1 DR2

Storage Memory

JVM-Ηeap TeraCache Heap

NVMe SSD

mmap()How to deal with DRAM resources?

• Iterative Jobs → reuse cache data → need large DR2 size• Shuffle Jobs → short-lived data → need large DR1 size

Page 14: Say Goodbye to Off-heap Caches! On-heap Caches Using ...Spark: Caching Impacts Performance 4 •Jobs cache intermediate data in memory •Subsequent jobs reuse cached data •Caching

Deal With DRAM Resources For Multi-Heaps

14

• KM-jobs produce more short-lived data• More minor GCs/s →more space for DR1

3x 2x

• We propose dynamic resizing of DR1, DR2• Based on page fault rate in MMIO

• Based on Minor GCs

• LR-jobs reuse large size of cached data• More page faults/s→ more space for DR2

Page 15: Say Goodbye to Off-heap Caches! On-heap Caches Using ...Spark: Caching Impacts Performance 4 •Jobs cache intermediate data in memory •Subsequent jobs reuse cached data •Caching

Outline

• Motivation

• TeraCache design for multiple heaps with different properties

• How we reduce GC time?

• How we grow TeraCache over a device?

• Evaluation

• Conclusions

15

Page 16: Say Goodbye to Off-heap Caches! On-heap Caches Using ...Spark: Caching Impacts Performance 4 •Jobs cache intermediate data in memory •Subsequent jobs reuse cached data •Caching

Prototype Implementation

• We implement an early prototype of TeraCache based on ParallelGC• Place New generation on DRAM

• Place Old generation on the fast storage device

• Explicitly disable GC on Old generation

• Evaluate• GC overhead

• Serialization overhead

• Not support for reclamation of cached RDDs and dynamic resizing

16

Page 17: Say Goodbye to Off-heap Caches! On-heap Caches Using ...Spark: Caching Impacts Performance 4 •Jobs cache intermediate data in memory •Subsequent jobs reuse cached data •Caching

Preliminary Evaluation

17

• TC improves performance up to 37% LR (on average 25%)

• TC improves performance up to 2x compared to Linux swap (LR)

• TC improves GC up to 50% LGR (on average 46%)

2x

37%

50%

Page 18: Say Goodbye to Off-heap Caches! On-heap Caches Using ...Spark: Caching Impacts Performance 4 •Jobs cache intermediate data in memory •Subsequent jobs reuse cached data •Caching

Conclusions

• TeraCache: A JVM/Spark co-design• Able to support very large heaps

• Reduces GC time using two heaps

• Eliminates serialization-deserialization

• Dynamic sharing of DRAM resources across heaps

• Improves Spark ML workloads performance by 25% on average

• Applicable to other analytics runtimes

18

Page 19: Say Goodbye to Off-heap Caches! On-heap Caches Using ...Spark: Caching Impacts Performance 4 •Jobs cache intermediate data in memory •Subsequent jobs reuse cached data •Caching

Contact

Iacovos G. Kolokasis

[email protected]

www.csd.uoc.gr/~kolokasis

Institute of Computer Science (ICS)

Foundation of Research and Technology (FORTH) - Hellas• • •

Department of Computer Science, University of Crete

19