Spark memory management

MemoryManager is the place where I started looking at spark’s memory management architecture. This class handles the split of the overall memory into four dynamic portions — onHeapStorage, onHeapExecution, offHeapStorage, offHeapExecution. Execution memory is transient (shuffle, join, aggregates, sorting) and storage memory is longer lived (cache, broadcast variables). MemoryManager depends on MemoryStore to actually allocate and free memory. There are two kinds of MemoryManagers — StaticMemoryManager and UnifiedMemoryManager. Unified allows execution and storage to borrow memory from each other while Static does not allow this. ...

December 10, 2016 · 1 min · Bharath

Spark - QueryExecution

Today I am going to talk about the QueryExecution class in Spark. This class takes care of providing fine grained access to different stages of running a SparkSQL query. Basically the parsing, analysis, optimization and physical planning are all accessible via this class. It also handles inserting extra operations like extracting python UDFs, inserting shuffle stages, internal row format conversions etc. IncrementalExecution is a derived class which allows the same query to be run repeatedly in an incremental fashion, with possible state save in between executions. This is used in Structured Streaming. It is also used to allow users to run their own optimization strategies which is very cool.

November 20, 2016 · 1 min · Bharath

Bigtable

I am reading Google’s Bigtable paper. Here are some notes. Can handle petabytes of data spread over thousands of machines Clients can dynamically control data format, placement, memory/disk Data model is unique, two-level Large variations in size and serving latency can be handled sparse, distributed, multi-dimensional, sorted map row ranges (called tablets) are the unit of distribution and load balancing tablets are dynamically sized efficiency can be gained by taking advantage of sorting on row keys and locality in a tablet column family is a set of columns column family is the unit of access control and accounting any number of columns but limited number of column families (100s) keep last n versions of data or keep last n seconds of data (garbage collection) API has RowMutation and Scanner as primary abstractions uses GFS, cluster management system, sstable, chubby sstable is a persistent, ordered, immutable map operations for key lookup and key range iteration are supported it is split into 64k blocks and there is a block index at the end of the sstable block index allows accessing any key-value in one disk seek sstable can also be memory mapped chubby is used for bigtable master election store bootstrap location of bigtable data to discover tablet servers finalize tablet server deaths store bigtable schema info (column family info) store acls implementation consists of client library, master server and tablet server METADATA is a special table in bigtable This table is split into multiple tablets Each tablet can be present on different tablet servers The first tablet is special and is called root tablet Root tablet is never split (to keep lookup hierarchy for a tablet to a max of 3) root tablet location is in chubby root tablet tracks all the other tablets of the METADATA table these other tablets of the METADATA table can be split Each row in the METADATA table tracks one user tablet. So each METADATA tablet tracks one set of user tablets. each METADATA table row is hash(table id, end row key) -> location With 1KB per row and 128MB METADATA tablet size, trackable number of tablets is 2^17 * 2^17 = 2^34

July 1, 2014 · 2 min · Bharath