180 likes | 191 Views
This paper discusses the ATOMOS transactional programming language, focusing on transactional memory, conditional waiting, transaction nesting, and evaluation. It compares ATOMOS with Java and concludes that ATOMOS simplifies program design and improves performance.
E N D
The ATOMOS Transactional Programming Language Mehdi AmirijooLinköpings universitet
Background • Transactional memory • Conditional waiting • Transaction Nesting • Evaluation • Conclusion Mehdi Amirijoo
Background • Multi-threaded application • Access to shared data using lockssemaphore s;... wait(s); //decrease scount++;signal(s); //increase s... Mehdi Amirijoo
Background • Course-grained locking leads to serialization on high-contention data structures Process P1 { wait(s); ... d.a++; ... signal(s);} Process P2 { wait(s); ... d.b++; ... signal(s);} Process P3 { wait(s); ... d.a++; ... signal(s);} Mehdi Amirijoo
Background • Fine-grained locking: • improves concurrency • increases code complexity (deadlocks) • degrading performance Process P1 { ... wait(s1); d.a++; signal(s1); ...} Process P2 { ... wait(s2); d.b++; signal(s2); ...} Mehdi Amirijoo
Transactional Memory • Focus on where atomic execution is necessary • Not how it is implemented Process P1 { ... atomic { d.a++; } ...} Process P2 { ... atomic { d.b++; } ...} Mehdi Amirijoo
Transactional Memory • Statements within atomic appear to have serialization with respect to: • Other transactions • Reads and writes outside of transactions • Nested transactions • Optimistic speculation (transactions) vspessimistic waiting (locks) • Roll-back due to writesoutside the transaction Process P1 { atomic { atomic { ... } } ... Mehdi Amirijoo
Conditional Waiting • Conditional critical region (CCR) • Similar property as critical sections, and • A process can enter the critical region iff the condition evaluates to be true. • In ATOMOS: atomic { if ( !condition(condition_variables) ) { watch condition_variables; retry;} // critical region} Mehdi Amirijoo
Conditional Waiting Class Buffer { public int get (){ synchronized (this) { while (!available) wait(); available = false; notifyAll(); return contents;}} public void put(int value) { synchronized (this) { while (available) wait(); contents = value; available = true; notifyAll();}} } Class Buffer {public int get() { atomic { if (!available) { watch available; retry;} available = false; return contents;}} public void put (int value) { atomic { if (available) { watch available; retry;} contents = value; available = true;}}} Mehdi Amirijoo
Conditional Waiting Example: Barrier synchronization atomic { count++; if (count != nThreads) { watch count; retry; }} synchronized (lock) { count++; if (count != nThreads) lock.wait(); else lock.notifyAll();} atomic { count++; } atomic { if (count != nThreads) { watch count; retry; }} Mehdi Amirijoo
Nesting • In databases transactions usually reduce isolation to improve performance • Communication from within uncommitted transactions! • Closed-nested transaction:Results of children visible only to parent • Open-nested Transaction:Results of children visible globally Mehdi Amirijoo
Nesting Mehdi Amirijoo
Nesting public static int generateID { atomic { return id++; }} public static void createOrder (...) { atomic { Order order = new Order(); order.setID(generateID()); // finish initialization of order. This could // include more calls to generateID. orders.put(new Integer(order.getID()),order); }} Mehdi Amirijoo
Nesting public static open int generateID { open { return id++; }} public static void createOrder (...) { atomic { Order order = new Order(); order.setID(generateID()); // finish initialization of order. This could // include more calls to generateID. orders.put(new Integer(order.getID()),order); }} Mehdi Amirijoo
Evaluation • Goal:Compare ATOMOS with Java • Synchronized→atomic • wait(), notify(), notifyAll() → watch, retry • 1 to 32 CPU:s (no thread migration) • No garbage collection • Measure execution time Mehdi Amirijoo
Evaluation Benchmark focusing on business object manipulation Only 1% chance of contention between threads. ATOMOS does not incur additional bottlenecks Mehdi Amirijoo
Evaluation Benchmark focusing on business object manipulation Hashtable and HashMap use only one mutex ConcurrentHashMap uses fine-grained locking Atomos uses single atomic statement Mehdi Amirijoo
Conclusion • Transactional programming simplifies design of programs • Conditional waiting enables CCR • Open nesting increases performance by reducing time to commit • Evaluation shows that the approach is scalable with the number of processors Mehdi Amirijoo