michael bond katherine coons kathryn mckinley university of texas at austin
TRANSCRIPT
![Page 1: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/1.jpg)
Pacer: Proportional Detection of Data RacesMichael BondKatherine CoonsKathryn McKinleyUniversity of Texas at Austin
![Page 2: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/2.jpg)
Detecting data races in production
![Page 3: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/3.jpg)
Overhead
FastTrack[Flanagan & Freund ’09]
80x 8x
![Page 4: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/4.jpg)
Overhead
FastTrack[Flanagan & Freund ’09]
creads&writes + csync n
Number of threads
![Page 5: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/5.jpg)
Overhead
FastTrack[Flanagan & Freund ’09]
creads&writes + csync n
Problemin future
Problemtoday
![Page 6: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/6.jpg)
Overhead
FastTrack[Flanagan & Freund ’09]
creads&writes + csync n
Pacer (creads&writes + csync n) r + cnon-sampling (1 – r)
Sampling rate
![Page 7: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/7.jpg)
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/8.jpg)
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/9.jpg)
Detect race first access sampled
![Page 10: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/10.jpg)
Sampling period
Thread A Thread B
Non-sampling period
Sampling period
Non-sampling period
Non-sampling period
![Page 11: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/11.jpg)
Thread A Thread B
write x
read x
read y
write y
![Page 12: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/12.jpg)
Insight #1:Stop tracking variable after
non-sampled access
![Page 13: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/13.jpg)
Thread A
write x
unlock m
Thread B
![Page 14: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/14.jpg)
Thread A
write x
unlock m
Thread B
lock m
![Page 15: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/15.jpg)
Thread A
write x
unlock m
Thread B
lock m
write x
![Page 16: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/16.jpg)
Thread A
write x
unlock m
read x
Thread B
lock m
write x
![Page 17: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/17.jpg)
Thread A
write x
unlock m
read x
Thread B
lock m
write xRace!
![Page 18: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/18.jpg)
Thread A
write x
unlock m
read x
Thread B
lock m
write xRace!
![Page 19: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/19.jpg)
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/20.jpg)
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/21.jpg)
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/22.jpg)
Thread A
write x
unlock m
read x
Thread B
lock m
write x
5 2 3 4A B A B
![Page 23: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/23.jpg)
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/24.jpg)
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/25.jpg)
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/26.jpg)
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/27.jpg)
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 2
Happens before?
A B A B
![Page 28: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/28.jpg)
Thread A
write x
unlock m
read x
Thread B
lock m
write x
5 2 3 4
5 4
5@A
5 2
6 2
A B A B
![Page 29: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/29.jpg)
Thread A
write x
unlock m
read x
Thread B
lock m
write x
5 2 3 4
5 4
5@A
5 2
6 2
A B A B
![Page 30: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/30.jpg)
Thread A
write x
unlock m
read x
Thread B
lock m
write x
5 2 3 4
5 4
5@A
5 2
6 2
No work performed
A B A B
![Page 31: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/31.jpg)
Thread A
write x
unlock m
read x
Thread B
lock m
write x
5 2 3 4
5 4
5@A
5 2
6 2
Race uncaught
A B A B
![Page 32: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/32.jpg)
Thread A
write x
unlock m
read x
Thread B
lock m
write x
5 2 3 4
5 4
5 2
6 2
4@B
A B A B
![Page 33: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/33.jpg)
Thread A
write x
unlock m
read x
Thread B
lock m
write x
5 2 3 4
5 4
5 2
6 2
4@B
Happens before?Race!
A B A B
![Page 34: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/34.jpg)
Insight #2: We only care whether“A happens before B”
if A is sampled
![Page 35: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/35.jpg)
Thread A Thread B
Do these events happen before other events?We don’t care!
![Page 36: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/36.jpg)
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/37.jpg)
Thread A
unlock m1
…
unlock m2
Thread B
lock m1
…
lock m2
5 2 3 4A B A B
![Page 38: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/38.jpg)
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/39.jpg)
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/40.jpg)
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/41.jpg)
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/42.jpg)
Implementation
http://jikesrvm.org/Research+Archive
![Page 43: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/43.jpg)
Performance
0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%0
5
10
15
20
eclipsehsqldbxalanpseudojbb
Sampling rate
Slow
dow
n
1
![Page 44: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/44.jpg)
Performance
Qualitative improvementin time & space
![Page 45: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/45.jpg)
Accuracy
Probability (detecting any race) = r?
![Page 46: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/46.jpg)
Per-Race Accuracy(eclipse, r = 1%)
0%
1%
8%
Distinct races (ordered by detection rate)
Det
ectio
n ra
te
![Page 47: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/47.jpg)
Related Work
LiteRace [Marino et al. ’09]
Cold-region hypothesis [Chilimbi & Hauswirth ’04]
Full analysis at synchronization operations
![Page 48: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/48.jpg)
Deployable Race Detection
Accuracy, time, space sampling rateDetect race first access sampled
![Page 49: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/49.jpg)
Deployable Race Detection
Accuracy, time, space sampling rateDetect race first access sampled
Qualitative improvement
![Page 50: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/50.jpg)
Deployable Race Detection
Accuracy, time, space sampling rateDetect race first access sampled
Qualitative improvementHelp developers fix difficult-to-reproduce bugs
![Page 51: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/51.jpg)
Deployable Race Detection
Accuracy, time, space sampling rateDetect race first access sampled
Qualitative improvementHelp developers fix difficult-to-reproduce bugs
Thank you
![Page 52: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/52.jpg)
Backup
![Page 53: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/53.jpg)
Thread A
unlock m1
…
unlock m2
Thread B
lock m1
…
lock m2
5 2 3 4
5 4
A B A B
Example: “Timeless” Non-Sampling Periods
5 4
v6
Vector clock versions
![Page 54: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/54.jpg)
Thread A
unlock m1
…
unlock m2
Thread B
lock m1
…
lock m2
5 2 3 4
5 4
A B A B
Example: “Timeless” Non-Sampling Periods
v6
5 2 v6
v6
![Page 55: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/55.jpg)
Thread A
unlock m1
…
unlock m2
Thread B
lock m1
…
lock m2
5 2 3 4A B A B
Example: “Timeless” Non-Sampling Periods
v6
5 2 v6
5 2 v6
Join unnecessary
5 4v6
![Page 56: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/56.jpg)
Per-Race Accuracy (Eclipse)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 270%
1%
10%
100%
r = 25%r = 10%r = 5%r = 3%r = 1%
Distinct races (each line sorted by detection rate)
Det
ectio
n ra
te
![Page 57: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/57.jpg)
Space Performance (eclipse)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
200
400
600
800
r=100%r=25%r=5%r=1%Base
Fraction of program execution
Live
mem
ory
(MB)
![Page 58: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/58.jpg)
Performance (0-10% sampling rate)
0% 1% 2% 3% 4% 5% 6% 7% 8% 9% 10%0
1
2
3
4
eclipsehsqldbxalanpseudojbb
Sampling rate
Slow
dow
n
![Page 59: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/59.jpg)
0% 1% 2% 3% 4% 5% 6% 7% 8% 9% 10%0
1
2
3
4
eclipsehsqldbxalanpseudojbb
Sampling rate
Slow
dow
n
33% base overhead
52% over-head
Performance (0-10% sampling rate)
![Page 60: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/60.jpg)
0% 1% 2% 3% 4% 5% 6% 7% 8% 9% 10%0
1
2
3
4
eclipsehsqldbxalanpseudojbb
Sampling rate
Slow
dow
n
33% base overhead
52% over-head
Performance (0-10% sampling rate)
Qualitative improvement
![Page 61: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/61.jpg)
Methodology
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/62.jpg)
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/63.jpg)
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/64.jpg)
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/65.jpg)
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/66.jpg)
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/67.jpg)
Why Do We Care?
Races indicate Atomicity violations Order violations
![Page 68: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/68.jpg)
Why Do We Care?
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/69.jpg)
Why Do We Care?
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/70.jpg)
Producer-Consumer Example
class ProducerConsumer { boolean ready; int x;
produce() { x = … ; ready = true; }
consume() { while (!ready) { } … = x; }}
![Page 71: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/71.jpg)
Does It Race?
class ProducerConsumer { boolean ready; int x; T1 T2 produce() { x = … ; ready = true; }
consume() { while (!ready) { } … = x; }}
![Page 72: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/72.jpg)
Does It Race?
class ProducerConsumer { boolean ready; int x; T1 T2 produce() { x = … ; ready = true; }
consume() { while (!ready) { } … = x; }}
![Page 73: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/73.jpg)
So What?
class ProducerConsumer { boolean ready; int x; T1 T2 produce() { x = … ; ready = true; }
consume() { while (!ready) { } … = x; }}
![Page 74: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/74.jpg)
So What?
class ProducerConsumer { boolean ready; int x; T1 T2 produce() { x = … ; ready = true; }
consume() { while (!ready) { } … = x; }}
Can read old value
![Page 75: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/75.jpg)
So What?
class ProducerConsumer { boolean ready; int x; T1 T2 produce() { x = … ; ready = true; }
consume() { … = x; while (!ready) { } }}
Legal reordering by compiler or hardware
![Page 76: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/76.jpg)
How to Fix?
class ProducerConsumer { boolean ready; int x; T1 T2 produce() { x = … ; ready = true; }
consume() { while (!ready) { } … = x; }}
![Page 77: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/77.jpg)
Properly Synchronized
class ProducerConsumer { volatile boolean ready; int x; T1 T2 produce() { x = … ; ready = true; }
consume() { while (!ready) { } … = x; }}
Happens- before edge
![Page 78: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/78.jpg)
Example #2
class LibraryBook { Set<Person> borrowers;}
![Page 79: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/79.jpg)
Initialization on Demand
class LibraryBook { Set<Person> borrowers;
addBorrower(Person p) { if (borrowers == null) { borrowers = new HashSet<Person>(); } borrowers.add(p); }}
![Page 80: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/80.jpg)
Synchronized but Slow?
class LibraryBook { Set<Person> borrowers;
addBorrower(Person p) { synchronized (this) { if (borrowers == null) { borrowers = new HashSet<Person>(); } } borrowers.add(p); }}
![Page 81: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/81.jpg)
Double-Checked Locking
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/82.jpg)
Does It Race?
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/83.jpg)
Does It Race?
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/84.jpg)
So What?
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/85.jpg)
So What?
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/86.jpg)
So What?
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/87.jpg)
Performance vs. Accuracy
0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%0
5
10
15
20
eclipsehsqldbxalanpseudojbb
Detection rate ( sampling rate)
Slow
dow
n
![Page 88: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/88.jpg)
Performance vs. Accuracy
-1% 1% 3% 5% 7% 9% 11% 13% 15%0
1
2
3
4
5
eclipsehsqldbxalanpseudojbb
Detection rate ( sampling rate)
Slow
dow
n
33% base overhead
~50% overhead
![Page 89: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/89.jpg)
Accuracy & Performance
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/90.jpg)
Northeast Blackout of 2003
![Page 91: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/91.jpg)
Northeast Blackout of 2003
50 million people
![Page 92: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/92.jpg)
Northeast Blackout of 2003
Energy Management System Alarm and Event Processing Routine (1 MLOC)
http://www.securityfocus.com/news/8412
![Page 93: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/93.jpg)
Northeast Blackout of 2003
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/94.jpg)
Northeast Blackout of 2003
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/95.jpg)
Tracks happens-before: sound & precise 80X slowdown Each analysis step: O(n) time (n = # of threads)
Vector Clock-Based Race Detection
![Page 96: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/96.jpg)
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
Vector Clock-Based Race Detection
![Page 97: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/97.jpg)
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
Vector Clock-Based Race Detection
![Page 98: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/98.jpg)
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
Vector Clock-Based Race Detection
![Page 99: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/99.jpg)
Vector Clock-Based Race Detection
Thread A Thread B
5 2 3 4A B A B
Vector clocks
![Page 100: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/100.jpg)
Thread A Thread B
5 2 3 4A B A B
Vector clocks
Thread A’s logical time Thread B’s logical time
Vector Clock-Based Race Detection
![Page 101: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/101.jpg)
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
Vector Clock-Based Race Detection
![Page 102: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/102.jpg)
5 2 3 4A B A B
Vector Clock-Based Race Detection
Thread A
unlock m
Thread B
lock m6 2Increment
clock
![Page 103: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/103.jpg)
5 2 3 4A B A B
Vector Clock-Based Race Detection
Thread A
unlock m
Thread B
lock m6 2
5 4
5 2
Joinclocks
![Page 104: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/104.jpg)
5 2 3 4A B A B
Vector Clock-Based Race Detection
Thread A
unlock m
Thread B
lock m6 2
5 4 n = # of threads
O(n) time
5 2
![Page 105: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/105.jpg)
Vector Clock-Based Race Detection
Thread A
write x
unlock m
read x
Thread B
lock m
write x
5 2 3 4A B A B
![Page 106: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/106.jpg)
Vector Clock-Based Race Detection
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/107.jpg)
Vector Clock-Based Race Detection
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/108.jpg)
Vector Clock-Based Race Detection
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/109.jpg)
Vector Clock-Based Race Detection
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/110.jpg)
Vector Clock-Based Race Detection
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/111.jpg)
Vector Clock-Based Race Detection
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/112.jpg)
5@A
Vector Clock-Based Race Detection
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/113.jpg)
5@A
Vector Clock-Based Race Detection
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/114.jpg)
5@A
Vector Clock-Based Race Detection
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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/115.jpg)
FastTrack[Flanagan & Freund ’09]
Pacer
Detection rate occurrence rate occurrence rate × r
Prior Work Isn’t Deployable
Sampling rate
![Page 116: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/116.jpg)
FastTrack[Flanagan & Freund ’09]
Pacer
Detection rate occurrence rate occurrence rate × r
Running time t(c1 + c2n)
(Theoretical) Accuracy & Performance
No. of threads
![Page 117: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/117.jpg)
FastTrack[Flanagan & Freund ’09]
Pacer
Detection rate occurrence rate occurrence rate × r
Running time t(c1 + c2n)
(Theoretical) Accuracy & Performance
Reads & writes Synchronization
![Page 118: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/118.jpg)
FastTrack[Flanagan & Freund ’09]
Pacer
Detection rate occurrence rate occurrence rate × r
Running time t(c1 + c2n)
(Theoretical) Accuracy & Performance
Reads & writes
Problem today Problem in future
Synchronization
![Page 119: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/119.jpg)
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
(Theoretical) Accuracy & Performance
![Page 120: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/120.jpg)
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)
(Theoretical) Accuracy & Performance
![Page 121: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/121.jpg)
Pacer
![Page 122: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/122.jpg)
Pacer
![Page 123: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/123.jpg)
Detecting Data Races in Production
Data race occurs extremely rarely
Data race occurs extremely rarely
Data race occurs periodically
Pre-deployment Deployed
![Page 124: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/124.jpg)
Detecting Data Races in Production
“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: Michael Bond Katherine Coons Kathryn McKinley University of Texas at Austin](https://reader036.vdocument.in/reader036/viewer/2022062423/5697bf9a1a28abf838c91f39/html5/thumbnails/125.jpg)
Detecting Data Races in Production
Data race buggy execution