+ All Categories
Home > Documents > Pacer: Proportional Detection of Data Races

Pacer: Proportional Detection of Data Races

Date post: 18-Mar-2016
Category:
Upload: chico
View: 27 times
Download: 2 times
Share this document with a friend
Description:
Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin. Pacer: Proportional Detection of Data Races. Detecting data races in production. Number of threads. Problem today. Problem in future. Sampling rate. Sampling periods. Non-sampling periods. - PowerPoint PPT Presentation
Popular Tags:
125
Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin
Transcript
Page 1: Pacer: Proportional Detection of Data Races

Michael BondKatherine CoonsKathryn McKinleyUniversity of Texas at Austin

Page 2: Pacer: Proportional Detection of Data Races

Detecting data races in production

Page 3: Pacer: Proportional Detection of Data Races

Overhead

FastTrack[Flanagan & Freund ’09]

80x 8x

Page 4: Pacer: Proportional Detection of Data Races

Overhead

FastTrack[Flanagan & Freund ’09]

creads&writes + csync n

Number of threads

Page 5: Pacer: Proportional Detection of Data Races

Overhead

FastTrack[Flanagan & Freund ’09]

creads&writes + csync n

Problemin future

Problemtoday

Page 6: Pacer: Proportional Detection of Data Races

Overhead

FastTrack[Flanagan & Freund ’09]

creads&writes + csync n

Pacer (creads&writes + csync n) r + cnon-sampling (1 – r)

Sampling rate

Page 7: Pacer: Proportional Detection of Data Races

Overhead

FastTrack[Flanagan & Freund ’09]

creads&writes + csync n

Pacer (creads&writes + csync n) r + cnon-sampling (1 – r)

Sampling periods Non-sampling periods

Page 8: Pacer: Proportional Detection of Data Races

Overhead

FastTrack[Flanagan & Freund ’09]

creads&writes + csync n

Pacer (creads&writes + csync n) r + cnon-sampling (1 – r)

Probability (detecting any race)

FastTrack 1

Pacer r

Page 9: Pacer: Proportional Detection of Data Races

Detect race first access sampled

Page 10: Pacer: Proportional Detection of Data Races

Sampling period

Thread A Thread B

Non-sampling period

Sampling period

Non-sampling period

Non-sampling period

Page 11: Pacer: Proportional Detection of Data Races

Thread A Thread B

write x

read x

read y

write y

Page 12: Pacer: Proportional Detection of Data Races

Insight #1:Stop tracking variable after

non-sampled access

Page 13: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

Thread B

Page 14: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

Thread B

lock m

Page 15: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

Thread B

lock m

write x

Page 16: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write x

Page 17: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write xRace!

Page 18: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write xRace!

Page 19: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4A B A B

Vector clocks

Page 20: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4A B A B

Vector clocks

Page 21: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4A B A B

Vector clocks

Page 22: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4A B A B

Page 23: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4A B A B

5@A

Page 24: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4

5 2

5@A

A B A B

Page 25: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4

6 25 2

5@A

Incrementclock

A B A B

Page 26: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4

6 2

5 4

5 2

Joinclocks

5@A

A B A B

Page 27: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4

5 4

5 2

5@A

6 2Happens before?

A B A B

Page 28: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4

5 4

5@A

5 26 2

A B A B

Page 29: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4

5 4

5@A

5 26 2

A B A B

Page 30: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4

5 4

5@A

5 26 2

No work performed

A B A B

Page 31: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4

5 4

5@A

5 26 2

Race uncaught

A B A B

Page 32: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4

5 4

5 26 2

4@B

A B A B

Page 33: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4

5 4

5 26 2

4@B

Happens before?Race!

A B A B

Page 34: Pacer: Proportional Detection of Data Races

Insight #2: We only care whether“A happens before B”

if A is sampled

Page 35: Pacer: Proportional Detection of Data Races

Thread A Thread B

Do these events happen before other events?We don’t care!

Page 36: Pacer: Proportional Detection of Data Races

Increment clocks

Thread A Thread B

Don’t increment clocks

Increment clocks

Don’t increment clocks

Don’t increment clocks

Do these events happen before other events?We don’t care!

Page 37: Pacer: Proportional Detection of Data Races

Thread A

unlock m1

unlock m2

Thread B

lock m1

lock m2

5 2 3 4A B A B

Page 38: Pacer: Proportional Detection of Data Races

Thread A

unlock m1

unlock m2

Thread B

lock m1

lock m2

5 2 3 4

5 4

5 4

5 2

No clock increment

A B A B

Page 39: Pacer: Proportional Detection of Data Races

Thread A

unlock m1

unlock m2

Thread B

lock m1

lock m2

5 2 3 4

5 4

5 4

5 2

5 2

A B A B

Page 40: Pacer: Proportional Detection of Data Races

Thread A

unlock m1

unlock m2

Thread B

lock m1

lock m2

5 2 3 4

5 4

5 4

5 2

5 2

Unnecessary join

A B A B

Page 41: Pacer: Proportional Detection of Data Races

Thread A

unlock m1

unlock m2

Thread B

lock m1

lock m2

5 2 3 4

5 4

5 4

5 2

5 2

O(n) O(1)

A B A B

Page 42: Pacer: Proportional Detection of Data Races

http://jikesrvm.org/Research+Archive

Page 43: Pacer: Proportional Detection of Data Races

1

Page 44: Pacer: Proportional Detection of Data Races

Qualitative improvementin time & space

Page 45: Pacer: Proportional Detection of Data Races

Probability (detecting any race) = r?

Page 46: Pacer: Proportional Detection of Data Races
Page 47: Pacer: Proportional Detection of Data Races

LiteRace [Marino et al. ’09]

Cold-region hypothesis [Chilimbi & Hauswirth ’04]

Full analysis at synchronization operations

Page 48: Pacer: Proportional Detection of Data Races

Accuracy, time, space sampling rateDetect race first access sampled

Page 49: Pacer: Proportional Detection of Data Races

Accuracy, time, space sampling rateDetect race first access sampled

Qualitative improvement

Page 50: Pacer: Proportional Detection of Data Races

Accuracy, time, space sampling rateDetect race first access sampled

Qualitative improvementHelp developers fix difficult-to-reproduce bugs

Page 51: Pacer: Proportional Detection of Data Races

Accuracy, time, space sampling rateDetect race first access sampled

Qualitative improvementHelp developers fix difficult-to-reproduce bugs

Thank you

Page 52: Pacer: Proportional Detection of Data Races
Page 53: Pacer: Proportional Detection of Data Races

Thread A

unlock m1

unlock m2

Thread B

lock m1

lock m2

5 2 3 4

5 4

A B A B

5 4

v6

Vector clock versions

Page 54: Pacer: Proportional Detection of Data Races

Thread A

unlock m1

unlock m2

Thread B

lock m1

lock m2

5 2 3 4

5 4

A B A Bv6

5 2 v6

v6

Page 55: Pacer: Proportional Detection of Data Races

Thread A

unlock m1

unlock m2

Thread B

lock m1

lock m2

5 2 3 4A B A B

v6

5 2 v6

5 2 v6

Join unnecessary

5 4v6

Page 56: Pacer: Proportional Detection of Data Races
Page 57: Pacer: Proportional Detection of Data Races
Page 58: Pacer: Proportional Detection of Data Races
Page 59: Pacer: Proportional Detection of Data Races
Page 60: Pacer: Proportional Detection of Data Races

Qualitative improvement

Page 61: Pacer: Proportional Detection of Data Races

Core 2 Quad (4 cores) Multithreaded benchmarks (DaCapo & SPECjbb2000)

Evaluating sampling-based race detection Need 100s of trials to evaluate Some races are rare Evaluate only frequent races

Page 62: Pacer: Proportional Detection of Data Races

Two accesses to same variable (one is a write)

One access doesn’t happen before the other Program order Synchronization order▪ Acquire-release▪ Wait-notify▪ Fork-join▪ Volatile read-write

Page 63: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

Thread B Two accesses to same variable (one is a write)

One access doesn’t happen before the other Program order Synchronization order▪ Acquire-release▪ Wait-notify▪ Fork-join▪ Volatile read-write

Page 64: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

Thread B

lock m

write x

Two accesses to same variable (one is a write)

One access doesn’t happen before the other Program order Synchronization order▪ Acquire-release▪ Wait-notify▪ Fork-join▪ Volatile read-write

Page 65: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write x

Two accesses to same variable (one is a write)

One access doesn’t happen before the other Program order Synchronization order▪ Acquire-release▪ Wait-notify▪ Fork-join▪ Volatile read-write

Page 66: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write xRace!

Two accesses to same variable (one is a write)

One access doesn’t happen before the other Program order Synchronization order▪ Acquire-release▪ Wait-notify▪ Fork-join▪ Volatile read-write

Page 67: Pacer: Proportional Detection of Data Races

Races indicate Atomicity violations Order violations

Page 68: Pacer: Proportional Detection of Data Races

Races indicate Atomicity violations Order violations

Races lead to Sequential consistency violations

No races sequential consistency (Java/C++) Races writes observed out of order

Page 69: Pacer: Proportional Detection of Data Races

Races indicate Atomicity violations Order violations

Races lead to Sequential consistency violations

No races sequential consistency (Java/C++) Races writes observed out of order

Most races potentially harmful [Flanagan & Freund ’10]

Page 70: Pacer: Proportional Detection of Data Races

class ProducerConsumer { boolean ready; int x;

produce() { x = … ; ready = true; }

consume() { while (!ready) { } … = x; }}

Page 71: Pacer: Proportional Detection of Data Races

class ProducerConsumer { boolean ready; int x; T1 T2 produce() { x = … ; ready = true; }

consume() { while (!ready) { } … = x; }}

Page 72: Pacer: Proportional Detection of Data Races

class ProducerConsumer { boolean ready; int x; T1 T2 produce() { x = … ; ready = true; }

consume() { while (!ready) { } … = x; }}

Page 73: Pacer: Proportional Detection of Data Races

class ProducerConsumer { boolean ready; int x; T1 T2 produce() { x = … ; ready = true; }

consume() { while (!ready) { } … = x; }}

Page 74: Pacer: Proportional Detection of Data Races

class ProducerConsumer { boolean ready; int x; T1 T2 produce() { x = … ; ready = true; }

consume() { while (!ready) { } … = x; }}

Can read old value

Page 75: Pacer: Proportional Detection of Data Races

class ProducerConsumer { boolean ready; int x; T1 T2 produce() { x = … ; ready = true; }

consume() { … = x; while (!ready) { } }}

Legal reordering by compiler or hardware

Page 76: Pacer: Proportional Detection of Data Races

class ProducerConsumer { boolean ready; int x; T1 T2 produce() { x = … ; ready = true; }

consume() { while (!ready) { } … = x; }}

Page 77: Pacer: Proportional Detection of Data Races

class ProducerConsumer { volatile boolean ready; int x; T1 T2 produce() { x = … ; ready = true; }

consume() { while (!ready) { } … = x; }}

Happens- before edge

Page 78: Pacer: Proportional Detection of Data Races

class LibraryBook { Set<Person> borrowers;}

Page 79: Pacer: Proportional Detection of Data Races

class LibraryBook { Set<Person> borrowers;

addBorrower(Person p) { if (borrowers == null) { borrowers = new HashSet<Person>(); } borrowers.add(p); }}

Page 80: Pacer: Proportional Detection of Data Races

class LibraryBook { Set<Person> borrowers;

addBorrower(Person p) { synchronized (this) { if (borrowers == null) { borrowers = new HashSet<Person>(); } } borrowers.add(p); }}

Page 81: Pacer: Proportional Detection of Data Races

class LibraryBook { Set<Person> borrowers;

addBorrower(Person p) { if (borrowers == null) { synchronized (this) { if (borrowers == null) { borrowers = new HashSet<Person>(); } } } borrowers.add(p); }}

Page 82: Pacer: Proportional Detection of Data Races

class LibraryBook { Set<Person> borrowers;

addBorrower(Person p) { if (borrowers == null) { synchronized (this) { if (borrowers == null) { borrowers = new HashSet<Person>(); } } } borrowers.add(p); }}

Page 83: Pacer: Proportional Detection of Data Races

addBorrower(Person p) { if (borrowers == null) { synchronized (this) { if (borrowers == null) { borrowers = new HashSet(); } } }

...

borrowers.add(p);}

addBorrower(Person p) {

if (borrowers == null) { ...

} borrowers.add(p);}

Page 84: Pacer: Proportional Detection of Data Races

addBorrower(Person p) { if (borrowers == null) { synchronized (this) { if (borrowers == null) { HashSet obj = alloc HashSet; obj.<init>(); borrowers = obj; } } }

...

borrowers.add(p);}

addBorrower(Person p) {

if (borrowers == null) { ...

} borrowers.add(p);}

Page 85: Pacer: Proportional Detection of Data Races

addBorrower(Person p) { if (borrowers == null) { synchronized (this) { if (borrowers == null) { HashSet obj = alloc HashSet; borrowers = obj; obj.<init>(); } } }

...

borrowers.add(p);}

addBorrower(Person p) {

if (borrowers == null) { ...

} borrowers.add(p);}

Page 86: Pacer: Proportional Detection of Data Races

addBorrower(Person p) { if (borrowers == null) { synchronized (this) { if (borrowers == null) { HashSet obj = alloc HashSet; borrowers = obj;

obj.<init>(); }}} ... borrowers.add(p);}

addBorrower(Person p) {

if (borrowers == null) { ...

} borrowers.add(p);}

Page 87: Pacer: Proportional Detection of Data Races
Page 88: Pacer: Proportional Detection of Data Races

33% base overhead

~50% overhead

Page 89: Pacer: Proportional Detection of Data Races

Program alone FastTrack Pacer

Detection rate 0 occurrence rate occurrence rate × r

Running time t t(c1 + c2n) t[(c1 + c2n)r + c3]

Evaluate only frequent races Evaluate scaling with r Don’t evaluate scaling with n

Page 90: Pacer: Proportional Detection of Data Races
Page 91: Pacer: Proportional Detection of Data Races

50 million people

Page 92: Pacer: Proportional Detection of Data Races

Energy Management System Alarm and Event Processing Routine (1 MLOC)

http://www.securityfocus.com/news/8412

Page 93: Pacer: Proportional Detection of Data Races

Energy Management System Alarm and Event Processing Routine (1 MLOC)

Post-mortem analysis: 8 weeks"This fault was so deeply embedded, it took them

weeks of poring through millions of lines of code and data to find it.” –Ralph DiNicola, FirstEnergy

http://www.securityfocus.com/news/8412

Page 94: Pacer: Proportional Detection of Data Races

Race condition Two threads writing to data structure simultaneously

Usually occurs without error Small window for causing data corruption

http://www.securityfocus.com/news/8412

Page 95: Pacer: Proportional Detection of Data Races

Tracks happens-before: sound & precise 80X slowdown Each analysis step: O(n) time (n = # of threads)

Page 96: Pacer: Proportional Detection of Data Races

Tracks happens-before: sound & precise 80X slowdown Each analysis step: O(n) time (n = # of threads)

FastTrack [Flanagan & Freund ’09] Reads & writes (97%): O(1) time Synchronization (3%): O(n) time 8X slowdown

Page 97: Pacer: Proportional Detection of Data Races

Tracks happens-before: sound & precise 80X slowdown Each analysis step: O(n) time (n = # of threads)

FastTrack [Flanagan & Freund ’09] Reads & writes (97%): O(1) time Synchronization (3%): O(n) time 8X slowdown

Problem today

Problem in future

Page 98: Pacer: Proportional Detection of Data Races

Tracks happens-before: sound & precise 80X slowdown Each analysis step: O(n) time (n = # of threads)

FastTrack [Flanagan & Freund ’09] Reads & writes (97%): O(1) time Synchronization (3%): O(n) time 8X slowdown

Page 99: Pacer: Proportional Detection of Data Races

Thread A Thread B

5 2 3 4A B A B

Vector clocks

Page 100: Pacer: Proportional Detection of Data Races

Thread A Thread B

5 2 3 4A B A B

Vector clocks

Thread A’s logical time Thread B’s logical time

Page 101: Pacer: Proportional Detection of Data Races

Thread A Thread B

5 2 3 4A B A B

Vector clocks

Last logical time “received” from B

Last logical time “received” from A

Page 102: Pacer: Proportional Detection of Data Races

5 2 3 4A B A B

Thread A

unlock m

Thread B

lock m6 2Increment

clock

Page 103: Pacer: Proportional Detection of Data Races

5 2 3 4A B A B

Thread A

unlock m

Thread B

lock m6 2

5 4

5 2

Joinclocks

Page 104: Pacer: Proportional Detection of Data Races

5 2 3 4A B A B

Thread A

unlock m

Thread B

lock m6 2

5 4 n = # of threads

O(n) time

5 2

Page 105: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4A B A B

Page 106: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4A B A B

5@A

Page 107: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4A B A B

5@A

Page 108: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4A B A B

6 2

5@A

5 2

Page 109: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4A B A B

6 2

5@A

5 2

Page 110: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4A B A B

6 2

5 4

5@A

5 2

Page 111: Pacer: Proportional Detection of Data Races

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4A B A B

5 4

5@A

6 2Happens before?5 2

Page 112: Pacer: Proportional Detection of Data Races

5@A

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4A B A B

5 4

6 2

4@B

5 2

Page 113: Pacer: Proportional Detection of Data Races

5@A

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4A B A B

5 4

6 2

Happens before?

4@B

5 2

Page 114: Pacer: Proportional Detection of Data Races

5@A

Thread A

write x

unlock m

read x

Thread B

lock m

write x

5 2 3 4A B A B

5 4

6 2

Happens before?

4@BRace!

5 2

Page 115: Pacer: Proportional Detection of Data Races

FastTrack[Flanagan & Freund ’09]

Pacer

Detection rate occurrence rate occurrence rate × r

Sampling rate

Page 116: Pacer: Proportional Detection of Data Races

FastTrack[Flanagan & Freund ’09]

Pacer

Detection rate occurrence rate occurrence rate × r

Running time t(c1 + c2n)

No. of threads

Page 117: Pacer: Proportional Detection of Data Races

FastTrack[Flanagan & Freund ’09]

Pacer

Detection rate occurrence rate occurrence rate × r

Running time t(c1 + c2n)

Reads & writes Synchronization

Page 118: Pacer: Proportional Detection of Data Races

FastTrack[Flanagan & Freund ’09]

Pacer

Detection rate occurrence rate occurrence rate × r

Running time t(c1 + c2n)

Reads & writes

Problem today Problem in future

Synchronization

Page 119: Pacer: Proportional Detection of Data Races

FastTrack[Flanagan & Freund ’09]

Pacer

Detection rate occurrence rate occurrence rate × r

Running time t(c1 + c2n) t[(c1 + c2n)r + c3]

Overhead in sampling periods

Page 120: Pacer: Proportional Detection of Data Races

FastTrack[Flanagan & Freund ’09]

Pacer

Detection rate occurrence rate occurrence rate × r

Running time t(c1 + c2n) t[(c1 + c2n)r + c3]

Overhead in sampling periods

Overhead in non-sampling periods (small)

Page 121: Pacer: Proportional Detection of Data Races
Page 122: Pacer: Proportional Detection of Data Races
Page 123: Pacer: Proportional Detection of Data Races

Data race occurs extremely rarely

Data race occurs extremely rarely

Data race occurs periodically

Pre-deployment Deployed

Page 124: Pacer: Proportional Detection of Data Races

“We test exhaustively … we had in excess of three million online operational hours [342 years] in which

nothing had ever exercised that bug.”–Mike Unum, manager of commercial solutions, GE Energy

http://www.securityfocus.com/news/8412

Page 125: Pacer: Proportional Detection of Data Races

Data race buggy execution


Recommended