Concurrent Predicates: A Debugging Technique for Every Parallel Programmer PACT 13 Justin...

16
Concurrent Predicates: A Debugging Technique for Every Parallel Programmer PACT ‘13 Justin Gottschlich Gilles Pokam Cristiano Pereira Youfeng Wu Intel Corporation 1

Transcript of Concurrent Predicates: A Debugging Technique for Every Parallel Programmer PACT 13 Justin...

Page 1: Concurrent Predicates: A Debugging Technique for Every Parallel Programmer PACT 13 Justin Gottschlich Gilles Pokam Cristiano Pereira Youfeng Wu Intel Corporation.

1

Concurrent Predicates: A Debugging Technique for Every Parallel Programmer

PACT ‘13

Justin GottschlichGilles PokamCristiano PereiraYoufeng Wu

Intel Corporation

Page 2: Concurrent Predicates: A Debugging Technique for Every Parallel Programmer PACT 13 Justin Gottschlich Gilles Pokam Cristiano Pereira Youfeng Wu Intel Corporation.

2

The Problem

• Reproducing known multithreaded bugs is challenging

• Why is it important?– Fixing known bugs is general approach for real-

world bug fixing

• Works well for sequential code, not parallel

Page 3: Concurrent Predicates: A Debugging Technique for Every Parallel Programmer PACT 13 Justin Gottschlich Gilles Pokam Cristiano Pereira Youfeng Wu Intel Corporation.

3

A Simple Sequential Bug Exampley = calculate();

a = x / y;

if (y == 0) y = 1;

if (y == 0) crash

y = calculate();

if (y == 0) y = 1;

a = x / y;y != 0, no crash

Page 4: Concurrent Predicates: A Debugging Technique for Every Parallel Programmer PACT 13 Justin Gottschlich Gilles Pokam Cristiano Pereira Youfeng Wu Intel Corporation.

4

A Not-So Simple Parallel Bug Example

Parallel Bug Reproduction Needs1. Buggy program state2. Buggy program schedule

Page 5: Concurrent Predicates: A Debugging Technique for Every Parallel Programmer PACT 13 Justin Gottschlich Gilles Pokam Cristiano Pereira Youfeng Wu Intel Corporation.

5

The CP Solution

100mil loops, 0-999 calc(),occurs 1 out of 20 executions.

100mil loops, 0-999 calc(),occurs 20 out of 20 executions.

Page 6: Concurrent Predicates: A Debugging Technique for Every Parallel Programmer PACT 13 Justin Gottschlich Gilles Pokam Cristiano Pereira Youfeng Wu Intel Corporation.

6

What is CP?

• Two variants– Concurrent Predicates (CP) – control structure

– CP with Expressions (CPEs) – happens-before ordering extrapolated

Page 7: Concurrent Predicates: A Debugging Technique for Every Parallel Programmer PACT 13 Justin Gottschlich Gilles Pokam Cristiano Pereira Youfeng Wu Intel Corporation.

7

The CPE Solution

Page 8: Concurrent Predicates: A Debugging Technique for Every Parallel Programmer PACT 13 Justin Gottschlich Gilles Pokam Cristiano Pereira Youfeng Wu Intel Corporation.

8

The Real Problem

• But what about reproducing a known bug with an unknown root cause?– Most real-world bugs come in this form

Page 9: Concurrent Predicates: A Debugging Technique for Every Parallel Programmer PACT 13 Justin Gottschlich Gilles Pokam Cristiano Pereira Youfeng Wu Intel Corporation.

9

Recipes and Experimental Data

Page 10: Concurrent Predicates: A Debugging Technique for Every Parallel Programmer PACT 13 Justin Gottschlich Gilles Pokam Cristiano Pereira Youfeng Wu Intel Corporation.

10

A Bit About Bugs• Bugs can be thought in terms of ...

– A root cause– An observable effect

• CPs can be thought of in terms of ...– A root cause CP– An effect CP

• The root cause CP is placed after bug root cause, which is usually unknown

y = calculate();

• The effect CP is placed just before bug effect, which is usually known

a = x / y;

Page 11: Concurrent Predicates: A Debugging Technique for Every Parallel Programmer PACT 13 Justin Gottschlich Gilles Pokam Cristiano Pereira Youfeng Wu Intel Corporation.

11

Recipe: Data Race

• CP can automatically find data races– Early implementation in PIN– Verified results found by Thread Checker• Identified true positives

Page 12: Concurrent Predicates: A Debugging Technique for Every Parallel Programmer PACT 13 Justin Gottschlich Gilles Pokam Cristiano Pereira Youfeng Wu Intel Corporation.

12

Recipe: Atomicity Violation

• Same structure as divide by zero example

Page 13: Concurrent Predicates: A Debugging Technique for Every Parallel Programmer PACT 13 Justin Gottschlich Gilles Pokam Cristiano Pereira Youfeng Wu Intel Corporation.

13

Recipe: Deadlock

• Expression operators in paper

Page 14: Concurrent Predicates: A Debugging Technique for Every Parallel Programmer PACT 13 Justin Gottschlich Gilles Pokam Cristiano Pereira Youfeng Wu Intel Corporation.

14

Experimental Results

• 5 handcrafted bugs• 5 RADBench bugs• 3 unresolved TBoost.STM bugs (now fixed)• Overhead generally 10%-100% (1.1x – 2x)

Page 15: Concurrent Predicates: A Debugging Technique for Every Parallel Programmer PACT 13 Justin Gottschlich Gilles Pokam Cristiano Pereira Youfeng Wu Intel Corporation.

15

Conclusions and Future Directions

• CP and CPE:– Can improve known bug reproduction– Can identify unknown root causes of known bugs

using recipes (we’ve used them)

• What’s next?– Simplify model; direct debugger integration– Automated CPE injection for certain types of

bugs– Usage experience data from novice programmers

Page 16: Concurrent Predicates: A Debugging Technique for Every Parallel Programmer PACT 13 Justin Gottschlich Gilles Pokam Cristiano Pereira Youfeng Wu Intel Corporation.

16

Concurrent Predicates: A Debugging Technique for Every Parallel Programmer

PACT ‘13

Justin Gottschlich ([email protected])Gilles PokamCristiano PereiraYoufeng Wu

Intel Corporation

Questions?