Hassium: Hardware Assisted Database Synchronization Hillel Avni Aharon Avitzur
Contents Hassium Execution Example Performance Page 1
Hassium Single version, shared everything concurrency control algorithm The following are wrapped with separate HTM transactions: Row access, for read or write Commit Deadlock detection More characteristics: Monotonic increasing version counter V per database thread (i.e. per connection) Unique database thread ID Each database transaction Has a unique set of ID and version, <ID, V> At commit, a database transaction marks <ID, V> as committed More details in the running example… Page 2
Hassium Scalability Characteristics Compared, single version, shared everything algorithm types: OCC: Lock write-set at commit time and then and validate read-set ETL: Lock write-set at encounter time and validate read-set at commit 2PL: Lock both read and write-sets at encounter time. HTM: Check conflicts by exploiting cache coherence invalidations T1 and T2, both access row R. Scalability characteristics: Writer Allows Reader: T1 wrote R T2 can read R (not ETL and 2PL) Writer See Writer: T1 wrote R T2 sees R is locked (not OCC) Reader Allows Writer: T1 read R T2 can write R (not HTM and 2PL) At Least One Survives: T1 and T2 will not mutually abort (not OCC) and ETL) Page 3
Contents Hassium Execution Example Performance Page 4
Example Threads ID = 0 V = 12 Data ID = 0 V = 3 Row 0 ID = 0 V = 3 Safe Versions Array Page 5
Example Threads Public ID = 0 V = 12 Data ID = 0 V = 3 Row 0 ID = 0 Private Safe Versions Array Page 6
Example ID (0) and V (3) of last writer of Row 1. User data not shown Backup of last committed version of the row Threads ID = 0 V = 12 Data ID = 0 V = 3 Row 0 Highest committed version of thread 1 ID = 0 V = 3 ID = 1 V = 183 Row 1 Highest committed version of thread 0 ID = 1 V = 170 Row 2 V = 11 V = 182 Safe Versions Array Page 7
Example Threads ID = 0 V = 12 Data ID = 0 V = 3 Row 0 ID = 0 V = 3 Safe Versions Array Page 8
Example: Threads 0 and 1 Write ID = 0 V = 12 2 Concurrent HTM TX Data ID = 0 V = 3 Row 0 ID = 1 V = 183 ID = 0 V = 3 ID = 1 V = 183 Row 1 ID = 0 V = 12 ID = 1 V = 170 Row 2 V = 11 V = 182 Safe Versions Array Page 9
Example: Threads Read from each other ID = 0 V = 12 Another 2 Concurrent HTM TX Data ID = 0 V = 3 ID = 0 V = 3 Row 0 ID = 1 V = 183 ID = 0 V = 3 ID = 1 V = 183 Row 1 ID = 0 V = 12 ID = 1 V = 170 ID = 1 V = 170 Row 2 V = 11 V = 182 Safe Versions Array Page 10
Example: Thread 0 Validates Threads ID = 0 V = 12 HTM TX Start Data ID = 0 V = 3 ID = 0 V = 3 Row 0 ID = 1 V = 183 ID = 0 V = 3 ID = 1 V = 183 Row 1 ID = 0 V = 12 ID = 1 V = 170 ID = 1 V = 170 Row 2 V = 11 V = 182 Safe Versions Array Page 11
Example: Thread 0 Validation Passed Threads ID = 0 V = 12 HTM TX Continues Data ID = 0 V = 3 ID = 0 V = 3 Row 0 ID = 1 V = 183 ID = 0 V = 3 ID = 1 V = 183 Row 1 ID = 0 V = 12 ID = 1 V = 170 ID = 1 V = 170 Row 2 V = 11 V = 182 Safe Versions Array Page 12
Example: Thread 0 Commits Threads ID = 0 V = 12 HTM TX Commits Data ID = 0 V = 3 Row 0 ID = 1 V = 183 ID = 0 V = 3 ID = 1 V = 183 Row 1 ID = 0 V = 12 ID = 1 V = 170 ID = 1 V = 170 Row 2 V = 12 V = 182 Safe Versions Array Page 13
Example: Thread 0 Commits Threads ID = 0 V = 13 NO HTM Data ID = 0 V = 3 Row 0 ID = 1 V = 183 ID = 0 V = 3 ID = 1 V = 183 Row 1 ID = 0 V = 12 ID = 1 V = 170 ID = 1 V = 170 Row 2 V = 12 V = 182 Safe Versions Array Page 14
Example: Thread 1 Validates Threads ID = 0 V = 13 HTM TX Start Data ID = 0 V = 3 Row 0 ID = 1 V = 183 ID = 0 V = 3 ID = 1 V = 183 Row 1 ID = 0 V = 12 ID = 1 V = 170 ID = 1 V = 170 Row 2 V = 12 V = 182 Safe Versions Array Page 15
Example: Threads 1 Validation Fails HTM TX Commits Data ID = 0 V = 3 Row 0 ID = 1 V = 183 ID = 0 V = 3 ID = 1 V = 183 Row 1 ID = 0 V = 12 ID = 1 V = 170 ID = 1 V = 170 Row 2 V = 12 V = 182 Safe Versions Array Page 16
Example: Thread 1 Aborts and rolls back Threads ID = 0 V = 13 NO HTM Data ID = 0 V = 3 Row 0 ID = 0 V = 3 ID = 1 V = 183 Row 1 ID = 0 V = 12 Row 2 V = 12 V = 182 Safe Versions Array Page 17
Contents Hassium Execution Example Performance Page 18
Possibility Test We execute the following test: N rows, r1,,,rN N threads, t1…tN A thread tk executes: Start Transaction Write rk Read r1…rN Commit Transaction All the algorithms we tested stopped at 3 threads: OCC and ETL: 100% aborts 2PL: Slowed to zero Page 19
Contention Test – TPCC New Order Mix of reads and writes. Hassium has Lower DB abort rate than OCC. When contention rises, Hassium has lower overhead than 2PL Page 20
Contention Test – TPCC Payment Mostly writes Hassium has Lower DB abort than ETL due to deadlock detection OCC has lower part of aborted DB transactions but, higher part of aborted work, because OCC always aborts at commit and waists more work Page 21