Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using Escape Analysis in Dynamic Data Race Detection Emma Harrington `15 Williams College

Similar presentations


Presentation on theme: "Using Escape Analysis in Dynamic Data Race Detection Emma Harrington `15 Williams College"— Presentation transcript:

1 Using Escape Analysis in Dynamic Data Race Detection Emma Harrington `15 Williams College Emma.Harrington@williams.edu

2 Multithreaded programs can utilize multiple cores. But at the cost of greater programming complexity.

3 Multithreaded programming can be awkward… Some resources should never be used simultaneously. Thread interference occurs when two threads access a shared resource without proper coordination.

4 Thread 1Thread 2 bal = t1 + 10 t1 = bal t2 = bal bal = t2 - 10 Thread 1Thread 2 bal = t1 + 10 t1 = bal t2 = bal bal = t2 - 10 Race Condition = two concurrent unsynchronized accesses with at least one write Thread 1 … t1 = bal; bal = t1 + 10; … Thread 2 … t2 = bal; bal = t2 - 10; … Multithreaded programming can be awkward…

5 Locks prevent interference. Programmers use mutual exclusion locks to protect shared resources in multithreaded environments.

6 We can use locks to prevent race conditions Thread 1 … acq(m); t1 = bal; bal = t1 + 10; rel(m); … Thread 2 … acq(m); t2 = bal; bal = t2 – 10; rel(m); … Thread 1Thread 2 t1 = bal bal = t2 - 10 rel(m) t2 = bal acq(m) bal = t1 + 10 acq(m) rel(m)

7 It’s easy to forget a lock and leave a resource unprotected. Thread 1 … t1 = bal; bal = t1 + 10; … Thread 2 … acq(m); t2 = bal; bal = t2 – 10; rel(m); … Thread 1Thread 2 t1 = bal bal = t2 - 10 t2 = bal bal = t1 + 10 acq(m) rel(m)

8 Dynamic Race Detection x = 0 rel(m) acq(m) x = 1 x = 2 Thread A Thread B... Data Race Goal: Identify race conditions automatically Method: Monitor program as it runs. Check that conflicting memory accesses are ordered by synchronization. Uses Lamport HB relation. Can be efficiently represented in VCs [DJIT + ][FastTrack].

9 How do dynamic race detectors work? Thread 1Thread 2 t1 = bal bal = t2 - 10 rel(m) t2 = bal acq(m) bal = t1 + 10 acq(m) rel(m)

10 Thread 1Thread 2 bal = t1 + 10 t1 = bal t2 = bal bal = t2 - 10 No ordering of these writes. How do dynamic race detectors work?

11 When there are many sensitive resources and many accesses, checking can be expensive (~10x).

12 BalanceName Account Balance Name Account Dynamic Escape Analysis Everything written to a shared variable must become shared. All shared variables must be tracked by the race checker. Everything written to a shared variable must become shared. All shared variables must be tracked by the race checker. Thread 1Thread 2 bal ATM Bank ATM bal Thread 1Thread 2 bal ATM Bank ATM bal Thread 1Thread 2 bal ATM Bank ATM bal Thread 1Thread 2 bal ATM Bank ATM bal Bank Teller BalanceName Account … ATM Bank BalanceName Account

13 Dynamic Escape Analysis Algorithm Objects are either shared or local Storing a reference to a thread local object in a shared object makes it and all objects reachable from it shared. Local objects are accessible from one thread. Shared objects are accessible from multiple threads.

14 How common are local objects and accesses? In a suite of 11 multithreaded Java benchmarks, about 40% of accesses are local and can be safely ignored by dynamic race detectors. I wrote my dynamic escape analysis tool for the RoadRunner Testing Framework [Flanagan and Freund 2010]. Q: A:

15 Q: A: FastTrack [Flanagan and Freund 2009] Dynamic Escape Analysis Does eliminating checks on local accesses speed up race detection? (Run time / FastTrack Run Time)

16 By adding a static escape analysis, can we improve these results? Q: A: FastTrack [Flanagan and Freund 2009] Static and Dynamic Escape Analysis Dynamic Escape Analysis For the static escape analysis, I used IBM’s WALA thread-local analysis that identifies classes where every instance is only accessible from its creating thread. (Run time / FastTrack Run Time)

17 Contributions Race detectors spend a significant amount of time checking accesses to thread-local data that are inherently race free. Dynamic escape analysis identifies accesses that race detectors can ignore. Dynamic escape analysis can be augmented with static information to improve performance.

18 Future Work Use extra cores or the GPU to reduce the overhead by offloading the heap traversal required by dynamic escape analysis. Build into the garbage collector, which already efficiently traverses the heap. Utilize the garbage collector, which must identify garbage objects reachable from no threads. Use multiple cores or the GPU to reduce the overhead of the dynamic escape analysis.


Download ppt "Using Escape Analysis in Dynamic Data Race Detection Emma Harrington `15 Williams College"

Similar presentations


Ads by Google