The Cost of Privatization Hagit Attiya Eshcar Hillel Technion & EPFLTechnion
The cost of privatization (June 2010) 2 A silver bullet for concurrent programming? A transaction is a sequence of operations, on a set of high level items –Appears to execute atomically –Ends by committing or by aborting Read() Write() Commit / Abort Transactional Memory STM
The cost of privatization (June 2010) 3 STM Software TM Implementation (STM) Translates high-level operations into primitives on base objects –e.g., read, write, CAS
The cost of privatization (June 2010) 4 STM Non-Transactional Accesses Direct operations on data items –Due to legacy code, irrevocable operations, or library functions May harm memory consistency & interfere with correct operation of the STM
The cost of privatization (June 2010) 5 STM Strong Atomicity Isolation and consistent ordering of transactions and non-transactional accesses E.g., a non-transactional read observes the value written by an earlier committed transaction
The cost of privatization (June 2010) 6 STM Obvious Solution Single-operation transaction –High overhead –Even with compiler optimizations Want uninstrumented access: single base object m for each item t Read t read m Write t write m
The cost of privatization (June 2010) 7 STM Privatization Cannot just assume a region is private [Guerraoui, Henzinger, Kapalka, Singh ’10] –Need a privatizing transaction: isolate a data region, and access it non-transactionally Deferred updates: write / CAS applied to m (by another transaction) after t is privatized
The cost of privatization (June 2010) 8 Privatization-Safe STM A non-transactional read obtains values written by preceding committed transactions After privatization, a base object associated with a privatized item is not written by another thread
The cost of privatization (June 2010) 9 Linked-List Workload A linked list & blue items are privatized Other transactions write to blue items Cannot just write an item w/o checking first Transactions that write to data that might be private must have non-empty read sets
The cost of privatization (June 2010) 10 Single Global Lock Efficient privatization –JudoSTM [Olszewski, Cutler, Steffan, ‘07] –NOrec [Dalessandro, Spear, Scott, ‘10] Inherently sequential: only one transaction makes progress
The cost of privatization (June 2010) 11 Nonconflicting transactions must commit (even when running concurrently) RingSTM : uses global ring, not progressive [Spear, Michael, von Praun, ‘08] Private transactions: uses quiescing barrier, not progressive [Dice, Matveev, Shavit ‘10] SkySTM : Traces W-R conflicts, progressive [Lev, Luchangco, Marathe, Moir, Nussbaum, ‘09] STM Properties: Progressiveness
The cost of privatization (June 2010) 12 No Early Updates Eager STM: Items in the write set are updated before the transaction is guaranteed to commit Lemma: Assuming progressiveness, eager STMs are not privatization-safe
The cost of privatization (June 2010) 13 STM Properties: Obliviousness No tracking of the data sets of non conflicting transactions (do not distinguish between them) Many STMs are oblivious NOrec, RingSTM, private transactions TLRW (slotted readers) [Dice, Shavit, ’10] –Exceptions are TLRW (unslotted readers), SkySTM 012
The cost of privatization (June 2010) 14 Cost of Privatization I: Invisible Reads Read operations do not write (also at commit-time) –Reduces contention on the memory –Look like empty read sets ― to the rest of the world! –JudoSTM, NOrec, RingSTM Theorem: In a progressive, oblivious STM, a transaction privatizing k items in the linked- list workload must have data set of size Ω(k)
The cost of privatization (June 2010) 15 Lower Bound with Invisible Reads: Proof p 1 executing T 1 ’ p 0 executing T 0 still commits invisibility p 0 executes T 0 privatizing the k blue items –Pick some item u that is not accessed by T 0 p 1 executes T 1 ’ writing to u –Nonempty read set u ready to commit but not eager
The cost of privatization (June 2010) 16 titi Lower Bound with Invisible Reads: Proof p 1 executing T 1 ’ p 0 executing T 0 If T 0 does not access item t i p 1 now executes T 1 writing t i –Nonempty read set, e.g., the linked list T 1 commits after T 0 commits u p 1 executing T 1 p 1 completes T 1 commits progressive oblivious invisible reads p 0 executing T 0
The cost of privatization (June 2010) 17 titi Lower Bound with Invisible Reads: Proof u p 1 executing T 1 p 1 completes T 1 p 0 executing T 0 not eager Base object m i is associated with t i p 1 must write to m i in the suffix of T 1 Contradicts privatization safety
The cost of privatization (June 2010) 18 Cost of Privatization II: Visible Reads Read operations write at some point, e.g. TLRW, SkySTM (read locks), private transactions –Semi-visible: the reader’s identity is unknown (oblivious) Theorem: In an ℓ-progressive, oblivious STM, a transaction privatizing k items in the linked-list workload must access min{ℓ,k} base objects Tradeoff: memory accesses parallelism TLRW, RingSTM realize extreme cases –Can be adapted to get intermediate tradeoffs many transactions make progress
The cost of privatization (June 2010) 19 T 1 … T k write to linked-list items without T 0 observing them (despite being visible) “Confusing” transactions T 1 ’ … T k ’ access a clone of the linked-list Lower Bound for Visible Reads: Hiding p 1 executing T 1 ’ p 0 executing T 0 p 2 executing T 2 ’
The cost of privatization (June 2010) 20 Inductively, swap a confusing transaction with an updating transaction –Incurs an access to an additional base object (to observe the updating transaction) –Be careful, not to lose previous accesses Lower Bound for Visible Reads: Proof p 1 executing T 1 ’ p 2 executing T 2 ’ p 0 executing T 0 p 1 executing T 1 ’ p 2 executing T 2 p 1 executing T 1
The cost of privatization (June 2010) 21 Summary Inherent cost for privatization, linear in the number of privatized items –Invisible reads: high-level accesses –Visible reads: low-level accesses Efficient privatization requires tracking data sets of other transactions or limiting parallelism –Both have significant impact on performance Same results for disjoint-access parallel STM Same results for static & dynamic separation [Abadi, Birrell, Harris, Isard ’08] [Abadi, Birrell, Harris, Hsiesh ’09]
The cost of privatization (June 2010) 22 Alternative Costs SkySTM is progressive, and provides efficient privatization Not oblivious: Tracks data sets in detail –All transactions have cost proportional to the size of their data set Is this inherent?
The cost of privatization (June 2010) 23 Thank you
The cost of privatization (June 2010) 24 Supporting Strong Atomicity STM using a global clock provides strong atomicity, w/o privatization [Guerraoui, Henzinger, Kapalka, Singh ’10] Theorem: progressive STMs cannot guarantee strong atomicity Static separation [Abadi, Birrell, Harris, Isard ’08] Dynamic separation [Abadi, Birrell, Harris, Hsiesh ’09] –Same lower bounds
The cost of privatization (June 2010) 25 Linked List Workload A privatizing transaction privatizes the list, for a thread that is going to work on the blue items Other transactions read the linked list nodes and write to a single blue item The privatizing transaction nullifies the head
The cost of privatization (June 2010) 26 STM Properties: Invisible Reads
The cost of privatization (June 2010) 27 Disjoint-Access Parallel STMs With invisible reads –Requires Ω(k) high-level accesses Allowing contention only due to nontrivial conflicts –Requires Ω(k) low-level accesses –Even with visible reads
The cost of privatization (June 2010) 28 Lower Bound with Invisible Reads: Proof p 0 executes T 0 privatizing k items –Some item u is not accessed by T 0 p 1 executes T 1 ’ writing to u –Arbitrary read set Cost of Privatization 28 p 1 executing T 1 ’ p 0 executing T 0 progressive
The cost of privatization (June 2010) 29 Lower Bound with Invisible Reads: Proof If T 0 does not access item t i Mofidy p 1 to execute T 1 writing to t i –Arbitrary read set T 1 commits after T 0 commits p 1 executing T 1 ’ p 1 executing T 1 p 1 completes T 1 p 0 executing T 0 progressiveoblivious invisible reads p 0 executing T 0
The cost of privatization (June 2010) 30 Lower Bound with Invisible Reads: Proof Base object m i is associated with t i p 1 must write to m i in the suffix of T 1 Contradicts privatization safety p 1 executing T 1 p 1 completes T 1 p 0 executing T 0 not eager
The cost of privatization (June 2010) 31 Open Question SkySTM is progressive, but not oblivious, with efficient privatization –Alternative cost: “writing” all the read locks (proportional to the size of the data set) –Intuitively, this is the cost of not being oblivious Can this be avoided?