Cache-Conscious Concurrency Control of Main-Memory Indexes on Shared-Memory Multiprocessor Systems Sang K. Cha, Sangyong Hwang, Kihong Kim, Keunjoo Kwon VLDB 2001 Presented by: Raluca Marcuta 1 / 31
1 Introduction Background and Motivation Objectives 2 Concurrency Control Approaches Physical Versioning Lock Coupling 3 Implementation Main Idea of OLFIT Node Operations Tree Operations 4 Experimental Evaluation Pure Search Performance Pure Update Performance Performance with Varying Update Ratio 5 Conclusions and Future Work 6 Related Work 7 Critique 2 / 31
Background and Motivation Cache-conscious index structures Approach : reduce cache misses by increasing index fanout Goal : improve search performance Examples : CSB+-tree (Cache Sensitive B+-tree) CR-tree (cache-conscious version of the R-tree) Concurrency control (CC) in shared-memory multiprocessors Crucial for real-world main memory database applications Concurrent updates and reads Approaches : physical versioning, lock coupling, tree-level latching 3 / 31
Objectives A new, more efficient CC scheme for main memory indexes OLFIT : Optimistic Latch-Free Index Traversal Customized for B+-trees and CSB+-trees Eliminates latching during index traversal Reduces latching during index update Goals Multiprocessor scalability of : index search update performance 4 / 31
Physical Versioning Approach Index readers do not interfere with updaters New version of the node for the updater Incorporation of new version : tree-level latching or node-level latching Advantages Latch-free traversal of indexes High concurrency for read transactions Disadvantages High cost for creating versions - memory allocation and write Index performance decreases with the increase of update ratio Poor scalability of update performance 5 / 31
Lock Coupling Approach Latching nodes during index traversal Hold latch on node until request granted for latch on child Disadvantages Poor scalability Heavy latching of the nodes Latching index nodes => coherence cache misses Coherence cache misses A processor s cached copy of a block is invalidated by another processor updating the cache block. 6 / 31
Coherence Cache Misses Caused by Latching Latches : placed inside the index node Latching operation Acquire/release latch Involves memory write : Invalidation of cache block regardless if the node updated 7 / 31
Coherence Cache Misses Caused by Latching (cont.) 8 / 31
Coherence Cache Misses Caused by Latching (cont.) 9 / 31
Coherence Cache Misses Caused by Latching (cont.) 10 / 31
Coherence Cache Misses Caused by Latching (cont.) 11 / 31
Coherence Cache Misses Caused by Latching (cont.) 12 / 31
Rationale Purpose of index CC Index readers reach the correct leaf without interfering with concurrent updaters Index updaters do not interfere with each other Criteria for a good CC scheme High degree of parallelism Problem Probability of coherence cache misses increases with the number of processors Save cache misses by Latch-free traversal during index search Latch-free traversal during index update 13 / 31
Latch-Free Index Search and Update Latch-free index search Condition = consistent node reads Consistency = no update between start and end of node read Latch-free index update Assumptions 1 Most node updates occur at the leaf level or near the leaf level 2 Number of leaf nodes > number of processors => probability of conflict = low Consequences 1 Latches on upper-level nodes are acquired too conservatively 2 Latches on leaf nodes are acquired too pessimistically 14 / 31
Main Idea of OLFIT 1 Traverse down the index optimistically without latching any nodes 2 Updaters acquire the latch of the leaf node to be updated 3 Latch acquisition proceeds upward if node split or deletion necessary Update operations on a node = serialized using a latch Read operations on a node = retried in case of inconsistency 15 / 31
Node Structure of B+-tree for OLFIT Two primitives : UpdateNode and ReadNode 16 / 31
Node Operations for OLFIT Algorithm UpdateNode U1. Acquire latch. U2. Update the content. U3. Increment version. U4. Release latch. Algorithm ReadNode R1. Copy the value of version into a register R. R2. Read the content of the node. R3. If latch is locked, go to R1. R4. If the current value of version is different from the copied value in R, go to R1. 17 / 31
Example of Concurrency Control 18 / 31
Example of Concurrency Control 19 / 31
Example of Concurrency Control 20 / 31
Example of Concurrency Control 21 / 31
Example of Concurrency Control 22 / 31
Tree Operations for OLFIT Dealing with node split Use high key and link pointer to the right neighbor Dealing with node deletion Remove links to node Register node to garbage collector Deallocate node when no operation reads the node 23 / 31
Experimental Evaluation Implementation of index CC schemes for B+-tree and CSB+-tree Lock coupling with node latches (LC) Tree-level locking with a tree latch (TL) Physical versioning with node latches (VN) Physical versioning with a tree latch (VT) OLFIT (OL) No concurrency control (NO) Experimental setting 8 CPUs, each with 8MB L2 cache, cache line of 64 bytes Workloads : 100% search, 100% insert, 50% insert + 50% delete + mixture of search, insert and delete Initial index : 10 million uniformly distributed 4-byte integers Size of index nodes : 128 bytes 24 / 31
Pure Search Performance for B+-tree OL, VN and VT - similar to NO TL - worse due to contention at the tree-latch LC - worst due to many coherence cache misses 25 / 31
Pure Update Performance for B+-tree and CSB+-tree OL - the only scalable one VN and VT - worse due to high cost of versioning VN and LC - slowly increase performance as number of threads increases VT and TL - worse due to contention at the tree-latch 26 / 31
Eight-Thread Performance with Varying Update Ratio OL, VN and VT - comparable for update ratio = 0 OL - better than other when update ratio increases 27 / 31
Conclusions and Future Work Conclusions The effect of latching in CC => coherence cache misses New optimistic index CC - OLFIT for B+-trees and CSB+-trees 1 No latching during index traversal 2 Latching for index update - only when necessary Performance comparison experiments Superior update and read scalability of OLFIT Future work Adaptation of OLFIT to other cache-conscious schemes, e.g. CR-tree Test OLFIT in real main memory database applications 28 / 31
Related Work Concurrency of Operations on B-Trees - 1977 Logical and Physical Versioning in Main Memory Databases - 1997 Presented paper - 2001 Indexing Moving Objects using Short-Lived Throwaway Indexes - 2009 Relation to own paper Concurrency control in main memory indexes Reduce latching to achieve greater performance - allow reading during updating 29 / 31
Critique Good aspects Relevant and various comparison experiments of five CC schemes : varying the number of threads on different workloads single thread and eight-thread varying the update ratio Good background Structured - easy to follow argument Could be improved More detailed proof that node splits are correctly handled (example) Generation of workloads is uniform - variation of insert/delete locality No related work section - included in the introduction instead Better formulation, e.g. parallel transact, we use the technique of using 30 / 31
Questions? 31 / 31