Data Races in Software Development

undefined
Swarnendu Biswas
, 
Minjia Zhang, and
Michael D. Bond
Ohio State University
Brandon Lucia
Carnegie Mellon University
OOPSLA 2015
Valor: Efficient, Software-Only Region Conflict
Exceptions
A Simple C++ Program
x = 
new
 X();
done = 
true
;
 
if
 (done) {
  x->func();
}
X* x = NULL;
bool
 done= 
false
;
    Thread T1
    Thread T2
A Simple C++ Program
x = 
new
 X();
done = 
true
;
 
if
 (done) {
  x->func();
}
X* x = NULL;
bool
 done= 
false
;
    Thread T1
    Thread T2
Data Races
x
 = 
new
 X();
done
 = 
true
;
 
if
 (
done
) {
  
x
->func();
}
X* x = NULL;
bool
 done= 
false
;
    Thread T1
    Thread T2
Data Races are  Evil
Catch-Fire Semantics
x = 
new
 X();
done = 
true
;
 
if
 (done) {
  x->func();
}
X* x = NULL;
bool
 done= 
false
;
    Thread T1
    Thread T2
Catch-Fire Semantics
x = 
new
 X();
done = 
true
;
 
if
 (done) {
  x->func();
}
X* x = NULL;
bool
 done= 
false
;
    Thread T1
    Thread T2
Catch-Fire Semantics
x = 
new
 X();
done = 
true
;
 
if
 (done) {
  x->func();
}
X* x = NULL;
bool
 done= 
false
;
    Thread T1
    Thread T2
A Java Example
X
 = 
new
 Object();
done
 = 
true;
while 
(!
done
) {}
X
.compute();
    Thread T1
    Thread T2
A Java Example
X
 = 
new
 Object();
done
 = 
true;
while 
(!
done
) {}
X
.compute();
    Thread T1
    Thread T2
C++ and Java Memory Models
C++ and Java Memory Models
C++ and Java Memory Models
Execution is sequentially consistent
C++ and Java Memory Models
Execution is sequentially consistent
C++ and Java Memory Models
C++ and Java Memory Models
Need for Stronger Memory Models
Need for Stronger Memory Models
“The inability to define reasonable semantics for programs with data
races is not just a theoretical shortcoming, but a fundamental hole in
the foundation of our languages and systems.”
Programming language memory models and data races
Data race and region conflict exceptions model
Valor: Our contribution
Evaluation
Outline
Data Race
    Thread T1
    Thread T2
X = 
new
 Object();
done = 
true;
while 
(!done) {}
X.compute();
Data Race Exceptions
    Thread T1
    Thread T2
X = 
new
 Object();
done = 
true;
while 
(!done) {}
X.compute();
EXCEPTION
REGION CONFLICT EXCEPTIONS MODEL
Region Conflict
    Thread T1
    Thread T2
Region Conflict
wr x
    Thread T1
    Thread T2
Region Conflict
rd/wr x
wr x
    Thread T1
    Thread T2
Region Conflict
rd/wr x
wr x
    Thread T1
Conflict
    Thread T2
Region Conflict
rd/wr x
wr x
    Thread T1
Conflict
    Thread T2
Execution Models
rd/wr x
wr x
    Thread T1
Conflict
    Thread T2
Region Conflict Exception Model
GOAL
Region Conflict Detection
Hardware customizations required for good performance
 Limited by resources and applicability
o
Needs extensive modifications and is unscalable
1
o
Detects serializability violations of bounded regions
2
1.
Lucia et al. Conflict Exceptions: Simplifying Concurrent Language Semantics With Precise Hardware Exceptions for
Data-Races. ISCA 2010.
2.
Marino et al. DRFx: A Simple and Efficient Memory Model for Concurrent Programming Languages. PLDI 2010.
Programming language memory models and data races
Data race and region conflict exceptions model
Valor: Our contribution
Evaluation
Outline
Valor: Efficient, Software-Only Region Conflict Detector
Elides tracking last readers, only tracks last writer
Detect read-write conflicts lazily
Tracking last writers
Detecting read-write conflicts lazily
Impact of lazy conflict detection
Tracking Last Writer
Per-Variable Metadata
Epoch
Tracking Last Writer
     Thread T1
     Thread T2
Tracking Last Writer
     Thread T1
     Thread T2
wr x
j
Tracking Last Writer
wr x
     Thread T1
j
Track last writer
     Thread T2
Tracking Last Writer
wr x
     Thread T1
j
Track last writer
     Thread T2
Tracking Last Writer
rd/wr x
wr x
     Thread T1
j
Track last writer
     Thread T2
Tracking Last Writer
rd/wr x
wr x
     Thread T1
j
Conflict
Track last writer
     Thread T2
Tracking Last Writer
rd/wr x
wr x
     Thread T1
j
Conflict
Track last writer
Allows precisely detecting
write-write and write-read
conflicts
     Thread T2
Tracking last writers
Detecting read-write conflicts lazily
Impact of lazy conflict detection
Detecting Read-Write Conflicts
Detecting Read-Write Conflicts
Detecting Read-Write Conflicts
Detecting Read-Write Conflicts
Detecting Read-Write Conflicts
Detecting Read-Write Conflicts
This simple mechanism used in prior work has problems
Remote Cache Misses Due to Tracking of Metadata
Thread T1
rd x
j
Leads to remote
cache misses
update
metadata
Metadata Updates
Thread T1
rd/wr x
j
Metadata Updates
Thread T1
rd/wr x
j
update
metadata
Synchronization on Metadata Updates
Thread T1
rd/wr x
lock l
j
Synchronization on Metadata Updates
Thread T1
rd/wr x
lock l
j
update
metadata
Synchronization on Metadata Updates
Thread T1
rd/wr x
unlock l
lock l
j
update
metadata
Synchronization on Metadata Updates
Thread T1
rd/wr x
unlock l
lock l
j
Bad for mostly
read-only data
update
metadata
Elide Tracking Last Readers
Elide Tracking Last Readers
rd x
     Thread T1
?
Elide Tracking Last Readers
rd x
     Thread T1
Detect read-write conflicts lazily
wr x
Elide Tracking Last Readers
rd x
     Thread T1
Detect read-write conflicts lazily
Log read accesses in thread-
local buffers
Validate reads at region
boundaries
1. Saha et al. McRT-STM: A High Performance Software Transactional
Memory System for a Multi-Core Runtime. PPoPP 2006.
wr x
Per-Variable Metadata
Version, Epoch
Elide Tracking Last Readers
rd x
     Thread T1
j
Detect read-write conflicts lazily
Log read accesses in thread-
local buffers
Validate reads at region
boundaries
Elide Tracking Last Readers
rd x
     Thread T1
Detect read-write conflicts lazily
log <x, v>
Log read accesses in thread-
local buffers
Validate reads at region
boundaries
j
Elide Tracking Last Readers
rd x
     Thread T1
Detect read-write conflicts lazily
log <x, v>
k
j
wr x
Elide Tracking Last Readers
rd x
     Thread T1
Detect read-write conflicts lazily
log <x, v>
k
j
wr x
Elide Tracking Last Readers
rd x
     Thread T1
Detect read-write conflicts lazily
log <x, v>
read
validation
k
j
wr x
Elide Tracking Last Readers
rd x
     Thread T1
Detect read-write conflicts lazily
log <x, v>
read
validation
T1 is not the last
writer
Version read is
outdated
k
j
wr x
Elide Tracking Last Readers
rd x
     Thread T1
Detect read-write conflicts lazily
log <x, v>
read
validation
T1 is not the last
writer
Version read is
outdated
Conflict
j
k
wr x
Elide Tracking Last Readers
Tracking last writers
Detecting read-write conflicts lazily
Impact of lazy conflict detection
Precise Conflict Detection
Precise vs Lazy Conflict Detection
read
validation
Conflict
Precise vs Lazy Conflict Detection
read
validation
Conflict
Delayed Exceptions
read
validation
Conflict
Delayed Exceptions
read
validation
Conflict
Programming language memory models and data races
Data race and region conflict exceptions model
Valor: Our contribution
Evaluation
Outline
IMPLEMENTATION
Implementation
Developed on top of Jikes RVM 3.1.3
Implementation
1. Flanagan and Freund. FastTrack: Efficient and Precise Dynamic Data Race Detection. PLDI 2009.
Developed on top of Jikes RVM 3.1.3
Implemented FastTrack, state-of-art
happens-before analysis based data
race detector
Implementation
Developed on top of Jikes RVM 3.1.3
Implemented FastTrack, state-of-art
happens-before analysis based data
race detector
Shared on Jikes RVM Research Archive
and ACM DL
EVALUATION
Benchmarks
Large workload sizes of DaCapo 2006 and 9.12-bach suite
Fixed-workload versions of SPECjbb2000 and SPECjbb2005
Platform
64-core AMD Opteron 6272
Experimental Methodology
Performance Comparison
Performance Comparison
Performance Comparison
Performance Comparison: Intel Xeon
Additional Experiments
Valor: Contributions
Strong execution guarantees in software
Advances state-of-art
Provides strong semantics in software at less than 100%
overhead
New Opportunities with Valor
Reorder and 
eliminate
 redundant loads and stores within synchronization-
free regions
undefined
Swarnendu Biswas
, 
Minjia Zhang, and
Michael D. Bond
Ohio State University
Brandon Lucia
Carnegie Mellon University
OOPSLA 2015
Valor: Efficient, Software-Only Region Conflict
Exceptions
Slide Note

Good afternoon everyone.

I will talk about our work which assigns strong semantics to all program executions at less than 100% overhead in software.

Embed
Share

The content discusses the challenges posed by data races in software development, particularly in C++ and Java programs. Data races can lead to unsafe software, complicate language specifications, and make it challenging to ensure correctness in concurrent executions. Catch-Fire Semantics in C++ treat data races as errors, emphasizing the importance of addressing them proactively to prevent issues. Examples and insights are provided to highlight the impact of data races on software integrity.

  • Data Races
  • Software Development
  • C++
  • Java
  • Concurrency

Uploaded on Sep 11, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Valor: Efficient, Software-Only Region Conflict Exceptions Swarnendu Biswas, Minjia Zhang, and Michael D. Bond Ohio State University Brandon Lucia Carnegie Mellon University OOPSLA 2015

  2. A Simple C++ Program X* x = NULL; bool done= false; Thread T1 Thread T2 x = new X(); done = true; if (done) { x->func(); }

  3. A Simple C++ Program X* x = NULL; bool done= false; Thread T1 Thread T2 if (done) { x->func(); } x = new X(); done = true;

  4. Data Races X* x = NULL; bool done= false; Thread T1 Thread T2 x = new X(); done = true; if (done) { x->func(); } Data race

  5. Data Races are Evil No semantic guarantees Lack of semantic guarantees make software unsafe Complicates language specifications Challenging to reason about correctness for racy executions Indicates other concurrency errors Leads to atomicity, order or sequential consistency violations

  6. Catch-Fire Semantics C++ treats data races as errors X* x = NULL; bool done= false; Thread T1 Thread T2 x = new X(); done = true; if (done) { x->func(); }

  7. Catch-Fire Semantics C++ treats data races as errors X* x = NULL; bool done= false; Thread T1 Thread T2 x = new X(); done = true; if (done) { x->func(); }

  8. Catch-Fire Semantics C++ treats data races as errors X* x = NULL; bool done= false; Thread T1 Thread T2 x = new X(); done = true; if (done) { x->func(); }

  9. A Java Example Thread T1 Thread T2 X = new Object(); done = true; while (!done) {} X.compute();

  10. A Java Example Java tries to assign semantics, which are unsatisfactory Thread T1 Thread T2 X = new Object(); done = true; while (!done) {} X.compute();

  11. C++ and Java Memory Models Data-race-free execution Strong semantics

  12. C++ and Java Memory Models Data-race-free execution Strong semantics Execution is sequentially consistent

  13. C++ and Java Memory Models Data-race-free execution Strong semantics Execution is sequentially consistent Synchronization-free regions execute atomically

  14. lock(l) C++ and Java Memory Models lock(m) Data-race-free execution Strong semantics SFR Execution is sequentially consistent unlock(m) Synchronization-free regions execute atomically unlock(l)

  15. C++ and Java Memory Models But what about data races?

  16. C++ and Java Memory Models But what about data races? ??? Racy execution

  17. Need for Stronger Memory Models Adve and Boehm, CACM 2010 The inability to define reasonable semantics for programs with data races is not just a theoretical shortcoming, but a fundamental hole in the foundation of our languages and systems.

  18. Need for Stronger Memory Models Adve and Boehm, CACM 2010 The inability to define reasonable semantics for programs with data races is not just a theoretical shortcoming, but a fundamental hole in the foundation of our languages and systems. We call upon software and hardware communities to develop languages and systems that enforce data-race-freedom, ...

  19. Outline Programming language memory models and data races Data race and region conflict exceptions model Valor: Our contribution Evaluation

  20. Data Race Thread T1 Thread T2 X = new Object(); done = true; while (!done) {} X.compute();

  21. Data Race Exceptions Thread T1 Thread T2 EXCEPTION X = new Object(); done = true; while (!done) {} X.compute();

  22. REGION CONFLICT EXCEPTIONS MODEL

  23. Region Conflict Thread T1 Thread T2

  24. Region Conflict Thread T1 Thread T2 wr x

  25. Region Conflict Thread T1 Thread T2 wr x rd/wr x

  26. Region Conflict Thread T1 Thread T2 wr x rd/wr x Conflict

  27. Region Conflict Reports a subset of true data races that violate region serializability Thread T1 Thread T2 wr x rd/wr x Conflict

  28. Execution Models Reports a subset of true data races that violate region serializability sequentially consistent Thread T1 Thread T2 region-conflict- free wr x data-race-free region serializable rd/wr x Conflict

  29. Region Conflict Exception Model GOAL Develop a practical region conflict detection technique

  30. Region Conflict Detection Hardware customizations required for good performance Limited by resources and applicability o Needs extensive modifications and is unscalable1 o Detects serializability violations of bounded regions2 1. Lucia et al. Conflict Exceptions: Simplifying Concurrent Language Semantics With Precise Hardware Exceptions for Data-Races. ISCA 2010. Marino et al. DRFx: A Simple and Efficient Memory Model for Concurrent Programming Languages. PLDI 2010. 2.

  31. Outline Programming language memory models and data races Data race and region conflict exceptions model Valor: Our contribution Evaluation

  32. Valor: Efficient, Software-Only Region Conflict Detector Elides tracking last readers, only tracks last writer Detect read-write conflicts lazily

  33. Valor: Efficient, Software-Only Region Conflict Detector Tracking last writers Detecting read-write conflicts lazily Impact of lazy conflict detection

  34. Tracking Last Writer

  35. Per-Variable Metadata Epoch j@T1 Thread T1 Has an ongoing region updated x? j wr x

  36. Tracking Last Writer x p@T0 Thread T1 Thread T2

  37. Tracking Last Writer x p@T0 Thread T1 Thread T2 j wr x

  38. Tracking Last Writer x p@T0 Thread T1 Thread T2 Track last writer j wr x

  39. Tracking Last Writer x j@T1 update metadata Thread T1 Thread T2 Track last writer j wr x

  40. Tracking Last Writer x j@T1 Thread T1 Thread T2 Track last writer j wr x rd/wr x

  41. Tracking Last Writer x j@T1 Thread T1 Thread T2 Track last writer j wr x Conflict rd/wr x

  42. Tracking Last Writer x j@T1 Thread T1 Thread T2 Track last writer Allows precisely detecting write-write and write-read conflicts j wr x Conflict rd/wr x

  43. Valor: Efficient, Software-Only Region Conflict Detector Tracking last writers Detecting read-write conflicts lazily Impact of lazy conflict detection

  44. Detecting Read-Write Conflicts Thread T1 Thread T2 rd x wr x

  45. Detecting Read-Write Conflicts x p@T0 Thread T1 Thread T2 j rd x

  46. Detecting Read-Write Conflicts x j@T1 update read metadata Thread T1 Thread T2 j rd x

  47. Detecting Read-Write Conflicts x j@T1 Thread T1 Thread T2 j rd x wr x

  48. Detecting Read-Write Conflicts x j@T1 Thread T1 Thread T2 j rd x Conflict wr x

  49. Detecting Read-Write Conflicts x j@T1 Thread T1 Thread T2 j rd x This simple mechanism used in prior work has problems Conflict wr x

  50. Remote Cache Misses Due to Tracking of Metadata Thread T1 j Leads to remote cache misses Write operation update metadata rd x

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#